From 2bc9c284e78c91694a48910399fca90b2a0fbf32 Mon Sep 17 00:00:00 2001 From: Sara Aspery Date: Fri, 5 Jan 2018 11:41:19 +0000 Subject: [PATCH 1/7] RM-5927 Add appliesToVersion to v20 v21 patches --- .../org_alfresco_module_rm/patch/rm-patch-v20-context.xml | 4 ++++ .../org_alfresco_module_rm/patch/rm-patch-v21-context.xml | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v20-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v20-context.xml index 985a809082..c300750bd5 100755 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v20-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v20-context.xml @@ -13,6 +13,7 @@ + @@ -28,6 +29,7 @@ + @@ -41,6 +43,7 @@ + @@ -58,6 +61,7 @@ + diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml index aa0a740c59..23c5db6ace 100755 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml @@ -13,6 +13,7 @@ + @@ -31,6 +32,7 @@ + @@ -47,6 +49,7 @@ + @@ -60,6 +63,7 @@ + @@ -75,6 +79,7 @@ + @@ -88,6 +93,7 @@ + @@ -100,6 +106,7 @@ + From 97f7ca3b64749ae02c200e484bfc040480723c47 Mon Sep 17 00:00:00 2001 From: Sara Aspery Date: Thu, 11 Jan 2018 14:56:34 +0000 Subject: [PATCH 2/7] RM-5927 Fix appliesToVersion to 2.x.999 --- .../patch/rm-patch-v21-context.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml index 23c5db6ace..b4ca30fbc1 100755 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml @@ -13,7 +13,7 @@ - + @@ -32,7 +32,7 @@ - + @@ -49,7 +49,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -79,7 +79,7 @@ - + @@ -93,7 +93,7 @@ - + @@ -106,7 +106,7 @@ - + From f7e0c28eb508711ab7ccdb66ef8ef99b22fcba07 Mon Sep 17 00:00:00 2001 From: Sara Aspery Date: Thu, 11 Jan 2018 14:57:33 +0000 Subject: [PATCH 3/7] RM-5927 Fix appliesToVersion to 2.0.999 --- .../org_alfresco_module_rm/patch/rm-patch-v20-context.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v20-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v20-context.xml index c300750bd5..f185ab5b08 100755 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v20-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v20-context.xml @@ -13,7 +13,7 @@ - + @@ -29,7 +29,7 @@ - + @@ -43,7 +43,7 @@ - + @@ -61,7 +61,7 @@ - + From f9a08391e927e26a0af442526b568d9e4acc9362 Mon Sep 17 00:00:00 2001 From: Sara Aspery Date: Sat, 13 Jan 2018 01:01:54 +0000 Subject: [PATCH 4/7] RM-5927 Fix v21 appliesFromVersion to 2.0 --- .../patch/rm-patch-v21-context.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml index b4ca30fbc1..e1ba23b776 100755 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml @@ -12,7 +12,7 @@ - + @@ -31,7 +31,7 @@ - + @@ -48,7 +48,7 @@ - + @@ -62,7 +62,7 @@ - + @@ -78,7 +78,7 @@ - + @@ -92,7 +92,7 @@ - + @@ -105,7 +105,7 @@ - + From a196d2b8c3d15f9f966d076f7a4e163cc0d4f99d Mon Sep 17 00:00:00 2001 From: Sara Aspery Date: Wed, 17 Jan 2018 06:47:24 +0000 Subject: [PATCH 5/7] RM-5927 Check version nbrs and remove appliesTo --- .../patch/rm-patch-context.xml | 1 + .../patch/rm-patch-v20-context.xml | 4 -- .../patch/rm-patch-v21-context.xml | 21 ++++------ .../compatibility/ModulePatchComponent.java | 41 +++++++++++++++++++ 4 files changed, 49 insertions(+), 18 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-context.xml index 7ca1fc7bab..6d4c60152e 100755 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-context.xml @@ -46,6 +46,7 @@ + \ No newline at end of file diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v20-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v20-context.xml index f185ab5b08..985a809082 100755 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v20-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v20-context.xml @@ -13,7 +13,6 @@ - @@ -29,7 +28,6 @@ - @@ -43,7 +41,6 @@ - @@ -61,7 +58,6 @@ - diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml index e1ba23b776..aa0a740c59 100755 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/patch/rm-patch-v21-context.xml @@ -12,8 +12,7 @@ - - + @@ -31,8 +30,7 @@ - - + @@ -48,8 +46,7 @@ - - + @@ -62,8 +59,7 @@ - - + @@ -78,8 +74,7 @@ - - + @@ -92,8 +87,7 @@ - - + @@ -105,8 +99,7 @@ - - + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/compatibility/ModulePatchComponent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/compatibility/ModulePatchComponent.java index 7b4a54abf4..89809db25c 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/compatibility/ModulePatchComponent.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/compatibility/ModulePatchComponent.java @@ -27,10 +27,17 @@ package org.alfresco.module.org_alfresco_module_rm.patch.compatibility; +import java.io.Serializable; + import org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchExecuterImpl; +import org.alfresco.repo.admin.registry.RegistryKey; +import org.alfresco.repo.admin.registry.RegistryService; import org.alfresco.repo.module.AbstractModuleComponent; +import org.alfresco.repo.module.ModuleComponentHelper; +import org.alfresco.repo.module.ModuleVersionNumber; import org.alfresco.repo.policy.BehaviourFilter; import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.service.cmr.module.ModuleDetails; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -44,6 +51,10 @@ import org.apache.commons.logging.LogFactory; @Deprecated public abstract class ModulePatchComponent extends AbstractModuleComponent { + private static final String REGISTRY_PATH_MODULES = "modules"; + private static final String REGISTRY_PROPERTY_INSTALLED_VERSION = "installedVersion"; + private static final String REGISTRY_PROPERTY_CURRENT_VERSION = "currentVersion"; + /** logger */ protected static final Log LOGGER = LogFactory.getLog(ModulePatchComponent.class); @@ -80,6 +91,14 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent this.modulePatchExecuter = modulePatchExecuter; } + /** + * @param registryService Registry service + */ + protected RegistryService registryService; + public void setRegistryService(RegistryService registryService) { + this.registryService = registryService; + } + /** * Init method */ @@ -96,6 +115,28 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent @Override protected void executeInternal() { + String moduleId = modulePatchExecuter.getModuleId(); + + RegistryKey moduleKeyInstalledVersion = new RegistryKey(ModuleComponentHelper.URI_MODULES_1_0, + new String[]{REGISTRY_PATH_MODULES, moduleId, REGISTRY_PROPERTY_INSTALLED_VERSION}); + Serializable moduleInstalledVersion = this.registryService.getProperty(moduleKeyInstalledVersion); + ModuleVersionNumber moduleInstalledVersionNumber = new ModuleVersionNumber(moduleInstalledVersion.toString()); + + RegistryKey moduleKeyCurrentVersion = new RegistryKey(ModuleComponentHelper.URI_MODULES_1_0, + new String[]{REGISTRY_PATH_MODULES, moduleId, REGISTRY_PROPERTY_CURRENT_VERSION}); + Serializable moduleCurrentVersion = this.registryService.getProperty(moduleKeyCurrentVersion); + ModuleVersionNumber moduleCurrentVersionNumber = new ModuleVersionNumber(moduleInstalledVersion.toString()); + + ModuleDetails moduleDetails = moduleService.getModule(moduleId); + ModuleVersionNumber moduleNewVersion = moduleDetails.getModuleVersionNumber(); + + LOGGER.debug("******************************************************************"); + LOGGER.debug(" moduleCurrentVersion : " + moduleCurrentVersion.toString()); + LOGGER.debug(" versionNumber: " + moduleCurrentVersionNumber.toString()); + LOGGER.debug(" moduleInstalledVersion: " + moduleInstalledVersion.toString()); + LOGGER.debug(" versionNumber: " + moduleInstalledVersionNumber.toString()); + LOGGER.debug(" moduleNewVersionNumber: " + moduleNewVersion.toString()); + try { if (LOGGER.isInfoEnabled()) From 2d075e14d1c89ee1788ea22ce5e249b3166eac97 Mon Sep 17 00:00:00 2001 From: Sara Aspery Date: Thu, 18 Jan 2018 02:58:38 +0000 Subject: [PATCH 6/7] RM-5927 Check installed vs current version --- .../compatibility/ModulePatchComponent.java | 116 ++++++++++-------- 1 file changed, 64 insertions(+), 52 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/compatibility/ModulePatchComponent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/compatibility/ModulePatchComponent.java index 89809db25c..2530389ff3 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/compatibility/ModulePatchComponent.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/compatibility/ModulePatchComponent.java @@ -37,7 +37,6 @@ import org.alfresco.repo.module.ModuleComponentHelper; import org.alfresco.repo.module.ModuleVersionNumber; import org.alfresco.repo.policy.BehaviourFilter; import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.service.cmr.module.ModuleDetails; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -67,6 +66,9 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent /** module patch executer */ protected ModulePatchExecuterImpl modulePatchExecuter; + /** Registry service */ + protected RegistryService registryService; + /** * @param retryingTransactionHelper retrying transaction helper */ @@ -94,7 +96,6 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent /** * @param registryService Registry service */ - protected RegistryService registryService; public void setRegistryService(RegistryService registryService) { this.registryService = registryService; } @@ -115,69 +116,80 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent @Override protected void executeInternal() { - String moduleId = modulePatchExecuter.getModuleId(); + ModuleVersionNumber moduleInstalledVersionNumber = getModuleVersionNumber(REGISTRY_PROPERTY_INSTALLED_VERSION); + ModuleVersionNumber moduleCurrentVersionNumber = getModuleVersionNumber(REGISTRY_PROPERTY_CURRENT_VERSION); - RegistryKey moduleKeyInstalledVersion = new RegistryKey(ModuleComponentHelper.URI_MODULES_1_0, - new String[]{REGISTRY_PATH_MODULES, moduleId, REGISTRY_PROPERTY_INSTALLED_VERSION}); - Serializable moduleInstalledVersion = this.registryService.getProperty(moduleKeyInstalledVersion); - ModuleVersionNumber moduleInstalledVersionNumber = new ModuleVersionNumber(moduleInstalledVersion.toString()); - - RegistryKey moduleKeyCurrentVersion = new RegistryKey(ModuleComponentHelper.URI_MODULES_1_0, - new String[]{REGISTRY_PATH_MODULES, moduleId, REGISTRY_PROPERTY_CURRENT_VERSION}); - Serializable moduleCurrentVersion = this.registryService.getProperty(moduleKeyCurrentVersion); - ModuleVersionNumber moduleCurrentVersionNumber = new ModuleVersionNumber(moduleInstalledVersion.toString()); - - ModuleDetails moduleDetails = moduleService.getModule(moduleId); - ModuleVersionNumber moduleNewVersion = moduleDetails.getModuleVersionNumber(); - - LOGGER.debug("******************************************************************"); - LOGGER.debug(" moduleCurrentVersion : " + moduleCurrentVersion.toString()); - LOGGER.debug(" versionNumber: " + moduleCurrentVersionNumber.toString()); - LOGGER.debug(" moduleInstalledVersion: " + moduleInstalledVersion.toString()); - LOGGER.debug(" versionNumber: " + moduleInstalledVersionNumber.toString()); - LOGGER.debug(" moduleNewVersionNumber: " + moduleNewVersion.toString()); - - try + if (isUpgradeFromVersionThatIncludesEarlyPatch(moduleInstalledVersionNumber, moduleCurrentVersionNumber)) { if (LOGGER.isInfoEnabled()) { - LOGGER.info("Module patch component '" + getName() + "' is executing ..."); + LOGGER.info("Module patch component '" + getName() + "' is skipped for upgrade" + + " from version " + moduleInstalledVersionNumber.toString() + + " to version " + moduleCurrentVersionNumber.toString()); } - - // execute path within an isolated transaction - retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + } else + { + try { - @Override - public Void execute() + if (LOGGER.isInfoEnabled()) { - behaviourFilter.disableBehaviour(); - try - { - executePatch(); - } - finally - { - behaviourFilter.enableBehaviour(); - } - return null; + LOGGER.info("Module patch component '" + getName() + "' is executing ..."); } - }, false, true); + // execute path within an isolated transaction + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + @Override + public Void execute() + { + behaviourFilter.disableBehaviour(); + try + { + executePatch(); + } finally + { + behaviourFilter.enableBehaviour(); + } + return null; + } - if (LOGGER.isInfoEnabled()) + }, false, true); + + if (LOGGER.isInfoEnabled()) + { + LOGGER.info(" ... completed module patch '" + getName() + "'"); + } + } catch (Exception exception) { - LOGGER.info(" ... completed module patch '" + getName() + "'"); + // record the exception otherwise it gets swallowed + if (LOGGER.isInfoEnabled()) + { + LOGGER.info(" ... error encountered. " + exception.getMessage(), exception); + } + throw exception; } } - catch (Exception exception) - { - // record the exception otherwise it gets swallowed - if (LOGGER.isInfoEnabled()) - { - LOGGER.info(" ... error encountered. " + exception.getMessage(), exception); - } - throw exception; - } + } + + /** + * Helper method to get the ModuleVersionNumber. + */ + private ModuleVersionNumber getModuleVersionNumber(String registryProperty) + { + String moduleId = modulePatchExecuter.getModuleId(); + RegistryKey moduleKeyVersion = new RegistryKey(ModuleComponentHelper.URI_MODULES_1_0, + new String[]{REGISTRY_PATH_MODULES, moduleId, registryProperty}); + Serializable moduleVersion = this.registryService.getProperty(moduleKeyVersion); + + return new ModuleVersionNumber(moduleVersion.toString()); + } + + private boolean isUpgradeFromVersionThatIncludesEarlyPatch(ModuleVersionNumber installedModuleVersionNumber, + ModuleVersionNumber currentModuleVersionNumber) + { + ModuleVersionNumber minVersion = this.getAppliesFromVersionNumber(); + return installedModuleVersionNumber.compareTo(minVersion) >= 0 && + installedModuleVersionNumber.compareTo(currentModuleVersionNumber) != 0; } /** From d691d343d66dd0f3dea8526ce0277eb95bf9b984 Mon Sep 17 00:00:00 2001 From: Sara Aspery Date: Thu, 18 Jan 2018 11:41:02 +0000 Subject: [PATCH 7/7] RM-5927 Changes from review --- .../compatibility/ModulePatchComponent.java | 72 +++++++++++-------- 1 file changed, 41 insertions(+), 31 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/compatibility/ModulePatchComponent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/compatibility/ModulePatchComponent.java index 2530389ff3..92524b0bf2 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/compatibility/ModulePatchComponent.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/compatibility/ModulePatchComponent.java @@ -37,8 +37,8 @@ import org.alfresco.repo.module.ModuleComponentHelper; import org.alfresco.repo.module.ModuleVersionNumber; import org.alfresco.repo.policy.BehaviourFilter; import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -55,7 +55,7 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent private static final String REGISTRY_PROPERTY_CURRENT_VERSION = "currentVersion"; /** logger */ - protected static final Log LOGGER = LogFactory.getLog(ModulePatchComponent.class); + protected static final Logger LOGGER = LoggerFactory.getLogger(ModulePatchComponent.class); /** Retrying transaction helper */ protected RetryingTransactionHelper retryingTransactionHelper; @@ -96,7 +96,8 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent /** * @param registryService Registry service */ - public void setRegistryService(RegistryService registryService) { + public void setRegistryService(RegistryService registryService) + { this.registryService = registryService; } @@ -118,23 +119,19 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent { ModuleVersionNumber moduleInstalledVersionNumber = getModuleVersionNumber(REGISTRY_PROPERTY_INSTALLED_VERSION); ModuleVersionNumber moduleCurrentVersionNumber = getModuleVersionNumber(REGISTRY_PROPERTY_CURRENT_VERSION); + + String moduleName = getName(); - if (isUpgradeFromVersionThatIncludesEarlyPatch(moduleInstalledVersionNumber, moduleCurrentVersionNumber)) + if (isVersionLaterThan(moduleInstalledVersionNumber, moduleCurrentVersionNumber)) { - if (LOGGER.isInfoEnabled()) - { - LOGGER.info("Module patch component '" + getName() + "' is skipped for upgrade" + - " from version " + moduleInstalledVersionNumber.toString() + - " to version " + moduleCurrentVersionNumber.toString()); - } - } else + LOGGER.info("Module patch component '{}' is skipped for upgrade from version {} to version {}", + moduleName, moduleInstalledVersionNumber, moduleCurrentVersionNumber); + } + else { try { - if (LOGGER.isInfoEnabled()) - { - LOGGER.info("Module patch component '" + getName() + "' is executing ..."); - } + LOGGER.info("Module patch component '{}' is executing ...", moduleName); // execute path within an isolated transaction retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() @@ -146,7 +143,8 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent try { executePatch(); - } finally + } + finally { behaviourFilter.enableBehaviour(); } @@ -155,17 +153,12 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent }, false, true); - if (LOGGER.isInfoEnabled()) - { - LOGGER.info(" ... completed module patch '" + getName() + "'"); - } + LOGGER.info(" ... completed module patch '{}'", moduleName); + } catch (Exception exception) { // record the exception otherwise it gets swallowed - if (LOGGER.isInfoEnabled()) - { - LOGGER.info(" ... error encountered. " + exception.getMessage(), exception); - } + LOGGER.info(" ... error encountered. {}", exception.getMessage(), exception); throw exception; } } @@ -183,13 +176,30 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent return new ModuleVersionNumber(moduleVersion.toString()); } - - private boolean isUpgradeFromVersionThatIncludesEarlyPatch(ModuleVersionNumber installedModuleVersionNumber, - ModuleVersionNumber currentModuleVersionNumber) + + /** + * Helper method to determine if this is an upgrade from a version that already includes the early (v2.0, v2.1) + * patches. + * + */ + private boolean isVersionLaterThan(ModuleVersionNumber installedModuleVersionNumber, + ModuleVersionNumber currentModuleVersionNumber) { - ModuleVersionNumber minVersion = this.getAppliesFromVersionNumber(); - return installedModuleVersionNumber.compareTo(minVersion) >= 0 && - installedModuleVersionNumber.compareTo(currentModuleVersionNumber) != 0; + // assume that the v2.0 and v2.1 patches should be run + boolean versionLaterThan = false; + + // if this is an upgrade as opposed to a fresh install + if (installedModuleVersionNumber.compareTo(currentModuleVersionNumber) != 0) + { + // if the installed version is later than the minimum version number of this patch + ModuleVersionNumber minVersion = this.getAppliesFromVersionNumber(); + if (installedModuleVersionNumber.compareTo(minVersion) >= 0) + { + versionLaterThan = true; + } + } + + return versionLaterThan; } /**