Support for renaming of modules

- When a module ID changes, the old ID gets put in a list against property 'module.aliases'.
 - The tool and the repo startup detect the existing installation against the alias and perform a rename.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5559 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-04-26 08:42:19 +00:00
parent d94db4e310
commit 31efa6d4f3
10 changed files with 362 additions and 46 deletions

View File

@@ -148,9 +148,17 @@ public class InstalledFiles
*
* @return the file location
*/
private String getFileLocation()
public String getFileLocation()
{
return this.warLocation + ModuleManagementTool.MODULE_DIR + "/" + this.moduleId + "/modifications.install";
return this.warLocation + getFilePathInWar();
}
/**
* @return Returns the path of the install file within the WAR
*/
public String getFilePathInWar()
{
return ModuleManagementTool.MODULE_DIR + "/" + this.moduleId + "/modifications.install";
}
/**

View File

@@ -75,7 +75,7 @@ public class ModuleDetailsHelper
try
{
File file = new File(location, ModuleManagementTool.DETECTOR_AMP_AND_WAR);
if (file.exists() == true)
if (file.exists())
{
InputStream is = new FileInputStream(file);
result = createModuleDetailsFromPropertiesStream(is);
@@ -102,6 +102,19 @@ public class ModuleDetailsHelper
return ModuleDetailsHelper.createModuleDetailsFromPropertyLocation(modulePropertiesFileLocation);
}
/**
* @param warLocation the location of the WAR file
* @param moduleId the module ID within the WAR
* @return Returns a file handle to the module properties file within the given WAR.
* The file may or may not exist.
*/
public static File getModuleDetailsFileFromWarAndId(String warLocation, String moduleId)
{
String location = ModuleDetailsHelper.getModulePropertiesFileLocation(warLocation, moduleId);
File file = new File(location, ModuleManagementTool.DETECTOR_AMP_AND_WAR);
return file;
}
/**
* Gets the file location
*
@@ -109,9 +122,18 @@ public class ModuleDetailsHelper
* @param moduleId the module id
* @return the file location
*/
private static String getModulePropertiesFileLocation(String warLocation, String moduleId)
public static String getModulePropertiesFileLocation(String warLocation, String moduleId)
{
return warLocation + ModuleManagementTool.MODULE_DIR + "/" + moduleId + "/" + "module.properties";
return warLocation + getModulePropertiesFilePathInWar(moduleId);
}
/**
* @param moduleId the module ID
* @return Returns the path of the module file within a WAR
*/
public static String getModulePropertiesFilePathInWar(String moduleId)
{
return ModuleManagementTool.MODULE_DIR + "/" + moduleId + "/" + "module.properties";
}
/**

View File

@@ -31,6 +31,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -229,7 +230,7 @@ public class ModuleManagementTool
backUpDir.mkdir();
}
// Make a backup of the war we are oging to modify
// Make a backup of the war we are going to modify
if (backupWAR == true)
{
java.io.File warFile = new java.io.File(warFileLocation);
@@ -255,8 +256,28 @@ public class ModuleManagementTool
String installingId = installingModuleDetails.getId();
VersionNumber installingVersion = installingModuleDetails.getVersion();
// Get the detail of the installed module
ModuleDetails installedModuleDetails = ModuleDetailsHelper.createModuleDetailsFromWarAndId(warFileLocation, installingModuleDetails.getId());
// Try to find an installed module by the ID
ModuleDetails installedModuleDetails = ModuleDetailsHelper.createModuleDetailsFromWarAndId(warFileLocation, installingId);
if (installedModuleDetails == null)
{
// It might be there as one of the aliases
List<String> installingAliases = installingModuleDetails.getAliases();
for (String installingAlias : installingAliases)
{
ModuleDetails installedAliasModuleDetails = ModuleDetailsHelper.createModuleDetailsFromWarAndId(warFileLocation, installingAlias);
if (installedAliasModuleDetails == null)
{
// There is nothing by that alias
continue;
}
// We found an alias and will treat it as the same module
installedModuleDetails = installedAliasModuleDetails;
outputMessage("Module '" + installingAlias + "' is installed and is an alias of '" + installingId + "'");
break;
}
}
// Now clean up the old instance
if (installedModuleDetails != null)
{
String installedId = installedModuleDetails.getId();
@@ -453,6 +474,12 @@ public class ModuleManagementTool
outputMessage("Recovering file '" + update.getKey() + "' from backup '" + update.getValue() + "'", true);
}
// Now remove the installed files list
String installedFilesPathInWar = installedFiles.getFilePathInWar();
removeFile(warFileLocation, installedFilesPathInWar, preview);
// Remove the module properties
String modulePropertiesFileLocationInWar = ModuleDetailsHelper.getModulePropertiesFilePathInWar(moduleId);
removeFile(warFileLocation, modulePropertiesFileLocationInWar, preview);
}
/**
@@ -478,7 +505,7 @@ public class ModuleManagementTool
outputMessage("The file '" + filePath + "' was expected for removal but was not present in the war", true);
}
}
/**
* Copies a file from the AMP location to the correct location in the WAR, interating on directories where appropraite.
*

View File

@@ -1,4 +1,4 @@
# The default AEP => WAR file mappings
# The default AMP => WAR file mappings
/config=/WEB-INF/classes
/lib=/WEB-INF/lib
/licenses=/WEB-INF/licenses