com.atlassian.confluence.upgrade
Class AbstractUpgradeManager

java.lang.Object
  extended by com.atlassian.confluence.upgrade.AbstractUpgradeManager
All Implemented Interfaces:
UpgradeManager, UpgradeTaskInfoService, org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
DefaultUpgradeManager

public abstract class AbstractUpgradeManager
extends java.lang.Object
implements UpgradeManager, org.springframework.beans.factory.InitializingBean, UpgradeTaskInfoService


Field Summary
 
Fields inherited from interface com.atlassian.confluence.upgrade.UpgradeManager
MINIMUM_SUPPORTED_UPGRADE_BUILD_NUMBER, MINIMUM_SUPPORTED_UPGRADE_VERSION
 
Constructor Summary
AbstractUpgradeManager()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  void beforeUpgrade()
           
 boolean configuredBuildNumberNewerThan(java.lang.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.
 void entireUpgradeFinished()
          Called when all immediate and deferred upgrade actions have been performed *if* an upgrade was needed.
protected  java.util.List<UpgradeTask> getAllUpgradeTasks()
           
 java.util.Collection<UpgradeTaskInfo> 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.
protected  java.lang.String getConfiguredBuildNumber()
           
protected abstract  java.lang.String getDatabaseBuildNumber()
           
 java.util.List<UpgradeError> getErrors()
           
 java.lang.String getExportBuildNumber(boolean isSpaceExport)
          Tells the earliest version the exports will be compatible with.
 java.lang.String getOldestSpaceImportAllowed()
          Calculates the oldest build number from which a space can be imported.
 java.util.List<DeferredUpgradeTask> getPluginDependentUpgradeTasks()
           
 java.util.Map<java.lang.String,PluginExportCompatibility> getPluginExportCompatibility(boolean isSpaceExport)
          Returns the list of plugins with data (especially plugins with Active Objects data) and tells how backward-compatible they are.
 java.util.List<UpgradeTask> getPreSchemaUpgradeTasks()
           
protected abstract  java.lang.String getRealBuildNumber()
           
 java.util.List<UpgradeTask> getSchemaUpgradeTasks()
           
 java.util.List<UpgradeTask> getUpgradeTasks()
           
protected  java.util.List<UpgradeTask> getUpgradeTasksToRun()
           
protected  void 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.
 boolean isUpgraded()
           
 boolean needUpgrade()
           
protected  boolean permitDatabaseUpgrades()
          This is used to guard against database upgrades being performed multiple times on the same database.
protected  void postUpgrade()
           
protected abstract  java.util.List<UpgradeError> runUpgradePrerequisites()
          Runs all upgrade prerequisites.
protected  void runUpgradeTasks(java.util.List<UpgradeTask> upgradeTasks)
           
 void setApplicationConfig(com.atlassian.config.ApplicationConfiguration applicationConfig)
           
protected  void setConfiguredBuildNumber(java.lang.String buildNumber)
           
protected abstract  void setDatabaseBuildNumber(java.lang.String databaseBuildNumber)
          Once the upgrade is complete, we'll need to set the new database build number in the database.
 void setPluginAccessor(com.atlassian.plugin.PluginAccessor pluginAccessor)
           
 void setPluginDependentUpgradeTasks(java.util.List<DeferredUpgradeTask> upgradeTasks)
           
 void setPreSchemaUpgradeTasks(java.util.List<UpgradeTask> preSchemaUpgradeTasks)
           
 void setSchemaHelper(SchemaHelper schemaHelper)
           
 void setSchemaUpgradeTasks(java.util.List<UpgradeTask> upgradeTasks)
           
 void setUpgradeTasks(java.util.List<UpgradeTask> upgradeTasks)
           
 boolean taskNewerThan(java.lang.String buildNumber, UpgradeTask upgradeTask)
          Returns true if the build number for the task is greater than the passed build number.
 void upgrade(com.atlassian.johnson.JohnsonEventContainer agentJohnson)
           
protected  void upgradeStarted()
           
protected  void upgradeTaskSucceeded(UpgradeTask upgradeTask)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.confluence.upgrade.UpgradeManager
setDatabaseBuildNumber
 

Constructor Detail

AbstractUpgradeManager

public AbstractUpgradeManager()
Method Detail

setApplicationConfig

public void setApplicationConfig(com.atlassian.config.ApplicationConfiguration applicationConfig)

setSchemaHelper

public void setSchemaHelper(SchemaHelper schemaHelper)

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

upgrade

public void upgrade(com.atlassian.johnson.JohnsonEventContainer agentJohnson)
             throws UpgradeException
Specified by:
upgrade in interface UpgradeManager
Throws:
UpgradeException

runUpgradeTasks

protected void runUpgradeTasks(java.util.List<UpgradeTask> upgradeTasks)
                        throws UpgradeException
Throws:
UpgradeException

getAllUpgradeTasks

protected java.util.List<UpgradeTask> getAllUpgradeTasks()
Returns:
the complete list of upgrade tasks for checking space import/export compatibility, in the correct order.

getAllUpgradeTasksInfo

public java.util.Collection<UpgradeTaskInfo> 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:
getAllUpgradeTasksInfo in interface UpgradeTaskInfoService
Returns:
a Collection of UpgradeTaskInfo objects, one for each UpgradeTask in the system, in no particular order.

getUpgradeTasksToRun

protected java.util.List<UpgradeTask> 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

protected void upgradeTaskSucceeded(UpgradeTask upgradeTask)
                             throws java.lang.Exception
Throws:
java.lang.Exception

upgradeStarted

protected void upgradeStarted()

getPreSchemaUpgradeTasks

public java.util.List<UpgradeTask> getPreSchemaUpgradeTasks()

setPreSchemaUpgradeTasks

public void setPreSchemaUpgradeTasks(java.util.List<UpgradeTask> preSchemaUpgradeTasks)

setUpgradeTasks

public void setUpgradeTasks(java.util.List<UpgradeTask> upgradeTasks)

setPluginAccessor

public void setPluginAccessor(com.atlassian.plugin.PluginAccessor pluginAccessor)

getUpgradeTasks

public java.util.List<UpgradeTask> getUpgradeTasks()

setSchemaUpgradeTasks

public void setSchemaUpgradeTasks(java.util.List<UpgradeTask> upgradeTasks)

getSchemaUpgradeTasks

public java.util.List<UpgradeTask> getSchemaUpgradeTasks()

getErrors

public java.util.List<UpgradeError> getErrors()
Specified by:
getErrors in interface UpgradeManager

setPluginDependentUpgradeTasks

public void setPluginDependentUpgradeTasks(java.util.List<DeferredUpgradeTask> upgradeTasks)

getPluginDependentUpgradeTasks

public java.util.List<DeferredUpgradeTask> getPluginDependentUpgradeTasks()

runUpgradePrerequisites

protected abstract java.util.List<UpgradeError> 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

protected java.lang.String 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(java.lang.String buildNumber)
                                 throws com.atlassian.config.ConfigurationException
Throws:
com.atlassian.config.ConfigurationException

needUpgrade

public boolean needUpgrade()
Specified by:
needUpgrade in interface UpgradeManager

configuredBuildNumberNewerThan

public boolean configuredBuildNumberNewerThan(java.lang.String buildNumber)
Description copied from interface: UpgradeManager
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.

Specified by:
configuredBuildNumberNewerThan in interface UpgradeManager

taskNewerThan

public boolean taskNewerThan(java.lang.String buildNumber,
                             UpgradeTask upgradeTask)
Description copied from interface: UpgradeManager
Returns 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:
taskNewerThan in interface UpgradeManager

initialUpgradeFinished

protected void initialUpgradeFinished()
                               throws java.lang.Exception
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:
java.lang.Exception - when setting the database or configuration build number fails

entireUpgradeFinished

public void entireUpgradeFinished()
Description copied from interface: UpgradeManager
Called when all immediate and deferred upgrade actions have been performed *if* an upgrade was needed.

Specified by:
entireUpgradeFinished in interface UpgradeManager

getRealBuildNumber

protected abstract java.lang.String 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

protected abstract java.lang.String 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

protected abstract void setDatabaseBuildNumber(java.lang.String databaseBuildNumber)
                                        throws java.lang.Exception
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:
java.lang.Exception - when there is any problem setting the database build number

permitDatabaseUpgrades

protected boolean permitDatabaseUpgrades()
                                  throws UpgradeException
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

protected void beforeUpgrade()
                      throws UpgradeException
Throws:
UpgradeException

postUpgrade

protected void postUpgrade()

isUpgraded

public boolean isUpgraded()
Specified by:
isUpgraded in interface UpgradeManager
Returns:
true if the UpgradeManager was able to successfully upgrade this instance, or if no upgrade was necessary; otherwise false.

getOldestSpaceImportAllowed

public java.lang.String getOldestSpaceImportAllowed()
Description copied from interface: UpgradeManager
Calculates the oldest build number from which a space can be imported.

Specified by:
getOldestSpaceImportAllowed in interface UpgradeManager
Returns:
the build number

getExportBuildNumber

public java.lang.String getExportBuildNumber(boolean isSpaceExport)
Description copied from interface: UpgradeManager
Tells the earliest version the exports will be compatible with.

Specified by:
getExportBuildNumber in interface UpgradeManager
Parameters:
isSpaceExport - true if the export is about a space, false for a global export.
Returns:
a build number

getPluginExportCompatibility

public java.util.Map<java.lang.String,PluginExportCompatibility> getPluginExportCompatibility(boolean isSpaceExport)
Description copied from interface: UpgradeManager

Returns 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:
getPluginExportCompatibility in interface UpgradeManager
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.


Copyright © 2003-2014 Atlassian. All Rights Reserved.