diff --git a/source/java/org/alfresco/repo/module/ModuleDetailsImpl.java b/source/java/org/alfresco/repo/module/ModuleDetailsImpl.java index b333ebc671..bf862b72d9 100644 --- a/source/java/org/alfresco/repo/module/ModuleDetailsImpl.java +++ b/source/java/org/alfresco/repo/module/ModuleDetailsImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2015 Alfresco Software Limited. * * This file is part of Alfresco * @@ -32,6 +32,7 @@ import org.alfresco.service.cmr.module.ModuleInstallState; import org.springframework.extensions.surf.util.ISO8601DateFormat; import org.alfresco.util.Pair; import org.alfresco.util.VersionNumber; +import org.alfresco.repo.module.tool.LogOutput; /** * Module details implementation. @@ -58,6 +59,7 @@ public class ModuleDetailsImpl implements ModuleDetails private List dependencies; private Date installDate; private ModuleInstallState installState; + private LogOutput log; /** * Private constructor to set default values. @@ -79,9 +81,23 @@ public class ModuleDetailsImpl implements ModuleDetails * @param properties the set of properties */ public ModuleDetailsImpl(Properties properties) + { + this(properties, null); + } + + /** + * Creates the instance from a set of properties. All the property values are trimmed + * and empty string values are removed from the set. In other words, zero length or + * whitespace strings are not supported. + * + * @param properties the set of properties + * @param log logger + */ + public ModuleDetailsImpl(Properties properties, LogOutput log) { // Set defaults this(); + this.log = log; // Copy the properties so they don't get modified Properties trimmedProperties = new Properties(); // Trim all the property values @@ -155,6 +171,15 @@ public class ModuleDetailsImpl implements ModuleDetails try { repoVersionMin = new VersionNumber(trimmedProperties.getProperty(PROP_REPO_VERSION_MIN)); + int[] parts = repoVersionMin.getParts(); + if (parts.length > 3) + { + repoVersionMin = new VersionNumber(parts[0] + "." + parts[1] + "." + parts[2]); + if (log != null) + { + log.info("WARNING: version.label from repoVersionMin is ignored."); + } + } } catch (Throwable t) { @@ -167,6 +192,15 @@ public class ModuleDetailsImpl implements ModuleDetails try { repoVersionMax = new VersionNumber(trimmedProperties.getProperty(PROP_REPO_VERSION_MAX)); + int[] parts = repoVersionMax.getParts(); + if (parts.length > 3) + { + repoVersionMax = new VersionNumber(parts[0] + "." + parts[1] + "." + parts[2]); + if (log != null) + { + log.info("WARNING: version.label from repoVersionMax is ignored."); + } + } } catch (Throwable t) { diff --git a/source/java/org/alfresco/repo/module/tool/ModuleDetailsHelper.java b/source/java/org/alfresco/repo/module/tool/ModuleDetailsHelper.java index 4bb4d66404..edb20219cb 100644 --- a/source/java/org/alfresco/repo/module/tool/ModuleDetailsHelper.java +++ b/source/java/org/alfresco/repo/module/tool/ModuleDetailsHelper.java @@ -45,12 +45,23 @@ public class ModuleDetailsHelper * @return Returns the initialized module details */ public static ModuleDetails createModuleDetailsFromPropertiesStream(InputStream is) throws IOException + { + return createModuleDetailsFromPropertiesStream(is, null); + } + + /** + * Factory method to create module details from a stream of a properties file + * @param is the properties input stream, which will be closed during the call + * @param log logger + * @return Returns the initialized module details + */ + public static ModuleDetails createModuleDetailsFromPropertiesStream(InputStream is, LogOutput log) throws IOException { try { Properties properties = new Properties(); properties.load(is); - return new ModuleDetailsImpl(properties); + return new ModuleDetailsImpl(properties, log); } finally { @@ -66,6 +77,19 @@ public class ModuleDetailsHelper * @throws IOException */ public static ModuleDetails createModuleDetailsFromPropertyLocation(String location) throws IOException + { + return createModuleDetailsFromPropertyLocation(location, null); + } + + /** + * Creates a module details helper object based on a file location. + * + * @param location file location + * @param log logger + * @return Returns the module details or null if the location points to nothing + * @throws IOException + */ + public static ModuleDetails createModuleDetailsFromPropertyLocation(String location, LogOutput log) throws IOException { ModuleDetails result = null; TFileInputStream is; @@ -82,7 +106,7 @@ public class ModuleDetailsHelper try { - result = createModuleDetailsFromPropertiesStream(is); + result = createModuleDetailsFromPropertiesStream(is, log); } catch (IOException exception) { diff --git a/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java b/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java index fb2a973c4f..266d054733 100644 --- a/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java +++ b/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java @@ -217,7 +217,7 @@ public class ModuleManagementTool implements LogOutput // Get the details of the installing module String propertiesLocation = ampFileLocation + "/module.properties"; - ModuleDetails installingModuleDetails = ModuleDetailsHelper.createModuleDetailsFromPropertyLocation(propertiesLocation); + ModuleDetails installingModuleDetails = ModuleDetailsHelper.createModuleDetailsFromPropertyLocation(propertiesLocation, this); if (installingModuleDetails == null) { throw new ModuleManagementToolException("No module.properties file has been found in the installing .amp file '" + ampFileLocation + "'");