Package com.atlassian.confluence.upgrade
Class AbstractUpgradeManager
java.lang.Object
com.atlassian.confluence.upgrade.AbstractUpgradeManager
- All Implemented Interfaces:
UpgradeManager,UpgradeTaskInfoService,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.InitializingBean
- Direct Known Subclasses:
DefaultUpgradeManager
public abstract class AbstractUpgradeManager
extends Object
implements UpgradeManager, org.springframework.beans.factory.InitializingBean, UpgradeTaskInfoService, org.springframework.beans.factory.BeanFactoryAware
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intIn Confluence 8.0.0 we have removed upgrade tasks with build numbers lower than 7103 Cloud's build number is still that of the fork "6452", so our build number is too high.static final Comparator<UpgradeTask>Fields inherited from interface com.atlassian.confluence.upgrade.UpgradeManager
MINIMUM_SUPPORTED_UPGRADE_BUILD_NUMBER, MINIMUM_SUPPORTED_UPGRADE_VERSION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidstatic voidassertNoDuplicateBuildNumbers(Iterable<UpgradeTask> upgradeTasks) protected voidbooleanconfiguredBuildNumberNewerThan(String buildNumber) Returns true if the passed build number is less than the configured build number - that is, the version of the currently running Confluence is newer than the version passed.voidCalled when all immediate and deferred upgrade actions have been performed *if* an upgrade was needed.protected abstract voidprotected List<UpgradeTask>While this could just return the list of UpgradeTasks directly (since UpgradeTask implements UpgradeTaskInfo), we re-wrap them here to prevent plugins from casting them to UpgradeTask and trying to execute them.protected Stringprotected abstract StringgetExportBuildNumber(boolean isSpaceExport) Tells the earliest version the exports will be compatible with.Calculates the oldest build number from which a space can be imported.getPluginExportCompatibility(boolean isSpaceExport) Returns the list of plugins with data (especially plugins with Active Objects data) and tells how backward-compatible they are.protected abstract Stringprotected List<UpgradeTask>protected voidOnce all upgrade tasks have been completed without error, make sure the build number stored in the applications main configuration file and database now matches the build number of this version of the release.booleanprotected booleanbooleanprotected booleanThis is used to guard against database upgrades being performed multiple times on the same database.protected voidprotected abstract voidprotected abstract List<UpgradeError>Runs all upgrade prerequisites.protected voidrunUpgradeTasks(List<UpgradeTask> upgradeTasks) voidsetApplicationConfig(com.atlassian.config.ApplicationConfiguration applicationConfig) voidsetBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) protected voidsetConfiguredBuildNumber(String buildNumber) protected abstract voidsetDatabaseBuildNumber(String databaseBuildNumber) Once the upgrade is complete, we'll need to set the new database build number in the database.voidsetPluginAccessor(com.atlassian.plugin.PluginAccessor pluginAccessor) voidsetPluginDependentUpgradeTaskNames(List<String> upgradeTaskNames) voidsetPluginDependentUpgradeTasks(List<DeferredUpgradeTask> upgradeTasks) voidsetPreSchemaUpgradeTaskNames(List<String> preSchemaUpgradeTaskNames) voidsetPreSchemaUpgradeTasks(List<UpgradeTask> preSchemaUpgradeTasks) voidsetSchemaUpgradeTaskNames(List<String> upgradeTaskNames) voidsetSchemaUpgradeTasks(List<UpgradeTask> upgradeTasks) voidsetUpgradedFlag(com.atlassian.confluence.upgrade.MutableUpgradedFlag upgradedFlag) voidsetUpgradeTaskNames(List<String> upgradeTaskNames) voidsetUpgradeTasks(List<UpgradeTask> upgradeTasks) booleantaskNewerThan(String buildNumber, UpgradeTask upgradeTask) Returns true if the build number for the task is greater than the passed build number.protected abstract voidvoidupgrade(com.atlassian.johnson.JohnsonEventContainer agentJohnson) protected voidprotected voidupgradeTaskSucceeded(UpgradeTask upgradeTask) protected abstract voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.confluence.upgrade.UpgradeManager
setDatabaseBuildNumber
-
Field Details
-
MAXIMUM_CLOUD_BUILD_VERSION_NUMBER
protected static final int MAXIMUM_CLOUD_BUILD_VERSION_NUMBERIn Confluence 8.0.0 we have removed upgrade tasks with build numbers lower than 7103 Cloud's build number is still that of the fork "6452", so our build number is too high. This temporary fix ensures the build number is what cloud expects until we update the logic regarding cloud server compatibility.- See Also:
-
UPGRADE_TASK_COMPARATOR
-
-
Constructor Details
-
AbstractUpgradeManager
public AbstractUpgradeManager()
-
-
Method Details
-
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) - Specified by:
setBeanFactoryin interfaceorg.springframework.beans.factory.BeanFactoryAware
-
setApplicationConfig
public void setApplicationConfig(com.atlassian.config.ApplicationConfiguration applicationConfig) -
setUpgradedFlag
public void setUpgradedFlag(com.atlassian.confluence.upgrade.MutableUpgradedFlag upgradedFlag) -
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
validateSchemaUpdateIfNeeded
protected abstract void validateSchemaUpdateIfNeeded() throws com.atlassian.config.ConfigurationException- Throws:
com.atlassian.config.ConfigurationException
-
updateSchemaIfNeeded
protected abstract void updateSchemaIfNeeded() throws com.atlassian.config.ConfigurationException- Throws:
com.atlassian.config.ConfigurationException
-
releaseSchemaReferences
protected abstract void releaseSchemaReferences() -
upgrade
public void upgrade(com.atlassian.johnson.JohnsonEventContainer agentJohnson) throws UpgradeException - Specified by:
upgradein interfaceUpgradeManager- Throws:
UpgradeException
-
neededSchemaUpgrade
protected boolean neededSchemaUpgrade() -
finalizeIfNeeded
- Throws:
UpgradeException
-
runUpgradeTasks
- Throws:
UpgradeException
-
getAllUpgradeTasks
- Returns:
- the complete list of upgrade tasks for checking space import/export compatibility, in the correct order.
-
getAllUpgradeTasksInfo
While this could just return the list of UpgradeTasks directly (since UpgradeTask implements UpgradeTaskInfo), we re-wrap them here to prevent plugins from casting them to UpgradeTask and trying to execute them. That would be bad.- Specified by:
getAllUpgradeTasksInfoin interfaceUpgradeTaskInfoService- Returns:
- a Collection of
UpgradeTaskInfoobjects, one for eachUpgradeTaskin the system, in no particular order.
-
getUpgradeTasksToRun
- Returns:
- the complete list of upgrade tasks to be run for this upgrade, in the correct order. Note: this excludes pre-schema upgrade tasks
-
upgradeTaskSucceeded
- Throws:
Exception
-
upgradeStarted
protected void upgradeStarted() -
getPreSchemaUpgradeTasks
-
setPreSchemaUpgradeTasks
-
setPreSchemaUpgradeTaskNames
- Since:
- 7.5
-
setUpgradeTasks
-
setUpgradeTaskNames
- Since:
- 7.5
-
setPluginAccessor
public void setPluginAccessor(com.atlassian.plugin.PluginAccessor pluginAccessor) -
assertNoDuplicateBuildNumbers
public static void assertNoDuplicateBuildNumbers(Iterable<UpgradeTask> upgradeTasks) throws IllegalStateException - Throws:
IllegalStateException
-
getUpgradeTasks
-
setSchemaUpgradeTasks
-
setSchemaUpgradeTaskNames
- Since:
- 7.5
-
getSchemaUpgradeTasks
-
getErrors
- Specified by:
getErrorsin interfaceUpgradeManager
-
setPluginDependentUpgradeTasks
-
setPluginDependentUpgradeTaskNames
- Since:
- 7.5
-
getPluginDependentUpgradeTasks
-
runUpgradePrerequisites
Runs all upgrade prerequisites.- Returns:
- an empty list if all upgrade prerequisites pass, otherwise, returns a list consisting of one or more failure messages.
-
getConfiguredBuildNumber
- Returns:
- The build number of the current version that the user is running under. This version is stored in their confluence home confluence.cfg.xml file
-
setConfiguredBuildNumber
protected void setConfiguredBuildNumber(String buildNumber) throws com.atlassian.config.ConfigurationException - Throws:
com.atlassian.config.ConfigurationException
-
needUpgrade
public boolean needUpgrade()- Specified by:
needUpgradein interfaceUpgradeManager
-
configuredBuildNumberNewerThan
Description copied from interface:UpgradeManagerReturns true if the passed build number is less than the configured build number - that is, the version of the currently running Confluence is newer than the version passed.- Specified by:
configuredBuildNumberNewerThanin interfaceUpgradeManager
-
taskNewerThan
Description copied from interface:UpgradeManagerReturns true if the build number for the task is greater than the passed build number. Usually indicates that the task should run as part of an upgrade.- Specified by:
taskNewerThanin interfaceUpgradeManager
-
initialUpgradeFinished
Once all upgrade tasks have been completed without error, make sure the build number stored in the applications main configuration file and database now matches the build number of this version of the release.Note that this method is called "initialUpgradeFinished" because any deferred pluginDependentUpgradeTasks may still have to run, so the upgrade process is not yet complete.
- Throws:
Exception- when setting the database or configuration build number fails
-
entireUpgradeFinished
public void entireUpgradeFinished()Description copied from interface:UpgradeManagerCalled when all immediate and deferred upgrade actions have been performed *if* an upgrade was needed.- Specified by:
entireUpgradeFinishedin interfaceUpgradeManager
-
getRealBuildNumber
- Returns:
- The build number of the new version of Confluence being upgraded to. This number can be found in the default.properties of the new expanded WAR
-
getDatabaseBuildNumber
- Returns:
- The build number of the data in the database. If the version of the database data can not be
determined, this method should return the same value as
getConfiguredBuildNumber().
-
setDatabaseBuildNumber
Once the upgrade is complete, we'll need to set the new database build number in the database.- Parameters:
databaseBuildNumber- The new database build number- Throws:
Exception- when there is any problem setting the database build number
-
permitDatabaseUpgrades
This is used to guard against database upgrades being performed multiple times on the same database. By default, assume a non-clustered setup and allow database upgrades.- Returns:
- True by default. Is overridden for cluster upgrades.
- Throws:
UpgradeException- If the implementation of this method encounters any errors.
-
beforeUpgrade
- Throws:
UpgradeException
-
postUpgrade
protected void postUpgrade() -
isUpgraded
public boolean isUpgraded()- Specified by:
isUpgradedin interfaceUpgradeManager- Returns:
- true if the UpgradeManager was able to successfully upgrade this instance, or if no upgrade was necessary; otherwise false.
-
getOldestSpaceImportAllowed
Description copied from interface:UpgradeManagerCalculates the oldest build number from which a space can be imported.- Specified by:
getOldestSpaceImportAllowedin interfaceUpgradeManager- Returns:
- the build number
-
getExportBuildNumber
Description copied from interface:UpgradeManagerTells the earliest version the exports will be compatible with.- Specified by:
getExportBuildNumberin interfaceUpgradeManager- Parameters:
isSpaceExport- true if the export is about a space, false for a global export.- Returns:
- a build number
-
getPluginExportCompatibility
Description copied from interface:UpgradeManagerReturns the list of plugins with data (especially plugins with Active Objects data) and tells how backward-compatible they are.
If at least one plugin isn't compatible, the importer silently doesn't import any data.
What is a compatible version?
The data is exported as-is in XML and reimported in an earlier version. If the earlier version of the plugin is able to read the data without fault, then it is compatible. Note that there is no downgrade task, obviously.
- Specified by:
getPluginExportCompatibilityin interfaceUpgradeManager- Parameters:
isSpaceExport- true if the export is about a space, false for a global export.- Returns:
- a matrix of plugin key and minimum versions of the plugins.
-