diff --git a/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java b/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java index ebdc546666..93eb9fd9ed 100644 --- a/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java +++ b/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java @@ -583,6 +583,14 @@ public class ModuleManagementTool implements LogOutput backupLocation = BACKUP_DIR + "/" + generateGuid() + ".bin"; if (preview == false) { + //Create the directory if it doesn't exist. + TFile backupLocationDirectory = new TFile(warFileLocation+ BACKUP_DIR); + if (!backupLocationDirectory.exists()) + { + backupLocationDirectory.mkdir(); + } + + //Backup the file TFile backupFile = new TFile(warFileLocation + backupLocation); destinationChild.cp_rp(backupFile); } diff --git a/source/java/org/alfresco/repo/module/tool/ModuleManagementToolTest.java b/source/java/org/alfresco/repo/module/tool/ModuleManagementToolTest.java index ce9565abe1..8b7f417398 100644 --- a/source/java/org/alfresco/repo/module/tool/ModuleManagementToolTest.java +++ b/source/java/org/alfresco/repo/module/tool/ModuleManagementToolTest.java @@ -250,7 +250,7 @@ public class ModuleManagementToolTest extends TestCase { manager.setVerbose(true); - String warLocation = getFileLocation(".war", "module/test.war"); + String warLocation = getFileLocation(".war", "module/alfresco-4.2.c.war"); String ampLocation = getFileLocation(".amp", "module/test_v4.amp"); try @@ -263,8 +263,18 @@ public class ModuleManagementToolTest extends TestCase { assertTrue(e.getMessage().contains("The amp will overwrite an existing file")); } - this.manager.installModule(ampLocation, warLocation, false, true, false); //install it again - this.manager.installModule(ampLocation, warLocation, false, true, false); //install it again, just to be sure + + String ampv2Location = getFileLocation(".amp", "module/test_v2.amp"); + warLocation = getFileLocation(".war", "module/alfresco-4.2.c.war"); //Get a new war file + this.manager.installModule(ampLocation, warLocation, false, true, false); //install v1 + this.manager.installModule(ampv2Location, warLocation, false, true, false); //install v2 + + //install another amp that replaces the same files + ampLocation = getFileLocation(".amp", "module/test_v4.amp"); + warLocation = getFileLocation(".war", "module/alfresco-4.2.c.war"); //Get a new war file + String amp5Location = getFileLocation(".amp", "module/test_v7.amp"); //new amp that overides existing files + this.manager.installModule(ampLocation, warLocation, false, true, false); + this.manager.installModule(amp5Location, warLocation, false, true, false); } public void testInstallFromDir() diff --git a/source/test-resources/module/alfresco-4.2.c.war b/source/test-resources/module/alfresco-4.2.c.war new file mode 100755 index 0000000000..9ddb788f99 Binary files /dev/null and b/source/test-resources/module/alfresco-4.2.c.war differ diff --git a/source/test-resources/module/test_v7.amp b/source/test-resources/module/test_v7.amp new file mode 100755 index 0000000000..e1b81e4aea Binary files /dev/null and b/source/test-resources/module/test_v7.amp differ