mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fixed module startup bug
The ModuleComponent 'appliesFromVersion' and 'appliesToVersion' properties were being compared to the module's new version number. In actual fact, components' applicability must be against the original installation version number. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5561 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -6,6 +6,8 @@ module.msg.installing= Installing module ''{0}'' version {1}.
|
|||||||
module.msg.upgrading= Upgrading module ''{0}'' version {1} (was {2}).
|
module.msg.upgrading= Upgrading module ''{0}'' version {1} (was {2}).
|
||||||
module.msg.missing= A previously-installed module ''{0}'' (version {1}) is not present in your distribution.
|
module.msg.missing= A previously-installed module ''{0}'' (version {1}) is not present in your distribution.
|
||||||
|
|
||||||
|
module.warn.no_install_version=Module ''{0}'' had no install version. Assuming version {1} was installed.
|
||||||
|
|
||||||
module.err.downgrading_not_supported=\nDowngrading of modules is not supported.\nModule ''{0}'' version {1} is currently installed and must be uninstalled before version {2} can be installed.
|
module.err.downgrading_not_supported=\nDowngrading of modules is not supported.\nModule ''{0}'' version {1} is currently installed and must be uninstalled before version {2} can be installed.
|
||||||
module.err.unsupported_repo_version=\nModule ''{0}'' version {1} is incompatible with the current repository version {2}.\n The repository version required must be in range [{3} : {4}].
|
module.err.unsupported_repo_version=\nModule ''{0}'' version {1} is incompatible with the current repository version {2}.\n The repository version required must be in range [{3} : {4}].
|
||||||
module.err.already_executed=The module component has already been executed: {0}.{1}
|
module.err.already_executed=The module component has already been executed: {0}.{1}
|
||||||
|
@@ -71,6 +71,7 @@ public class ModuleComponentHelper
|
|||||||
private static final String MSG_STARTING = "module.msg.starting";
|
private static final String MSG_STARTING = "module.msg.starting";
|
||||||
private static final String MSG_INSTALLING = "module.msg.installing";
|
private static final String MSG_INSTALLING = "module.msg.installing";
|
||||||
private static final String MSG_UPGRADING = "module.msg.upgrading";
|
private static final String MSG_UPGRADING = "module.msg.upgrading";
|
||||||
|
private static final String WARN_NO_INSTALL_VERSION = "module.warn.no_install_version";
|
||||||
private static final String ERR_UNSUPPORTED_REPO_VERSION = "module.err.unsupported_repo_version";
|
private static final String ERR_UNSUPPORTED_REPO_VERSION = "module.err.unsupported_repo_version";
|
||||||
private static final String ERR_NO_DOWNGRADE = "module.err.downgrading_not_supported";
|
private static final String ERR_NO_DOWNGRADE = "module.err.downgrading_not_supported";
|
||||||
private static final String ERR_COMPONENT_ALREADY_REGISTERED = "module.err.component_already_registered";
|
private static final String ERR_COMPONENT_ALREADY_REGISTERED = "module.err.component_already_registered";
|
||||||
@@ -332,7 +333,7 @@ public class ModuleComponentHelper
|
|||||||
private void startModule(ModuleDetails module, Set<ModuleComponent> executedComponents)
|
private void startModule(ModuleDetails module, Set<ModuleComponent> executedComponents)
|
||||||
{
|
{
|
||||||
String moduleId = module.getId();
|
String moduleId = module.getId();
|
||||||
VersionNumber moduleVersion = module.getVersion();
|
VersionNumber moduleNewVersion = module.getVersion();
|
||||||
|
|
||||||
// Check if the module needs a rename first
|
// Check if the module needs a rename first
|
||||||
renameModule(module);
|
renameModule(module);
|
||||||
@@ -347,7 +348,7 @@ public class ModuleComponentHelper
|
|||||||
// The current repo version is not supported
|
// The current repo version is not supported
|
||||||
throw AlfrescoRuntimeException.create(
|
throw AlfrescoRuntimeException.create(
|
||||||
ERR_UNSUPPORTED_REPO_VERSION,
|
ERR_UNSUPPORTED_REPO_VERSION,
|
||||||
moduleId, moduleVersion, repoVersionNumber, minRepoVersionNumber, maxRepoVersionNumber);
|
moduleId, moduleNewVersion, repoVersionNumber, minRepoVersionNumber, maxRepoVersionNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the module details from the registry
|
// Get the module details from the registry
|
||||||
@@ -357,37 +358,50 @@ public class ModuleComponentHelper
|
|||||||
RegistryKey moduleKeyCurrentVersion = new RegistryKey(
|
RegistryKey moduleKeyCurrentVersion = new RegistryKey(
|
||||||
ModuleComponentHelper.URI_MODULES_1_0,
|
ModuleComponentHelper.URI_MODULES_1_0,
|
||||||
REGISTRY_PATH_MODULES, moduleId, REGISTRY_PROPERTY_CURRENT_VERSION);
|
REGISTRY_PATH_MODULES, moduleId, REGISTRY_PROPERTY_CURRENT_VERSION);
|
||||||
VersionNumber versionCurrent = (VersionNumber) registryService.getProperty(moduleKeyCurrentVersion);
|
VersionNumber moduleInstallVersion = (VersionNumber) registryService.getProperty(moduleKeyInstalledVersion);
|
||||||
|
VersionNumber moduleCurrentVersion = (VersionNumber) registryService.getProperty(moduleKeyCurrentVersion);
|
||||||
String msg = null;
|
String msg = null;
|
||||||
if (versionCurrent == null) // There is no current version
|
if (moduleCurrentVersion == null) // No previous record of it
|
||||||
{
|
{
|
||||||
msg = I18NUtil.getMessage(MSG_INSTALLING, moduleId, moduleVersion);
|
msg = I18NUtil.getMessage(MSG_INSTALLING, moduleId, moduleNewVersion);
|
||||||
// Record the install version
|
// Record the install version
|
||||||
registryService.addProperty(moduleKeyInstalledVersion, moduleVersion);
|
registryService.addProperty(moduleKeyInstalledVersion, moduleNewVersion);
|
||||||
|
moduleInstallVersion = moduleNewVersion;
|
||||||
|
moduleCurrentVersion = moduleNewVersion;
|
||||||
}
|
}
|
||||||
else // It is an upgrade or is the same
|
else // It is an upgrade or is the same
|
||||||
{
|
{
|
||||||
if (versionCurrent.compareTo(moduleVersion) == 0) // The current version is the same
|
// Check that we have an installed version
|
||||||
|
if (moduleInstallVersion == null)
|
||||||
{
|
{
|
||||||
msg = I18NUtil.getMessage(MSG_STARTING, moduleId, moduleVersion);
|
// A current version, but no installed version
|
||||||
|
logger.warn(I18NUtil.getMessage(WARN_NO_INSTALL_VERSION, moduleId, moduleCurrentVersion));
|
||||||
|
// Record the install version
|
||||||
|
registryService.addProperty(moduleKeyInstalledVersion, moduleCurrentVersion);
|
||||||
|
moduleInstallVersion = moduleCurrentVersion;
|
||||||
}
|
}
|
||||||
else if (versionCurrent.compareTo(moduleVersion) > 0) // Downgrading not supported
|
|
||||||
|
if (moduleCurrentVersion.compareTo(moduleNewVersion) == 0) // The current version is the same
|
||||||
{
|
{
|
||||||
throw AlfrescoRuntimeException.create(ERR_NO_DOWNGRADE, moduleId, versionCurrent, moduleVersion);
|
msg = I18NUtil.getMessage(MSG_STARTING, moduleId, moduleNewVersion);
|
||||||
|
}
|
||||||
|
else if (moduleCurrentVersion.compareTo(moduleNewVersion) > 0) // Downgrading not supported
|
||||||
|
{
|
||||||
|
throw AlfrescoRuntimeException.create(ERR_NO_DOWNGRADE, moduleId, moduleCurrentVersion, moduleNewVersion);
|
||||||
}
|
}
|
||||||
else // This is an upgrade
|
else // This is an upgrade
|
||||||
{
|
{
|
||||||
msg = I18NUtil.getMessage(MSG_UPGRADING, moduleId, moduleVersion, versionCurrent);
|
msg = I18NUtil.getMessage(MSG_UPGRADING, moduleId, moduleNewVersion, moduleCurrentVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loggerService.info(msg);
|
loggerService.info(msg);
|
||||||
// Record the current version
|
// Record the current version
|
||||||
registryService.addProperty(moduleKeyCurrentVersion, moduleVersion);
|
registryService.addProperty(moduleKeyCurrentVersion, moduleNewVersion);
|
||||||
|
|
||||||
Map<String, ModuleComponent> componentsByName = getComponents(moduleId);
|
Map<String, ModuleComponent> componentsByName = getComponents(moduleId);
|
||||||
for (ModuleComponent component : componentsByName.values())
|
for (ModuleComponent component : componentsByName.values())
|
||||||
{
|
{
|
||||||
executeComponent(module, component, executedComponents);
|
executeComponent(moduleId, moduleInstallVersion, component, executedComponents);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
@@ -400,7 +414,11 @@ public class ModuleComponentHelper
|
|||||||
/**
|
/**
|
||||||
* Execute the component, respecting dependencies.
|
* Execute the component, respecting dependencies.
|
||||||
*/
|
*/
|
||||||
private void executeComponent(ModuleDetails module, ModuleComponent component, Set<ModuleComponent> executedComponents)
|
private void executeComponent(
|
||||||
|
String moduleId,
|
||||||
|
VersionNumber moduleInstallVersion,
|
||||||
|
ModuleComponent component,
|
||||||
|
Set<ModuleComponent> executedComponents)
|
||||||
{
|
{
|
||||||
// Ignore if it has been executed in this run already
|
// Ignore if it has been executed in this run already
|
||||||
if (executedComponents.contains(component))
|
if (executedComponents.contains(component))
|
||||||
@@ -415,18 +433,17 @@ public class ModuleComponentHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check the version applicability
|
// Check the version applicability
|
||||||
VersionNumber moduleVersion = module.getVersion();
|
|
||||||
VersionNumber minVersion = component.getAppliesFromVersionNumber();
|
VersionNumber minVersion = component.getAppliesFromVersionNumber();
|
||||||
VersionNumber maxVersion = component.getAppliesToVersionNumber();
|
VersionNumber maxVersion = component.getAppliesToVersionNumber();
|
||||||
if (moduleVersion.compareTo(minVersion) < 0 || moduleVersion.compareTo(maxVersion) > 0)
|
if (moduleInstallVersion.compareTo(minVersion) < 0 || moduleInstallVersion.compareTo(maxVersion) > 0)
|
||||||
{
|
{
|
||||||
// It is out of the allowable range for execution so we just ignore it
|
// It is out of the allowable range for execution so we just ignore it
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("Skipping component that doesn't apply to the current version: \n" +
|
logger.debug("Skipping component that doesn't apply to the module installation version: \n" +
|
||||||
" Component: " + component + "\n" +
|
" Component: " + component + "\n" +
|
||||||
" Module: " + module + "\n" +
|
" Module: " + moduleId + "\n" +
|
||||||
" Version: " + moduleVersion + "\n" +
|
" Install Version: " + moduleInstallVersion + "\n" +
|
||||||
" Applies From : " + minVersion + "\n" +
|
" Applies From : " + minVersion + "\n" +
|
||||||
" Applies To : " + maxVersion);
|
" Applies To : " + maxVersion);
|
||||||
}
|
}
|
||||||
@@ -434,7 +451,6 @@ public class ModuleComponentHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Construct the registry key to store the execution date
|
// Construct the registry key to store the execution date
|
||||||
String moduleId = component.getModuleId();
|
|
||||||
String name = component.getName();
|
String name = component.getName();
|
||||||
RegistryKey executionDateKey = new RegistryKey(
|
RegistryKey executionDateKey = new RegistryKey(
|
||||||
ModuleComponentHelper.URI_MODULES_1_0,
|
ModuleComponentHelper.URI_MODULES_1_0,
|
||||||
@@ -458,7 +474,7 @@ public class ModuleComponentHelper
|
|||||||
List<ModuleComponent> dependencies = component.getDependsOn();
|
List<ModuleComponent> dependencies = component.getDependsOn();
|
||||||
for (ModuleComponent dependency : dependencies)
|
for (ModuleComponent dependency : dependencies)
|
||||||
{
|
{
|
||||||
executeComponent(module, dependency, executedComponents);
|
executeComponent(moduleId, moduleInstallVersion, dependency, executedComponents);
|
||||||
}
|
}
|
||||||
// Execute the component itself
|
// Execute the component itself
|
||||||
component.execute();
|
component.execute();
|
||||||
|
@@ -65,8 +65,8 @@ public class ModuleDetailsImpl implements ModuleDetails
|
|||||||
private ModuleDetailsImpl()
|
private ModuleDetailsImpl()
|
||||||
{
|
{
|
||||||
aliases = new ArrayList<String>(0);
|
aliases = new ArrayList<String>(0);
|
||||||
repoVersionMin = new VersionNumber("0.0.0");
|
repoVersionMin = VersionNumber.VERSION_ZERO;
|
||||||
repoVersionMax = new VersionNumber("999.999.999");
|
repoVersionMax = VersionNumber.VERSION_BIG;
|
||||||
this.installState = ModuleInstallState.UNKNOWN;
|
this.installState = ModuleInstallState.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user