Search in sources :

Example 1 with ModuleVersionNumber

use of org.alfresco.repo.module.ModuleVersionNumber in project records-management by Alfresco.

the class ModulePatchComponent method getModuleVersionNumber.

/**
 * Helper method to get the ModuleVersionNumber.
 */
private ModuleVersionNumber getModuleVersionNumber(String registryProperty) {
    String moduleId = modulePatchExecuter.getModuleId();
    RegistryKey moduleKeyVersion = new RegistryKey(ModuleComponentHelper.URI_MODULES_1_0, new String[] { REGISTRY_PATH_MODULES, moduleId, registryProperty });
    Serializable moduleVersion = this.registryService.getProperty(moduleKeyVersion);
    return new ModuleVersionNumber(moduleVersion.toString());
}
Also used : Serializable(java.io.Serializable) ModuleVersionNumber(org.alfresco.repo.module.ModuleVersionNumber) RegistryKey(org.alfresco.repo.admin.registry.RegistryKey)

Example 2 with ModuleVersionNumber

use of org.alfresco.repo.module.ModuleVersionNumber in project records-management by Alfresco.

the class ModulePatchComponent method executeInternal.

/**
 * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal()
 */
@Override
protected void executeInternal() {
    ModuleVersionNumber moduleInstalledVersionNumber = getModuleVersionNumber(REGISTRY_PROPERTY_INSTALLED_VERSION);
    ModuleVersionNumber moduleCurrentVersionNumber = getModuleVersionNumber(REGISTRY_PROPERTY_CURRENT_VERSION);
    String moduleName = getName();
    if (isVersionLaterThan(moduleInstalledVersionNumber, moduleCurrentVersionNumber)) {
        LOGGER.info("Module patch component '{}' is skipped for upgrade from version {} to version {}", moduleName, moduleInstalledVersionNumber, moduleCurrentVersionNumber);
    } else {
        try {
            LOGGER.info("Module patch component '{}' is executing ...", moduleName);
            // execute path within an isolated transaction
            retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() {

                @Override
                public Void execute() {
                    behaviourFilter.disableBehaviour();
                    try {
                        executePatch();
                    } finally {
                        behaviourFilter.enableBehaviour();
                    }
                    return null;
                }
            }, false, true);
            LOGGER.info(" ... completed module patch '{}'", moduleName);
        } catch (Exception exception) {
            // record the exception otherwise it gets swallowed
            LOGGER.info("  ... error encountered.  {}", exception.getMessage(), exception);
            throw exception;
        }
    }
}
Also used : ModuleVersionNumber(org.alfresco.repo.module.ModuleVersionNumber) RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper)

Example 3 with ModuleVersionNumber

use of org.alfresco.repo.module.ModuleVersionNumber 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 4 with ModuleVersionNumber

use of org.alfresco.repo.module.ModuleVersionNumber in project alfresco-repository by Alfresco.

the class ModuleComponentHelperTest method testStartComponentsV10.

public void testStartComponentsV10() {
    ModuleVersionNumber moduleVersion = new ModuleVersionNumber("1.0");
    startComponents(moduleVersion);
}
Also used : ModuleVersionNumber(org.alfresco.repo.module.ModuleVersionNumber)

Example 5 with ModuleVersionNumber

use of org.alfresco.repo.module.ModuleVersionNumber 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)

Aggregations

ModuleVersionNumber (org.alfresco.repo.module.ModuleVersionNumber)15 ModuleDetails (org.alfresco.service.cmr.module.ModuleDetails)4 VersionNumber (org.alfresco.util.VersionNumber)4 TFile (de.schlichtherle.truezip.file.TFile)3 ModuleDetailsImpl (org.alfresco.repo.module.ModuleDetailsImpl)3 Test (org.junit.Test)3 Serializable (java.io.Serializable)2 RegistryKey (org.alfresco.repo.admin.registry.RegistryKey)2 FsSyncException (de.schlichtherle.truezip.fs.FsSyncException)1 IOException (java.io.IOException)1 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)1 RegistryService (org.alfresco.repo.admin.registry.RegistryService)1 ModuleServiceImpl (org.alfresco.repo.module.ModuleServiceImpl)1 ModuleManagementToolException (org.alfresco.repo.module.tool.ModuleManagementToolException)1 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)1 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 ApplicationContext (org.springframework.context.ApplicationContext)1 Resource (org.springframework.core.io.Resource)1 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)1