diff --git a/source/java/org/alfresco/repo/module/tool/InstalledFiles.java b/source/java/org/alfresco/repo/module/tool/InstalledFiles.java
index 43c52210c2..adac50e598 100644
--- a/source/java/org/alfresco/repo/module/tool/InstalledFiles.java
+++ b/source/java/org/alfresco/repo/module/tool/InstalledFiles.java
@@ -56,7 +56,7 @@ public class InstalledFiles
*/
public void load()
{
- File file = new File(getFileLocation(), ModuleManagementTool.defaultDetector);
+ File file = new File(getFileLocation(), ModuleManagementTool.DETECTOR_AMP_AND_WAR);
if (file.exists() == true)
{
try
@@ -108,7 +108,7 @@ public class InstalledFiles
{
try
{
- File file = new File(getFileLocation(), ModuleManagementTool.defaultDetector);
+ File file = new File(getFileLocation(), ModuleManagementTool.DETECTOR_AMP_AND_WAR);
if (file.exists() == false)
{
file.createNewFile();
diff --git a/source/java/org/alfresco/repo/module/tool/ModuleDetailsHelper.java b/source/java/org/alfresco/repo/module/tool/ModuleDetailsHelper.java
index 3c542aae63..1a6210a333 100644
--- a/source/java/org/alfresco/repo/module/tool/ModuleDetailsHelper.java
+++ b/source/java/org/alfresco/repo/module/tool/ModuleDetailsHelper.java
@@ -64,7 +64,7 @@ public class ModuleDetailsHelper extends ModuleDetailsImpl
ModuleDetailsHelper result = null;
try
{
- File file = new File(location, ModuleManagementTool.defaultDetector);
+ File file = new File(location, ModuleManagementTool.DETECTOR_AMP_AND_WAR);
if (file.exists() == true)
{
result = new ModuleDetailsHelper(new FileInputStream(file));
@@ -86,7 +86,7 @@ public class ModuleDetailsHelper extends ModuleDetailsImpl
*/
public static ModuleDetailsHelper create(String warLocation, String moduleId)
{
- return ModuleDetailsHelper.create(ModuleDetailsHelper.getFileLocation(warLocation, moduleId));
+ return ModuleDetailsHelper.create(ModuleDetailsHelper.getModulePropertiesFileLocation(warLocation, moduleId));
}
/**
@@ -96,7 +96,7 @@ public class ModuleDetailsHelper extends ModuleDetailsImpl
* @param moduleId the module id
* @return the file location
*/
- private static String getFileLocation(String warLocation, String moduleId)
+ private static String getModulePropertiesFileLocation(String warLocation, String moduleId)
{
return warLocation + ModuleManagementTool.MODULE_DIR + "/" + moduleId + "/" + "module.properties";
}
@@ -111,7 +111,7 @@ public class ModuleDetailsHelper extends ModuleDetailsImpl
{
try
{
- File file = new File(getFileLocation(warLocation, moduleId), ModuleManagementTool.defaultDetector);
+ File file = new File(getModulePropertiesFileLocation(warLocation, moduleId), ModuleManagementTool.DETECTOR_AMP_AND_WAR);
if (file.exists() == false)
{
file.createNewFile();
diff --git a/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java b/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java
index 3af3721c08..0cf1777468 100644
--- a/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java
+++ b/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java
@@ -56,6 +56,13 @@ public class ModuleManagementTool
{
/** Location of the default mapping properties file */
private static final String DEFAULT_FILE_MAPPING_PROPERTIES = "org/alfresco/repo/module/tool/default-file-mapping.properties";
+ /** Location of the AMP-specific mappings file */
+ private static final String FILE_MAPPING_PROPERTIES = "file-mapping.properties";
+ /**
+ * The property to add to a custom {@link #FILE_MAPPING_PROPERTIES file-mapping.properties} to inherit the default values.
+ * The default is true.
+ */
+ private static final String PROP_INHERIT_DEFAULT = "inherit.default";
/** Standard directories found in the alfresco war */
public static final String MODULE_DIR = "/WEB-INF/classes/alfresco/module";
@@ -71,10 +78,10 @@ public class ModuleManagementTool
private static final String OPTION_DIRECTORY = "-directory";
/** Default zip detector */
- public static ZipDetector defaultDetector = new DefaultRaesZipDetector("amp|war");
+ public static final ZipDetector DETECTOR_AMP_AND_WAR = new DefaultRaesZipDetector("amp|war");
/** File mapping properties */
- private Properties fileMappingProperties;
+ private Properties defaultFileMappingProperties;
/** Indicates the current verbose setting */
private boolean verbose = false;
@@ -85,11 +92,11 @@ public class ModuleManagementTool
public ModuleManagementTool()
{
// Load the default file mapping properties
- this.fileMappingProperties = new Properties();
+ this.defaultFileMappingProperties = new Properties();
InputStream is = this.getClass().getClassLoader().getResourceAsStream(DEFAULT_FILE_MAPPING_PROPERTIES);
try
{
- this.fileMappingProperties.load(is);
+ this.defaultFileMappingProperties.load(is);
}
catch (IOException exception)
{
@@ -208,12 +215,12 @@ public class ModuleManagementTool
if (preview == false)
{
// Make sure the module and backup directory exisits in the WAR file
- File moduleDir = new File(warFileLocation + MODULE_DIR, defaultDetector);
+ File moduleDir = new File(warFileLocation + MODULE_DIR, DETECTOR_AMP_AND_WAR);
if (moduleDir.exists() == false)
{
moduleDir.mkdir();
}
- File backUpDir = new File(warFileLocation + BACKUP_DIR, defaultDetector);
+ File backUpDir = new File(warFileLocation + BACKUP_DIR, DETECTOR_AMP_AND_WAR);
if (backUpDir.exists() == false)
{
backUpDir.mkdir();
@@ -252,11 +259,11 @@ public class ModuleManagementTool
if (forceInstall == true)
{
// Warn of forced install
- outputMessage("WARNING: The installation of this module is being forced. All files will be removed and replaced reguarless of exiting versions present.");
+ outputMessage("WARNING: The installation of this module is being forced. All files will be removed and replaced regardless of exiting versions present.");
}
// Trying to update the extension, old files need to cleaned before we proceed
- outputMessage("Clearing out files relating to version '" + installedModuleDetails.getVersionNumber().toString() + "' of module '" + installedModuleDetails.getId() + "'");
+ outputMessage("Clearing out files relating to version '" + installedModuleDetails.getVersionNumber() + "' of module '" + installedModuleDetails.getId() + "'");
cleanWAR(warFileLocation, installedModuleDetails.getId(), preview);
}
else if (compareValue == 0)
@@ -274,29 +281,47 @@ public class ModuleManagementTool
}
- // TODO check for any additional file mapping propeties supplied in the AEP file
+ // Check if a custom mapping file has been defined
+ Properties fileMappingProperties = null;
+ Properties customFileMappingProperties = getCustomFileMappings(ampFileLocation);
+ if (customFileMappingProperties == null)
+ {
+ fileMappingProperties = defaultFileMappingProperties;
+ }
+ else
+ {
+ fileMappingProperties = new Properties();
+ // A custom mapping file was present. Check if it must inherit the default mappings.
+ String inheritDefaultStr = customFileMappingProperties.getProperty(PROP_INHERIT_DEFAULT, "true");
+ if (inheritDefaultStr.equalsIgnoreCase("true"))
+ {
+ fileMappingProperties.putAll(defaultFileMappingProperties);
+ }
+ fileMappingProperties.putAll(customFileMappingProperties);
+ fileMappingProperties.remove(PROP_INHERIT_DEFAULT);
+ }
// Copy the files from the AEP file into the WAR file
- outputMessage("Adding files relating to version '" + installingModuleDetails.getVersionNumber().toString() + "' of module '" + installingModuleDetails.getId() + "'");
+ outputMessage("Adding files relating to version '" + installingModuleDetails.getVersionNumber() + "' of module '" + installingModuleDetails.getId() + "'");
InstalledFiles installedFiles = new InstalledFiles(warFileLocation, installingModuleDetails.getId());
- for (Map.Entry