diff --git a/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java b/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java index a4d153e99c..8753c81e37 100644 --- a/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java +++ b/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java @@ -201,7 +201,12 @@ public class ModuleManagementTool try { outputMessage("Installing AMP '" + ampFileLocation + "' into WAR '" + warFileLocation + "'"); + java.io.File theWar = new File(warFileLocation, DETECTOR_AMP_AND_WAR); + if (!theWar.exists()) + { + throw new ModuleManagementToolException("The war file '" + warFileLocation + "' does not exist."); + } if (preview == false) { // Make sure the module and backup directory exisits in the WAR file @@ -220,10 +225,6 @@ public class ModuleManagementTool if (backupWAR == true) { java.io.File warFile = new java.io.File(warFileLocation); - if (warFile.exists() == false) - { - throw new ModuleManagementToolException("The war file '" + warFileLocation + "' does not exist."); - } String backupLocation = warFileLocation + "-" + System.currentTimeMillis() + ".bak"; java.io.File backup = new java.io.File(backupLocation); copyFile(warFile, backup); diff --git a/source/java/org/alfresco/repo/module/tool/ModuleManagementToolTest.java b/source/java/org/alfresco/repo/module/tool/ModuleManagementToolTest.java index 3df64428ac..9e8127a362 100644 --- a/source/java/org/alfresco/repo/module/tool/ModuleManagementToolTest.java +++ b/source/java/org/alfresco/repo/module/tool/ModuleManagementToolTest.java @@ -294,20 +294,27 @@ public class ModuleManagementToolTest extends TestCase return file.getPath(); } -// public void testNoWar() throws Exception -// { -// File noWar = new File("noWar"); -// File amp = getFile(".amp", "module/test_v1.amp"); -// try -// { -// this.manager.installModule(amp, noWar,false,false); -// } -// catch (ModuleManagementToolException exception) -// { -// assertTrue(exception.getMessage().endsWith("does not exist.")); -// } -// -// } + public void testNoWar() throws Exception + { + String noWar = "noWar"; + String ampLocation = getFileLocation(".amp", "module/test_v1.amp"); + try + { + this.manager.installModule(ampLocation, noWar,false,false, false); + } + catch (ModuleManagementToolException exception) + { + assertTrue(exception.getMessage().endsWith("does not exist.")); + } + try + { + this.manager.installModule(ampLocation, noWar,false,false, true); //backup war + } + catch (ModuleManagementToolException exception) + { + assertTrue(exception.getMessage().endsWith("does not exist.")); + } + } private void checkForFileExistance(String warLocation, List files) {