From 1e8c35affac8715683a2a005514adb95e574fbe8 Mon Sep 17 00:00:00 2001 From: Gethin James Date: Wed, 8 Feb 2012 16:05:05 +0000 Subject: [PATCH] Removed superseded changes brought in by the merge. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@33777 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/module/tool/ModuleDetailsHelper.java | 28 ------------ .../module/tool/ModuleManagementTool.java | 18 -------- .../module/tool/ModuleManagementToolTest.java | 43 +------------------ 3 files changed, 1 insertion(+), 88 deletions(-) diff --git a/source/java/org/alfresco/repo/module/tool/ModuleDetailsHelper.java b/source/java/org/alfresco/repo/module/tool/ModuleDetailsHelper.java index 2250731ef4..3a8f5f6b14 100644 --- a/source/java/org/alfresco/repo/module/tool/ModuleDetailsHelper.java +++ b/source/java/org/alfresco/repo/module/tool/ModuleDetailsHelper.java @@ -170,32 +170,4 @@ public class ModuleDetailsHelper exception); } } - - - /** - * Reads a .properites file from the war and returns it as a Properties object - * @param warLocation The location of the war - * @param propertiesPath Path to the properties file (including .properties) - * @return Properties object or null - */ - public static Properties getPropertiesFromWar(String warLocation, String propertiesPath) - { - Properties result = null; - try - { - File file = new File(warLocation+propertiesPath, ModuleManagementTool.DETECTOR_AMP_AND_WAR); - if (file.exists()) - { - InputStream is = new FileInputStream(file); - result = new Properties(); - result.load(is); - } - } - catch (IOException exception) - { - throw new ModuleManagementToolException("Unable to load properties from the war file; "+propertiesPath, exception); - } - return result; - - } } diff --git a/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java b/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java index 34dacca2f2..3936de9cb5 100644 --- a/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java +++ b/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java @@ -66,7 +66,6 @@ public class ModuleManagementTool /** Standard directories found in the alfresco war */ public static final String BACKUP_DIR = WarHelper.MODULE_NAMESPACE_DIR+ "/backup"; - public static final String VERSION_PROPERTIES = "/WEB-INF/classes/alfresco/version.properties"; /** Operations and options supperted via the command line interface to this class */ private static final String OP_INSTALL = "install"; @@ -232,9 +231,6 @@ public class ModuleManagementTool } String installingId = installingModuleDetails.getId(); VersionNumber installingVersion = installingModuleDetails.getVersion(); - - //Check that the target war repo is the correct version - checkTargetWarVersion(warFileLocation, installingModuleDetails); //A series of checks warHelper.checkCompatibleVersion(theWar, installingModuleDetails); @@ -376,20 +372,6 @@ public class ModuleManagementTool } } - protected void checkTargetWarVersion(String warFileLocation, ModuleDetails installingModuleDetails) - { - Properties warVers = ModuleDetailsHelper.getPropertiesFromWar(warFileLocation, VERSION_PROPERTIES); - outputMessage("WAR properties '" + warVers + "'"); - VersionNumber warVersion = new VersionNumber(warVers.getProperty("version.major")+"."+warVers.getProperty("version.revision")+"."+warVers.getProperty("version.minor")); - if(warVersion.compareTo(installingModuleDetails.getRepoVersionMin())==-1) { - throw new ModuleManagementToolException("The module ("+installingModuleDetails.getTitle()+") must be installed on a repo version greater than "+installingModuleDetails.getRepoVersionMin()); - } - if(warVersion.compareTo(installingModuleDetails.getRepoVersionMax())==1) { - throw new ModuleManagementToolException("The module ("+installingModuleDetails.getTitle()+") cannot be installed on a repo version greater than "+installingModuleDetails.getRepoVersionMax()); - } - - } - private void backupWar(String warFileLocation, boolean backupWAR) { diff --git a/source/java/org/alfresco/repo/module/tool/ModuleManagementToolTest.java b/source/java/org/alfresco/repo/module/tool/ModuleManagementToolTest.java index 49d301191c..9e8127a362 100644 --- a/source/java/org/alfresco/repo/module/tool/ModuleManagementToolTest.java +++ b/source/java/org/alfresco/repo/module/tool/ModuleManagementToolTest.java @@ -30,10 +30,7 @@ import java.util.Map; import junit.framework.TestCase; -import org.alfresco.repo.module.ModuleDetailsImpl; -import org.alfresco.service.cmr.module.ModuleDetails; import org.alfresco.util.TempFileProvider; -import org.alfresco.util.VersionNumber; import org.springframework.util.FileCopyUtils; import de.schlichtherle.io.DefaultRaesZipDetector; @@ -267,48 +264,10 @@ public class ModuleManagementToolTest extends TestCase } catch (ModuleManagementToolException exception) { + exception.printStackTrace(); System.out.println("Expected failure: " + exception.getMessage()); } } - - public void testCheckTargetWarVersion() throws Exception - { - manager.setVerbose(true); - String warLocation = getFileLocation(".war", "module/test.war"); //Version 4.0.1 - - ModuleDetails installingModuleDetails = new ModuleDetailsImpl("test_it", new VersionNumber("9999"), "Test Mod", "Testing module"); - installingModuleDetails.setRepoVersionMin(new VersionNumber("10.1")); - try - { - this.manager.checkTargetWarVersion(warLocation, installingModuleDetails); - fail(); //should never get here - } - catch (ModuleManagementToolException exception) - { - assertTrue(exception.getMessage().endsWith("must be installed on a repo version greater than 10.1")); - } - - installingModuleDetails.setRepoVersionMin(new VersionNumber("1.1")); - this.manager.checkTargetWarVersion(warLocation, installingModuleDetails); //does not throw exception - - installingModuleDetails.setRepoVersionMax(new VersionNumber("3.0")); - try - { - this.manager.checkTargetWarVersion(warLocation, installingModuleDetails); - fail(); //should never get here - } - catch (ModuleManagementToolException exception) - { - assertTrue(exception.getMessage().endsWith("cannot be installed on a repo version greater than 3.0")); - } - - installingModuleDetails.setRepoVersionMax(new VersionNumber("99")); - this.manager.checkTargetWarVersion(warLocation, installingModuleDetails); //does not throw exception - - installingModuleDetails.setRepoVersionMin(new VersionNumber("4.0.1")); //current war version - installingModuleDetails.setRepoVersionMax(new VersionNumber("4.0.1")); //current war version - this.manager.checkTargetWarVersion(warLocation, installingModuleDetails); //does not throw exception - } public void testList()