public abstract class AbstractUpgradeManager extends Object implements UpgradeManager
Modifier and Type | Field and Description |
---|---|
protected com.atlassian.config.ApplicationConfiguration |
applicationConfig |
protected io.atlassian.util.concurrent.ResettableLazyReference<BambooSharedProperties> |
bambooSharedProperties |
protected Comparator<String> |
buildNumberComparator |
protected String |
fileName |
protected String |
newBuildNumber |
protected String |
oldBuildNumber |
protected com.opensymphony.xwork2.TextProvider |
textProvider |
protected SortedMap<String,UpgradeTask> |
upgradeTasks |
protected UpgradeUtilityBean |
upgradeUtilityBean |
protected String |
xPathExpression |
Modifier | Constructor and Description |
---|---|
protected |
AbstractUpgradeManager(@NotNull com.atlassian.config.ApplicationConfiguration applicationConfig,
@NotNull String newBuildNumber,
@NotNull String fileName,
@NotNull String xPathExpression,
@NotNull BootstrapManager bootstrapManager) |
protected |
AbstractUpgradeManager(@NotNull com.atlassian.config.ApplicationConfiguration applicationConfig,
@NotNull String newBuildNumber,
@NotNull String fileName,
@NotNull String xPathExpression,
@NotNull BootstrapManager bootstrapManager,
@NotNull Supplier<BambooSharedProperties> bambooSharedPropertiesSupplier) |
Modifier and Type | Method and Description |
---|---|
protected void |
classifyUpgradeTask(@NotNull String bambooBuildNumber,
@NotNull UpgradeTask task) |
protected SortedMap<String,UpgradeTask> |
createTasks(@NotNull String xPathExpression,
@NotNull String installationBuildNumber,
@NotNull String upgradeBuildNumber)
Creates a mapping of build numbers to upgrade tasks.
|
UpgradeTask |
createUpgradeTask(String className) |
protected <E extends Exception> |
forEachTask(@NotNull String xPathExpression,
@NotNull String installationBuildNumber,
@NotNull String upgradeBuildNumber,
BambooClosures.Throwing1<UpgradeTask,E> action)
Iterates over upgrade tasks, lazily instantiating them on the fly.
|
@NotNull String |
getBuildNumber()
This gets the current build number
|
protected @NotNull String |
getDescription(@NotNull UpgradeTask task,
String thisTaskBuildNumber) |
String |
getOldBuildNumber() |
protected org.dom4j.Document |
getUpgradeDocument() |
SortedMap<String,UpgradeTask> |
getUpgradeTasks()
Gets a map of upgrade tasks which need to run.
|
boolean |
needUpgrade()
Determines whether we need to run the upgrade or not.
|
protected void |
populateRelevantUpgrades(@NotNull String buildNumberLo,
@NotNull String buildNumberHi) |
protected String |
runUpgradeTask(@NotNull UpgradeTask task,
@NotNull List<String> errors) |
void |
setTextProvider(com.opensymphony.xwork2.TextProvider textProvider) |
void |
setUpgradeUtilityBean(UpgradeUtilityBean upgradeUtilityBean) |
protected boolean |
shouldRunTask(@NotNull org.dom4j.Element element,
@NotNull String installationBuildNumber,
@NotNull String upgradeBuildNumber) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
doUpgrade
protected final Comparator<String> buildNumberComparator
protected String oldBuildNumber
protected final String newBuildNumber
protected final String fileName
protected final String xPathExpression
protected final SortedMap<String,UpgradeTask> upgradeTasks
protected final com.atlassian.config.ApplicationConfiguration applicationConfig
protected final io.atlassian.util.concurrent.ResettableLazyReference<BambooSharedProperties> bambooSharedProperties
protected UpgradeUtilityBean upgradeUtilityBean
protected com.opensymphony.xwork2.TextProvider textProvider
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)
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, @NotNull @NotNull Supplier<BambooSharedProperties> bambooSharedPropertiesSupplier)
public boolean needUpgrade()
UpgradeManager
needUpgrade
in interface UpgradeManager
boolean
whether the upgrade is needed@NotNull public @NotNull String getBuildNumber()
UpgradeManager
getBuildNumber
in interface UpgradeManager
protected void populateRelevantUpgrades(@NotNull @NotNull String buildNumberLo, @NotNull @NotNull String buildNumberHi) throws UpgradeException
UpgradeException
protected void classifyUpgradeTask(@NotNull @NotNull String bambooBuildNumber, @NotNull @NotNull UpgradeTask task) throws UpgradeException
UpgradeException
protected SortedMap<String,UpgradeTask> createTasks(@NotNull @NotNull String xPathExpression, @NotNull @NotNull String installationBuildNumber, @NotNull @NotNull String upgradeBuildNumber) throws UpgradeException
All matching upgrade tasks are instantiated by this method. This means that if there's a problem with instantiating at least one upgrade task (for example due to broken Spring dependencies), this method will throw.
To lazily iterate over upgrade tasks, use forEachTask(String, String, String, BambooClosures.Throwing1)
.
UpgradeException
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
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)
.
UpgradeException
E extends Exception
public UpgradeTask createUpgradeTask(String className) throws UpgradeException
UpgradeException
protected org.dom4j.Document getUpgradeDocument() throws org.dom4j.DocumentException
org.dom4j.DocumentException
protected String runUpgradeTask(@NotNull @NotNull UpgradeTask task, @NotNull @NotNull List<String> errors)
@NotNull protected @NotNull String getDescription(@NotNull @NotNull UpgradeTask task, String thisTaskBuildNumber)
protected boolean shouldRunTask(@NotNull @NotNull org.dom4j.Element element, @NotNull @NotNull String installationBuildNumber, @NotNull @NotNull String upgradeBuildNumber)
public SortedMap<String,UpgradeTask> getUpgradeTasks()
SortedMap
map of upgrade tasks, keys are the string representations
of the build number.public String getOldBuildNumber()
getOldBuildNumber
in interface UpgradeManager
public void setUpgradeUtilityBean(UpgradeUtilityBean upgradeUtilityBean)
public void setTextProvider(com.opensymphony.xwork2.TextProvider textProvider)
Copyright © 2022 Atlassian Software Systems Pty Ltd. All rights reserved.