Class AbstractUpgradeManager

    • Field Detail

      • buildNumberComparator

        protected final Comparator<String> buildNumberComparator
      • oldBuildNumber

        protected String oldBuildNumber
      • newBuildNumber

        protected final String newBuildNumber
      • fileName

        protected final String fileName
      • xPathExpression

        protected final String xPathExpression
      • applicationConfig

        protected final com.atlassian.config.ApplicationConfiguration applicationConfig
      • textProvider

        protected com.opensymphony.xwork2.TextProvider textProvider
    • Constructor Detail

      • AbstractUpgradeManager

        protected AbstractUpgradeManager​(@NotNull
                                         @NotNull com.atlassian.config.ApplicationConfiguration applicationConfig,
                                         @NotNull
                                         @NotNull String newBuildNumber,
                                         @NotNull
                                         @NotNull String fileName,
                                         @NotNull
                                         @NotNull String xPathExpression,
                                         @NotNull
                                         @NotNull BootstrapManager bootstrapManager)
    • Method Detail

      • needUpgrade

        public boolean needUpgrade()
        Description copied from interface: UpgradeManager
        Determines whether we need to run the upgrade or not.
        Specified by:
        needUpgrade in interface UpgradeManager
        Returns:
        boolean whether the upgrade is needed
      • getBuildNumber

        @NotNull
        public @NotNull String getBuildNumber()
        Description copied from interface: UpgradeManager
        This gets the current build number
        Specified by:
        getBuildNumber in interface UpgradeManager
        Returns:
        the current build number (stored in application config file)
      • forEachTask

        protected <E extends Exception> void forEachTask​(@NotNull
                                                         @NotNull String xPathExpression,
                                                         @NotNull
                                                         @NotNull String installationBuildNumber,
                                                         @NotNull
                                                         @NotNull String upgradeBuildNumber,
                                                         @NotNull
                                                         BambooClosures.Throwing1<UpgradeTask,​E> action)
                                                  throws UpgradeException,
                                                         E extends Exception
        Iterates over upgrade tasks, lazily instantiating them on the fly.

        Provided action will be performed on all previous upgrade tasks before a new task is instantiated. This may be beneficial for validation tasks, to detect problems and report them nicely instead of relying on infrastructure exceptions. (For example, first upgrade task may detect broken DB configuration and fail, and subsequent one, requiring DB connection from Spring beans, won't even be created.)

        To eagerly instantiate all upgrade tasks, use createTasks(String, String, String).

        Throws:
        UpgradeException
        E extends Exception
      • getUpgradeDocument

        protected org.dom4j.Document getUpgradeDocument()
                                                 throws org.dom4j.DocumentException
        Throws:
        org.dom4j.DocumentException
      • getDescription

        @NotNull
        protected @NotNull String getDescription​(@NotNull
                                                 @NotNull UpgradeTask task,
                                                 String thisTaskBuildNumber)
      • shouldRunTask

        protected boolean shouldRunTask​(@NotNull
                                        @NotNull org.dom4j.Element element,
                                        @NotNull
                                        @NotNull String installationBuildNumber,
                                        @NotNull
                                        @NotNull String upgradeBuildNumber)
      • getUpgradeTasks

        public SortedMap<String,​UpgradeTask> getUpgradeTasks()
        Gets a map of upgrade tasks which need to run.
        Returns:
        SortedMap map of upgrade tasks, keys are the string representations of the build number.
      • setUpgradeUtilityBean

        public void setUpgradeUtilityBean​(UpgradeUtilityBean upgradeUtilityBean)
      • setTextProvider

        public void setTextProvider​(com.opensymphony.xwork2.TextProvider textProvider)