com.atlassian.jira.upgrade
Class UpgradeManagerImpl

java.lang.Object
  extended bycom.atlassian.jira.upgrade.UpgradeManagerImpl
All Implemented Interfaces:
UpgradeManager

public class UpgradeManagerImpl
extends java.lang.Object
implements UpgradeManager


Constructor Summary
  UpgradeManagerImpl()
          This constructor adds all the upgrade tasks to the relevant Maps
protected UpgradeManagerImpl(java.util.Collection professionalUpgrades, java.util.Collection enterpriseUpgrades)
          For testing purposes only.
  UpgradeManagerImpl(java.lang.String professionalFileName, java.lang.String enterpriseFileName)
           
 
Method Summary
 void addToUpgradeHistory(java.lang.Class upgradeClass)
           
 java.util.Collection doProfessionalToEnterpriseUpgrade()
          Performs all enterprise upgrade tasks plus any professional upgrade tasks that need to be run from the build number stored in the database to the current build number.
 java.util.Collection doSetupUpgrade()
          Performs any upgrades that may be needed as a resulty of the Setup procedure of JIRA
protected  java.util.Collection doUpgradeIfNeeded(java.lang.String defaultBackupPath)
           
 java.util.Collection doUpgradeIfNeededAndAllowed(java.lang.String backupPath)
          Performs the upgarde if one is required and the license is not too old to proceed with the upgrade.
 java.util.SortedMap getAllEnterpriseUpgrades()
           
 java.util.SortedMap getAllProfessionalUpgrades()
           
 java.lang.String getExportFilePath()
           
 java.lang.String getJiraBuildNumber()
          Get the current build number from the database.
 java.util.SortedMap getRelevantUpgradesFromList(java.util.Map upgradeMap)
          For each upgrade in the upgradeMap, test whether it is needed (ie upgrade version is greater than the version in the database), and then add to set.
 java.util.SortedMap getSetupEnterpriseUpgrades()
           
 java.util.SortedMap getSetupProfessionalUpgrades()
           
 boolean needUpgrade()
          Returns true if the current build number is not equal to the build number in the database.
 void printErrors(java.util.Collection errors)
          Print errors to log4j at error level
static void setJiraBuildNumber(java.lang.String version)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UpgradeManagerImpl

protected UpgradeManagerImpl(java.util.Collection professionalUpgrades,
                             java.util.Collection enterpriseUpgrades)
For testing purposes only.

Parameters:
professionalUpgrades - A collection containing all the professional upgrades that are needed to be run.

UpgradeManagerImpl

public UpgradeManagerImpl(java.lang.String professionalFileName,
                          java.lang.String enterpriseFileName)

UpgradeManagerImpl

public UpgradeManagerImpl()
This constructor adds all the upgrade tasks to the relevant Maps

Method Detail

needUpgrade

public boolean needUpgrade()
Returns true if the current build number is not equal to the build number in the database. NB - There may not be any upgrades to run. However, you will need to run doUpgrade() to increment the build number in the database.

Specified by:
needUpgrade in interface UpgradeManager

doUpgradeIfNeededAndAllowed

public java.util.Collection doUpgradeIfNeededAndAllowed(java.lang.String backupPath)
                                                 throws IllegalXMLCharactersException
Performs the upgarde if one is required and the license is not too old to proceed with the upgrade.

Specified by:
doUpgradeIfNeededAndAllowed in interface UpgradeManager
Parameters:
backupPath - - a path to the defulat location of the export
Returns:
a list of errors that occurred during the upgrade
Throws:
IllegalXMLCharactersException

doUpgradeIfNeeded

protected java.util.Collection doUpgradeIfNeeded(java.lang.String defaultBackupPath)
                                          throws IllegalXMLCharactersException
Throws:
IllegalXMLCharactersException

printErrors

public void printErrors(java.util.Collection errors)
Print errors to log4j at error level

Specified by:
printErrors in interface UpgradeManager
Parameters:
errors - A collection of strings, describing all the errors that occurred.

doProfessionalToEnterpriseUpgrade

public java.util.Collection doProfessionalToEnterpriseUpgrade()
Performs all enterprise upgrade tasks plus any professional upgrade tasks that need to be run from the build number stored in the database to the current build number.

Get the Map of relevant upgrades for the professional version using getRelevantUpgradesFromList(java.util.Map)

Get the sortedset of upgradeNumbers which are to be performed for this upgrade. Add to this set ALL the enterprise upgrade numbers

Iterate over these numbers and if either of the professional or enterprise maps contains an upgradetask with this number then do the upgrade

If errors are found, it will cancel the upgrade, and return the list of errors.

For each upgrade that happens successfully, if the build number of the upgrade is greater than the build number stored in the database, the build number in the database will be set to the build number of the successfully completed upgrade, so that if one fails, you do not have to repeat all the upgrades that have already run.

If there are no errors from the entire upgrade, the build number in the database is incremented to the current build number. This is because there may be no upgrades for a particular version & needUpgrade() checks build no in database.

Specified by:
doProfessionalToEnterpriseUpgrade in interface UpgradeManager

doSetupUpgrade

public java.util.Collection doSetupUpgrade()
Performs any upgrades that may be needed as a resulty of the Setup procedure of JIRA

Get the set of setupUpgradeNumbers which are to be performed for this setup.

Iterate over these numbers and if either of the professional or enterprise upgrade maps contains an upgradetask with this number then do the upgrade

If errors are found, it will cancel the upgrade, and return the list of errors.

For each upgrade that happens successfully, it will increment the build number in the database, so that if one fails, you do not have to repeat all the upgrades that have already run.

If there are no errors from the upgrade, the build number in the database is incremented to the current build number. This is because there may be no upgrades for a particular version & needUpgrade() checks build no in database.

Specified by:
doSetupUpgrade in interface UpgradeManager

getRelevantUpgradesFromList

public java.util.SortedMap getRelevantUpgradesFromList(java.util.Map upgradeMap)
For each upgrade in the upgradeMap, test whether it is needed (ie upgrade version is greater than the version in the database), and then add to set.

Specified by:
getRelevantUpgradesFromList in interface UpgradeManager
Returns:
set of UpgradeTasks that need to be run.

getJiraBuildNumber

public java.lang.String getJiraBuildNumber()
Get the current build number from the database. This represents the level that this application is patched to. This may be different to the current version if there are patches waiting to be applied.

Specified by:
getJiraBuildNumber in interface UpgradeManager
Returns:
The version information from the database

setJiraBuildNumber

public static void setJiraBuildNumber(java.lang.String version)

addToUpgradeHistory

public void addToUpgradeHistory(java.lang.Class upgradeClass)
                         throws GenericEntityException
Throws:
GenericEntityException

getAllEnterpriseUpgrades

public java.util.SortedMap getAllEnterpriseUpgrades()
Specified by:
getAllEnterpriseUpgrades in interface UpgradeManager

getAllProfessionalUpgrades

public java.util.SortedMap getAllProfessionalUpgrades()
Specified by:
getAllProfessionalUpgrades in interface UpgradeManager

getSetupEnterpriseUpgrades

public java.util.SortedMap getSetupEnterpriseUpgrades()
Specified by:
getSetupEnterpriseUpgrades in interface UpgradeManager

getSetupProfessionalUpgrades

public java.util.SortedMap getSetupProfessionalUpgrades()
Specified by:
getSetupProfessionalUpgrades in interface UpgradeManager

getExportFilePath

public java.lang.String getExportFilePath()
Specified by:
getExportFilePath in interface UpgradeManager