Merged 5.0.N (5.0.4) to 5.1.N (5.1.1)

120179 amorarasu: Merged DEV to 5.0.N (5.0.4)
      120074 nabacioaiei: MNT-15252 : Any repository amp having set module.repo.version.min=5.0.2.1 cannot be applied to an Alfresco One 5.0.2.1 instance.
         - modified ModuleDetailsImpl to ignore version.label(if it exists) from module.repo.version.min and module.repo.version.max and log a warning.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@120259 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ramona Neamtu
2015-12-16 09:33:59 +00:00
parent 884bb19489
commit a2c245e353
3 changed files with 62 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2015 Alfresco Software Limited.
* *
* This file is part of Alfresco * 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.springframework.extensions.surf.util.ISO8601DateFormat;
import org.alfresco.util.Pair; import org.alfresco.util.Pair;
import org.alfresco.util.VersionNumber; import org.alfresco.util.VersionNumber;
import org.alfresco.repo.module.tool.LogOutput;
/** /**
* Module details implementation. * Module details implementation.
@@ -58,6 +59,7 @@ public class ModuleDetailsImpl implements ModuleDetails
private List<ModuleDependency> dependencies; private List<ModuleDependency> dependencies;
private Date installDate; private Date installDate;
private ModuleInstallState installState; private ModuleInstallState installState;
private LogOutput log;
/** /**
* Private constructor to set default values. * Private constructor to set default values.
@@ -79,9 +81,23 @@ public class ModuleDetailsImpl implements ModuleDetails
* @param properties the set of properties * @param properties the set of properties
*/ */
public ModuleDetailsImpl(Properties 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 // Set defaults
this(); this();
this.log = log;
// Copy the properties so they don't get modified // Copy the properties so they don't get modified
Properties trimmedProperties = new Properties(); Properties trimmedProperties = new Properties();
// Trim all the property values // Trim all the property values
@@ -155,6 +171,15 @@ public class ModuleDetailsImpl implements ModuleDetails
try try
{ {
repoVersionMin = new VersionNumber(trimmedProperties.getProperty(PROP_REPO_VERSION_MIN)); 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) catch (Throwable t)
{ {
@@ -167,6 +192,15 @@ public class ModuleDetailsImpl implements ModuleDetails
try try
{ {
repoVersionMax = new VersionNumber(trimmedProperties.getProperty(PROP_REPO_VERSION_MAX)); 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) catch (Throwable t)
{ {

View File

@@ -45,12 +45,23 @@ public class ModuleDetailsHelper
* @return Returns the initialized module details * @return Returns the initialized module details
*/ */
public static ModuleDetails createModuleDetailsFromPropertiesStream(InputStream is) throws IOException 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 try
{ {
Properties properties = new Properties(); Properties properties = new Properties();
properties.load(is); properties.load(is);
return new ModuleDetailsImpl(properties); return new ModuleDetailsImpl(properties, log);
} }
finally finally
{ {
@@ -66,6 +77,19 @@ public class ModuleDetailsHelper
* @throws IOException * @throws IOException
*/ */
public static ModuleDetails createModuleDetailsFromPropertyLocation(String location) 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; ModuleDetails result = null;
TFileInputStream is; TFileInputStream is;
@@ -82,7 +106,7 @@ public class ModuleDetailsHelper
try try
{ {
result = createModuleDetailsFromPropertiesStream(is); result = createModuleDetailsFromPropertiesStream(is, log);
} }
catch (IOException exception) catch (IOException exception)
{ {

View File

@@ -217,7 +217,7 @@ public class ModuleManagementTool implements LogOutput
// Get the details of the installing module // Get the details of the installing module
String propertiesLocation = ampFileLocation + "/module.properties"; String propertiesLocation = ampFileLocation + "/module.properties";
ModuleDetails installingModuleDetails = ModuleDetailsHelper.createModuleDetailsFromPropertyLocation(propertiesLocation); ModuleDetails installingModuleDetails = ModuleDetailsHelper.createModuleDetailsFromPropertyLocation(propertiesLocation, this);
if (installingModuleDetails == null) if (installingModuleDetails == null)
{ {
throw new ModuleManagementToolException("No module.properties file has been found in the installing .amp file '" + ampFileLocation + "'"); throw new ModuleManagementToolException("No module.properties file has been found in the installing .amp file '" + ampFileLocation + "'");