use of de.schlichtherle.truezip.file.TFile in project alfresco-repository by Alfresco.
the class ModuleDetailsHelper method saveModuleDetails.
/**
* Saves the module details to the war in the correct location based on the module id
*
* @param warLocation the war location
* @param moduleDetails the module id
*/
public static void saveModuleDetails(String warLocation, ModuleDetails moduleDetails) {
// Ensure that it is a valid set of properties
String moduleId = moduleDetails.getId();
try {
String modulePropertiesFileLocation = getModulePropertiesFileLocation(warLocation, moduleId);
TFile file = new TFile(modulePropertiesFileLocation);
if (file.exists() == false) {
file.createNewFile();
}
// Get all the module properties
Properties moduleProperties = moduleDetails.getProperties();
OutputStream os = new TFileOutputStream(file);
try {
moduleProperties.store(os, null);
} finally {
os.close();
}
} catch (IOException exception) {
throw new ModuleManagementToolException("Unable to save module details into WAR file: \n" + " Module: " + moduleDetails.getId() + "\n" + " Properties: " + moduleDetails.getProperties(), exception);
}
}
use of de.schlichtherle.truezip.file.TFile in project alfresco-repository by Alfresco.
the class WarHelperImplTest method testCheckCompatibleVersion.
@Test
public void testCheckCompatibleVersion() {
// Version 4.1.0
TFile theWar = getFile(".war", "module/test.war");
ModuleDetails installingModuleDetails = new ModuleDetailsImpl("test_it", new ModuleVersionNumber("9999"), "Test Mod", "Testing module");
installingModuleDetails.setRepoVersionMin(new VersionNumber("10.1"));
try {
this.checkCompatibleVersion(theWar, installingModuleDetails);
// should never get here
fail();
} catch (ModuleManagementToolException exception) {
assertTrue(exception.getMessage().contains("must be installed on a war version equal to or greater than 10.1"));
}
installingModuleDetails.setRepoVersionMin(new VersionNumber("1.1"));
// does not throw exception
this.checkCompatibleVersion(theWar, installingModuleDetails);
installingModuleDetails.setRepoVersionMax(new VersionNumber("3.0"));
try {
this.checkCompatibleVersion(theWar, installingModuleDetails);
// should never get here
fail();
} catch (ModuleManagementToolException exception) {
assertTrue(exception.getMessage().contains("cannot be installed on a war version greater than 3.0"));
}
installingModuleDetails.setRepoVersionMax(new VersionNumber("99"));
// does not throw exception
this.checkCompatibleVersion(theWar, installingModuleDetails);
// current war version
installingModuleDetails.setRepoVersionMin(new VersionNumber("4.1.0"));
// current war version
installingModuleDetails.setRepoVersionMax(new VersionNumber("4.1.0"));
// does not throw exception
this.checkCompatibleVersion(theWar, installingModuleDetails);
// current war version
installingModuleDetails.setRepoVersionMin(new VersionNumber("3.4.0"));
// current war version
installingModuleDetails.setRepoVersionMax(new VersionNumber("4.1.0"));
// does not throw exception
this.checkCompatibleVersion(theWar, installingModuleDetails);
try {
// current war version
installingModuleDetails.setRepoVersionMin(new VersionNumber("3.4.0"));
// current war version
installingModuleDetails.setRepoVersionMax(new VersionNumber("4.0.999"));
// does not throw exception
this.checkCompatibleVersion(theWar, installingModuleDetails);
// should never get here
fail("Should not pass as current version is 4.1.0 and the max value is 4.0.999");
} catch (ModuleManagementToolException exception) {
assertTrue(exception.getMessage().contains("cannot be installed on a war version greater than 4.0.999"));
}
}
use of de.schlichtherle.truezip.file.TFile in project alfresco-repository by Alfresco.
the class WarHelperImplTest method testCheckCompatibleEdition.
@Test
public void testCheckCompatibleEdition() {
Properties props = dummyModuleProperties();
ModuleDetails installingModuleDetails = new ModuleDetailsImpl(props);
// Community Edition
TFile theWar = getFile(".war", "module/test.war");
// Test for no edition specified
// does not throw exception
this.checkCompatibleEdition(theWar, installingModuleDetails);
// Test for invalid edition
props.setProperty(ModuleDetails.PROP_EDITIONS, "CommuniT");
installingModuleDetails = new ModuleDetailsImpl(props);
try {
this.checkCompatibleEdition(theWar, installingModuleDetails);
// should never get here
fail();
} catch (ModuleManagementToolException exception) {
assertTrue(exception.getMessage().endsWith("can only be installed in one of the following editions[CommuniT]"));
}
// should ignore case
props.setProperty(ModuleDetails.PROP_EDITIONS, ("CoMMunity"));
installingModuleDetails = new ModuleDetailsImpl(props);
// does not throw exception
this.checkCompatibleEdition(theWar, installingModuleDetails);
// should ignore case
props.setProperty(ModuleDetails.PROP_EDITIONS, ("enterprise,community,bob"));
installingModuleDetails = new ModuleDetailsImpl(props);
// does not throw exception
this.checkCompatibleEdition(theWar, installingModuleDetails);
// should ignore case
props.setProperty(ModuleDetails.PROP_EDITIONS, ("enterprise,Community"));
installingModuleDetails = new ModuleDetailsImpl(props);
// does not throw exception
this.checkCompatibleVersion(theWar, installingModuleDetails);
}
use of de.schlichtherle.truezip.file.TFile in project alfresco-repository by Alfresco.
the class WarHelperImplTest method testfindManifest.
@Test
public void testfindManifest() throws Exception {
// Now check the compatible versions using the manifest
TFile theWar = getFile(".war", "module/share-3.4.11.war");
Manifest manifest = this.findManifest(theWar);
assertNotNull(manifest);
assertEquals("Alfresco Share Enterprise", manifest.getMainAttributes().getValue(MANIFEST_IMPLEMENTATION_TITLE));
assertEquals("3.4.11", manifest.getMainAttributes().getValue(MANIFEST_SPECIFICATION_VERSION));
theWar = getFile(".war", "module/alfresco-4.2.a.war");
manifest = this.findManifest(theWar);
assertNotNull(manifest);
assertEquals("Alfresco Repository Community", manifest.getMainAttributes().getValue(MANIFEST_IMPLEMENTATION_TITLE));
assertEquals("4.2.a", manifest.getMainAttributes().getValue(MANIFEST_SPECIFICATION_VERSION));
}
use of de.schlichtherle.truezip.file.TFile in project alfresco-repository by Alfresco.
the class WarHelperImplTest method testListModules.
@Test
public void testListModules() throws Exception {
TFile theWar = getFile(".war", "module/test.war");
List<ModuleDetails> details = this.listModules(theWar);
assertNotNull(details);
assertEquals(details.size(), 0);
theWar = getFile(".war", "module/share-4.2.a.war");
details = this.listModules(theWar);
assertNotNull(details);
assertEquals(details.size(), 1);
ModuleDetails aModule = details.get(0);
assertEquals("alfresco-mm-share", aModule.getId());
assertEquals("0.1.5.6", aModule.getModuleVersionNumber().toString());
assertEquals(ModuleInstallState.INSTALLED, aModule.getInstallState());
}
Aggregations