use of org.alfresco.util.VersionNumber in project alfresco-repository by Alfresco.
the class WarHelperImplTest method testNoVersionProperties.
@Test
public void testNoVersionProperties() {
TFile theWar = getFile(".war", "module/empty.war");
ModuleDetails installingModuleDetails = new ModuleDetailsImpl("test_it", new ModuleVersionNumber("9999"), "Test Mod", "Testing module");
installingModuleDetails.setRepoVersionMin(new VersionNumber("10.1"));
// does not throw exception
this.checkCompatibleVersion(theWar, installingModuleDetails);
// does not throw exception
this.checkCompatibleEdition(theWar, installingModuleDetails);
}
use of org.alfresco.util.VersionNumber in project alfresco-repository by Alfresco.
the class ModuleComponentHelperTest method testgetModuleVersionNumber.
public void testgetModuleVersionNumber() {
ModuleVersionNumber moduleVersion = new ModuleVersionNumber("3.5");
VersionNumber versNumber = new VersionNumber("3.5");
assertEquals(moduleVersion, helper.getModuleVersionNumber(moduleVersion));
assertEquals(moduleVersion, helper.getModuleVersionNumber(versNumber));
try {
helper.getModuleVersionNumber(null);
// should never get here
assertTrue(false);
} catch (ModuleManagementToolException e) {
// should get here
}
// try {
// helper.getModuleVersionNumber("any object");
// assertTrue(false); //should never get here
// } catch (ModuleManagementToolException e) {
// //should get here
// }
// assertTrue(true);
}
use of org.alfresco.util.VersionNumber in project alfresco-repository by Alfresco.
the class ImageMagickContentTransformerWorker method isAlphaOptionSupported.
private static boolean isAlphaOptionSupported(String versionString) {
// the "-alpha" option was only introduced in ImageMagick v6.7.5 and will fail in older versions.
String ALPHA_PROP_SUPPORTED_VERSION = "6.7.5";
try {
VersionNumber supportedVersion = new VersionNumber(ALPHA_PROP_SUPPORTED_VERSION);
VersionNumber checkedVersion = new VersionNumber(getImageMagickVersionNumber(versionString));
return supportedVersion.compareTo(checkedVersion) > 0 ? false : true;
} catch (Exception e) {
logger.warn("Could not extract version of ImageMagick. Alpha-compatibility will be disabled: " + e.getMessage());
}
return false;
}
use of org.alfresco.util.VersionNumber in project alfresco-repository by Alfresco.
the class WarHelperImpl method checkCompatibleVersion.
@Override
public void checkCompatibleVersion(TFile war, ModuleDetails installingModuleDetails) {
// Version check
TFile propsFile = new TFile(war + VERSION_PROPERTIES);
if (propsFile != null && propsFile.exists()) {
log.info("INFO: Checking the war version using " + VERSION_PROPERTIES);
Properties warVers = loadProperties(propsFile);
VersionNumber warVersion = new VersionNumber(warVers.getProperty("version.major") + "." + warVers.getProperty("version.minor") + "." + warVers.getProperty("version.revision"));
checkVersions(warVersion, installingModuleDetails);
} else {
log.info("INFO: Checking the war version using the manifest.");
checkCompatibleVersionUsingManifest(war, installingModuleDetails);
}
}
use of org.alfresco.util.VersionNumber in project alfresco-repository by Alfresco.
the class ModuleComponentHelper method startModule.
/**
* Does the actual work without fussing about transactions and authentication.
* Module dependencies will be started first, but a module will only be started
* once.
*
* @param module the module to start
* @param startedModules the IDs of modules that have already started
* @param executedComponents keep track of the executed components
*/
private void startModule(ModuleDetails module, Set<String> startedModules, Set<ModuleComponent> executedComponents) {
String moduleId = module.getId();
ModuleVersionNumber moduleNewVersion = module.getModuleVersionNumber();
// Double check whether we have done this module already
if (startedModules.contains(moduleId)) {
if (logger.isDebugEnabled()) {
logger.debug("Module '" + module + "' already started");
}
return;
}
// Start dependencies
List<ModuleDependency> moduleDependencies = module.getDependencies();
for (ModuleDependency moduleDependency : moduleDependencies) {
if (logger.isDebugEnabled()) {
logger.debug("Module '" + module + "' depends on: " + moduleDependency);
}
// Get the dependency
String moduleDependencyId = moduleDependency.getDependencyId();
ModuleDetails moduleDependencyDetails = moduleService.getModule(moduleDependencyId);
// Check that it is there
if (moduleDependencyDetails == null) {
// The dependency is not there
// List required dependencies
StringBuilder sb = new StringBuilder(128);
for (ModuleDependency dependency : moduleDependencies) {
sb.append("\n").append(dependency);
}
String msg = I18NUtil.getMessage(MSG_DEPENDENCIES, moduleId, moduleNewVersion, sb.toString());
logger.info(msg);
// Now fail
throw AlfrescoRuntimeException.create(ERR_MISSING_DEPENDENCY, moduleId, moduleNewVersion, moduleDependency);
}
// The dependency is installed, so start it
startModule(moduleDependencyDetails, startedModules, executedComponents);
}
// Check if the module needs a rename first
renameModule(module);
// First check that the module version is fundamentally compatible with the repository
VersionNumber repoVersionNumber = descriptorService.getServerDescriptor().getVersionNumber();
VersionNumber minRepoVersionNumber = module.getRepoVersionMin();
VersionNumber maxRepoVersionNumber = module.getRepoVersionMax();
if ((minRepoVersionNumber != null && repoVersionNumber.compareTo(minRepoVersionNumber) < 0) || (maxRepoVersionNumber != null && repoVersionNumber.compareTo(maxRepoVersionNumber) > 0)) {
// The current repo version is not supported
throw AlfrescoRuntimeException.create(ERR_UNSUPPORTED_REPO_VERSION, moduleId, moduleNewVersion, repoVersionNumber, minRepoVersionNumber, maxRepoVersionNumber);
}
// Get the module details from the registry
RegistryKey moduleKeyInstalledVersion = new RegistryKey(ModuleComponentHelper.URI_MODULES_1_0, REGISTRY_PATH_MODULES, moduleId, REGISTRY_PROPERTY_INSTALLED_VERSION);
RegistryKey moduleKeyCurrentVersion = new RegistryKey(ModuleComponentHelper.URI_MODULES_1_0, REGISTRY_PATH_MODULES, moduleId, REGISTRY_PROPERTY_CURRENT_VERSION);
Serializable moduleInstallVersion = registryService.getProperty(moduleKeyInstalledVersion);
Serializable moduleCurrentVersion = registryService.getProperty(moduleKeyCurrentVersion);
String msg = null;
if (// No previous record of it
moduleCurrentVersion == null) {
msg = I18NUtil.getMessage(MSG_INSTALLING, moduleId, moduleNewVersion);
// Record the install version
registryService.addProperty(moduleKeyInstalledVersion, moduleNewVersion);
moduleInstallVersion = moduleNewVersion;
moduleCurrentVersion = moduleNewVersion;
} else // It is an upgrade or is the same
{
ModuleVersionNumber currentModuleVersion = getModuleVersionNumber(moduleCurrentVersion);
// Check that we have an installed version
if (moduleInstallVersion == null) {
// A current version, but no installed version
logger.warn(I18NUtil.getMessage(WARN_NO_INSTALL_VERSION, moduleId, moduleCurrentVersion));
// Record the install version
registryService.addProperty(moduleKeyInstalledVersion, currentModuleVersion);
moduleInstallVersion = moduleCurrentVersion;
}
if (// The current version is the same
currentModuleVersion.compareTo(moduleNewVersion) == 0) {
msg = I18NUtil.getMessage(MSG_STARTING, moduleId, moduleNewVersion);
} else if (// Downgrading not supported
currentModuleVersion.compareTo(moduleNewVersion) > 0) {
throw AlfrescoRuntimeException.create(ERR_NO_DOWNGRADE, moduleId, moduleCurrentVersion, moduleNewVersion);
} else // This is an upgrade
{
msg = I18NUtil.getMessage(MSG_UPGRADING, moduleId, moduleNewVersion, moduleCurrentVersion);
}
}
loggerService.info(msg);
// Record the current version
registryService.addProperty(moduleKeyCurrentVersion, moduleNewVersion);
Map<String, ModuleComponent> componentsByName = getComponents(moduleId);
for (ModuleComponent component : componentsByName.values()) {
executeComponent(moduleId, moduleNewVersion, component, executedComponents);
}
// Keep track of the ID as it started successfully
startedModules.add(moduleId);
// Done
if (logger.isDebugEnabled()) {
logger.debug("Started module '" + module + "' including " + executedComponents.size() + "components.");
}
}
Aggregations