Search in sources :

Example 1 with VersionNumber

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);
}
Also used : TFile(de.schlichtherle.truezip.file.TFile) ModuleDetailsImpl(org.alfresco.repo.module.ModuleDetailsImpl) ModuleVersionNumber(org.alfresco.repo.module.ModuleVersionNumber) ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails) VersionNumber(org.alfresco.util.VersionNumber) ModuleVersionNumber(org.alfresco.repo.module.ModuleVersionNumber) Test(org.junit.Test)

Example 2 with VersionNumber

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);
}
Also used : ModuleVersionNumber(org.alfresco.repo.module.ModuleVersionNumber) VersionNumber(org.alfresco.util.VersionNumber) ModuleVersionNumber(org.alfresco.repo.module.ModuleVersionNumber) ModuleManagementToolException(org.alfresco.repo.module.tool.ModuleManagementToolException)

Example 3 with VersionNumber

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;
}
Also used : VersionNumber(org.alfresco.util.VersionNumber) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Example 4 with VersionNumber

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);
    }
}
Also used : TFile(de.schlichtherle.truezip.file.TFile) Properties(java.util.Properties) VersionNumber(org.alfresco.util.VersionNumber)

Example 5 with VersionNumber

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.");
    }
}
Also used : Serializable(java.io.Serializable) ModuleDependency(org.alfresco.service.cmr.module.ModuleDependency) ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails) VersionNumber(org.alfresco.util.VersionNumber) RegistryKey(org.alfresco.repo.admin.registry.RegistryKey)

Aggregations

VersionNumber (org.alfresco.util.VersionNumber)9 TFile (de.schlichtherle.truezip.file.TFile)4 ModuleVersionNumber (org.alfresco.repo.module.ModuleVersionNumber)4 ModuleDetails (org.alfresco.service.cmr.module.ModuleDetails)4 ModuleDetailsImpl (org.alfresco.repo.module.ModuleDetailsImpl)3 Test (org.junit.Test)3 Serializable (java.io.Serializable)1 Properties (java.util.Properties)1 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)1 RegistryKey (org.alfresco.repo.admin.registry.RegistryKey)1 ModuleManagementToolException (org.alfresco.repo.module.tool.ModuleManagementToolException)1 ModuleDependency (org.alfresco.service.cmr.module.ModuleDependency)1