FIXED : ALF-12533: When run with -directory, MMT should only backup the alfresco.war file once

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@33735 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gethin James
2012-02-07 16:57:13 +00:00
parent d832e817f0
commit cf0ef30fc7

View File

@@ -145,6 +145,10 @@ public class ModuleManagementTool
java.io.File dir = new java.io.File(directoryLocation);
if (dir.exists() == true)
{
if (backupWAR) {
backupWar(warFileLocation,true);
backupWAR = false; //Set it to false so a backup doesn't occur again.
}
installModules(dir, warFileLocation, preview, forceInstall,backupWAR);
}
else
@@ -215,22 +219,7 @@ public class ModuleManagementTool
{
moduleDir.mkdir();
}
File backUpDir = new File(warFileLocation + BACKUP_DIR, DETECTOR_AMP_AND_WAR);
if (backUpDir.exists() == false)
{
backUpDir.mkdir();
}
// Make a backup of the war we are going to modify
if (backupWAR == true)
{
java.io.File warFile = new java.io.File(warFileLocation);
String backupLocation = warFileLocation + "-" + System.currentTimeMillis() + ".bak";
java.io.File backup = new java.io.File(backupLocation);
copyFile(warFile, backup);
outputMessage("WAR has been backed up to '" + backupLocation + "'");
}
backupWar(warFileLocation, backupWAR);
}
// Get the details of the installing module
@@ -382,6 +371,33 @@ public class ModuleManagementTool
throw new ModuleManagementToolException("An IO error was encountered during deployment of the AEP into the WAR", exception);
}
}
private void backupWar(String warFileLocation, boolean backupWAR)
{
// Make a backup of the war we are going to modify
if (backupWAR == true)
{
File backUpDir = new File(warFileLocation + BACKUP_DIR, DETECTOR_AMP_AND_WAR);
if (backUpDir.exists() == false)
{
backUpDir.mkdir();
}
java.io.File warFile = new java.io.File(warFileLocation);
String backupLocation = warFileLocation + "-" + System.currentTimeMillis() + ".bak";
java.io.File backup = new java.io.File(backupLocation);
try
{
copyFile(warFile, backup);
}
catch (IOException exception)
{
throw new ModuleManagementToolException("An IO error was encountered when backing up the WAR", exception);
}
outputMessage("WAR has been backed up to '" + backupLocation + "'");
}
}
/**
* @return Returns the custom file mapping properties or null if they weren't overwritten