Search in sources :

Example 21 with ModuleDetails

use of org.alfresco.service.cmr.module.ModuleDetails in project alfresco-repository by Alfresco.

the class ModuleManagementTool method listModules.

/**
 * Lists all the currently installed modules in the WAR
 *
 * @param warLocation   the war location
 * @throws ModuleManagementToolException
 */
public void listModules(String warLocation) {
    boolean previous = this.verbose;
    this.verbose = true;
    try {
        List<ModuleDetails> modulesFound = warHelper.listModules(new TFile(warLocation));
        if (modulesFound.size() < 1) {
            outputVerboseMessage("No modules are installed in this WAR file");
        }
        for (Iterator<ModuleDetails> iterator = modulesFound.iterator(); iterator.hasNext(); ) {
            ModuleDetails moduleDetails = iterator.next();
            outputVerboseMessage("Module '" + moduleDetails.getId() + "' installed in '" + warLocation + "'");
            outputVerboseMessage("   Title:        " + moduleDetails.getTitle(), true);
            outputVerboseMessage("   Version:      " + moduleDetails.getModuleVersionNumber(), true);
            outputVerboseMessage("   Install Date: " + moduleDetails.getInstallDate(), true);
            outputVerboseMessage("   Description:   " + moduleDetails.getDescription(), true);
        }
    } finally {
        this.verbose = previous;
    }
}
Also used : ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails)

Example 22 with ModuleDetails

use of org.alfresco.service.cmr.module.ModuleDetails in project alfresco-repository by Alfresco.

the class ConfigurationDataCollector method collectData.

@Override
public List<HBData> collectData() {
    // Collect repository configuration data
    logger.debug("Preparing repository configuration data...");
    Map<String, Object> configurationValues = new HashMap<>();
    configurationValues.put("smartFoldersEnabled", smartFoldersBundle.isEnabled());
    boolean readOnly = transactionService.getRetryingTransactionHelper().doInTransaction(() -> repoUsageComponent.getUsage().isReadOnly(), true);
    configurationValues.put("serverReadOnly", readOnly);
    configurationValues.put("serverMode", serverModeProvider.getServerMode().toString());
    boolean ftpEnabled = Boolean.valueOf(fileServersSubsystem.getProperty("ftp.enabled"));
    configurationValues.put("ftpEnabled", ftpEnabled);
    configurationValues.put("webDAVEnabled", webdavService.getEnabled());
    configurationValues.put("thumbnailsEnabled", thumbnailService.getThumbnailsEnabled());
    boolean activitiesFeedEnabled = Boolean.valueOf(activitiesFeedSubsystem.getProperty("activities.feed.notifier.enabled"));
    configurationValues.put("activitiesFeedEnabled", activitiesFeedEnabled);
    configurationValues.put("activitiEngineEnabled", workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID));
    boolean inboundEnabled = Boolean.valueOf(inboundSMTPSubsystem.getProperty("email.inbound.enabled"));
    boolean emailServerEnabled = Boolean.valueOf(inboundSMTPSubsystem.getProperty("email.server.enabled"));
    boolean inboundServerEnabled = inboundEnabled && emailServerEnabled;
    configurationValues.put("inboundServerEnabled", inboundServerEnabled);
    boolean imapEnabled = Boolean.valueOf(imapSubsystem.getProperty("imap.server.enabled"));
    configurationValues.put("imapEnabled", imapEnabled);
    Map<String, Object> replicationInfo = new HashMap<>();
    replicationInfo.put("enabled", replicationSubsystem.getProperty("replication.enabled"));
    replicationInfo.put("readOnly", replicationSubsystem.getProperty("replication.transfer.readonly"));
    configurationValues.put("replication", replicationInfo);
    if (dataSource instanceof BasicDataSource) {
        Map<String, Object> db = new HashMap<>();
        db.put("maxConnections", ((BasicDataSource) dataSource).getMaxActive());
        configurationValues.put("db", db);
    }
    // Modules information
    List<ModuleDetails> rawInstalledModules = moduleService.getAllModules();
    Map<String, Object> modules = new HashMap<>();
    Map<String, Object> installedModules = new HashMap<>();
    installedModules.put("count", rawInstalledModules.size());
    Map<String, Object> installedModulesList = new HashMap<>();
    for (ModuleDetails md : rawInstalledModules) {
        Map<String, Object> moduleInfo = new HashMap<>();
        moduleInfo.put("version", md.getModuleVersionNumber().toString());
        installedModulesList.put(md.getId(), moduleInfo);
    }
    if (!installedModulesList.isEmpty()) {
        installedModules.put("modules", installedModulesList);
    }
    modules.put("installed", installedModules);
    // Missing modules information
    List<ModuleDetails> rawMissingModules = getMissingModules();
    Map<String, Object> missingModules = new HashMap<>();
    Map<String, Object> missingModulesList = new HashMap<>();
    for (ModuleDetails md : rawMissingModules) {
        Map<String, Object> moduleInfo = new HashMap<>();
        moduleInfo.put("version", md.getModuleVersionNumber().toString());
        missingModulesList.put(md.getId(), moduleInfo);
    }
    if (!missingModulesList.isEmpty()) {
        missingModules.put("modules", missingModulesList);
        modules.put("missing", missingModules);
    }
    configurationValues.put("module", modules);
    // Audit information
    Map<String, Object> audit = new HashMap<>();
    audit.put("enabled", auditService.isAuditEnabled());
    Map<String, Object> auditAppList = new HashMap<>();
    Map<String, AuditService.AuditApplication> rawAppList = transactionService.getRetryingTransactionHelper().doInTransaction(() -> auditService.getAuditApplications(), true);
    for (Map.Entry<String, AuditService.AuditApplication> entry : rawAppList.entrySet()) {
        AuditService.AuditApplication app = entry.getValue();
        Map<String, Object> appInfo = new HashMap<>();
        appInfo.put("enabled", app.isEnabled());
        // replace spaces with hyphens
        String appName = entry.getKey().replace(" ", "-");
        auditAppList.put(appName, appInfo);
    }
    if (!auditAppList.isEmpty()) {
        audit.put("apps", auditAppList);
    }
    configurationValues.put("audit", audit);
    // Authentication chain
    String chainString = authenticationSubsystem.getProperty("chain");
    configurationValues.put("authenticationChain", chainString);
    HBData configurationData = new HBData(this.currentRepoDescriptorDAO.getDescriptor().getId(), this.getCollectorId(), this.getCollectorVersion(), new Date(), configurationValues);
    return Arrays.asList(configurationData);
}
Also used : HashMap(java.util.HashMap) ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails) Date(java.util.Date) HBData(org.alfresco.heartbeat.datasender.HBData) BasicDataSource(org.apache.commons.dbcp.BasicDataSource) HashMap(java.util.HashMap) Map(java.util.Map) AuditService(org.alfresco.service.cmr.audit.AuditService)

Example 23 with ModuleDetails

use of org.alfresco.service.cmr.module.ModuleDetails in project alfresco-repository by Alfresco.

the class ModuleDetailsImplTest method testDependencyChecks.

public void testDependencyChecks() {
    Properties props = new Properties();
    props.putAll(DEFAULT_PROPS);
    ModuleDetails details = new ModuleDetailsImpl(props);
    Properties tempProperties = new Properties();
    tempProperties.setProperty(ModuleDetails.PROP_ID, "a");
    tempProperties.setProperty(ModuleDetails.PROP_TITLE, "A");
    tempProperties.setProperty(ModuleDetails.PROP_DESCRIPTION, "A description");
    tempProperties.setProperty(ModuleDetails.PROP_VERSION, "1.0.0");
    ModuleDetails tempDetails = new ModuleDetailsImpl(tempProperties);
    List<ModuleDependency> dependencies = details.getDependencies();
    assertEquals("Incorrect number of dependencies", 8, dependencies.size());
    for (ModuleDependency dependency : dependencies) {
        if (dependency.getDependencyId().equals(tempDetails.getId())) {
            // It should not match
            assertFalse("No match expected", dependency.isValidDependency(tempDetails));
        }
    }
}
Also used : ModuleDependency(org.alfresco.service.cmr.module.ModuleDependency) ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails) Properties(java.util.Properties)

Example 24 with ModuleDetails

use of org.alfresco.service.cmr.module.ModuleDetails in project alfresco-repository by Alfresco.

the class WarHelperImplTest method testCheckCompatibleVersionUsingManifest.

@Test
public void testCheckCompatibleVersionUsingManifest() throws IOException {
    // Now check the compatible versions using the manifest
    TFile theWar = getFile(".war", "module/share-3.4.11.war");
    ModuleDetails installingModuleDetails = new ModuleDetailsImpl("test_it", new ModuleVersionNumber("9999"), "Test Mod", "Testing module");
    installingModuleDetails.setRepoVersionMin(new VersionNumber("10.1"));
    try {
        this.checkCompatibleVersionUsingManifest(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.checkCompatibleVersionUsingManifest(theWar, installingModuleDetails);
    installingModuleDetails.setRepoVersionMax(new VersionNumber("3.0"));
    try {
        this.checkCompatibleVersionUsingManifest(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.checkCompatibleVersionUsingManifest(theWar, installingModuleDetails);
    // current war version
    installingModuleDetails.setRepoVersionMin(new VersionNumber("3.4.11"));
    // current war version
    installingModuleDetails.setRepoVersionMax(new VersionNumber("3.4.11"));
    // does not throw exception
    this.checkCompatibleVersionUsingManifest(theWar, installingModuleDetails);
    // current war version
    installingModuleDetails.setRepoVersionMin(new VersionNumber("3.4.7"));
    // current war version
    installingModuleDetails.setRepoVersionMax(new VersionNumber("3.4.11"));
    // does not throw exception
    this.checkCompatibleVersionUsingManifest(theWar, installingModuleDetails);
    try {
        // current war version
        installingModuleDetails.setRepoVersionMin(new VersionNumber("3.4.0"));
        // current war version
        installingModuleDetails.setRepoVersionMax(new VersionNumber("3.4.10"));
        // does not throw exception
        this.checkCompatibleVersionUsingManifest(theWar, installingModuleDetails);
        // should never get here
        fail("Should not pass as current version is 3.4.11 and the max value is 3.4.10");
    } catch (ModuleManagementToolException exception) {
        assertTrue(exception.getMessage().contains("cannot be installed on a war version greater than 3.4.10"));
    }
    theWar = getFile(".war", "module/share-4.2.a.war");
    installingModuleDetails = new ModuleDetailsImpl("test_it", new ModuleVersionNumber("9999"), "Test Mod", "Testing module");
    installingModuleDetails.setRepoVersionMin(new VersionNumber("101.1"));
    // this should fail BUT we are using a non-numeric version number so instead it passes without validation
    this.checkCompatibleVersionUsingManifest(theWar, installingModuleDetails);
    theWar = getFile(".war", "module/alfresco-4.2.a.war");
    // this should fail BUT we are using a non-numeric version number so instead it passes without validation
    this.checkCompatibleVersionUsingManifest(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 25 with ModuleDetails

use of org.alfresco.service.cmr.module.ModuleDetails 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"));
    }
}
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)

Aggregations

ModuleDetails (org.alfresco.service.cmr.module.ModuleDetails)27 TFile (de.schlichtherle.truezip.file.TFile)9 Properties (java.util.Properties)7 ModuleDetailsImpl (org.alfresco.repo.module.ModuleDetailsImpl)7 Test (org.junit.Test)7 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 ModuleVersionNumber (org.alfresco.repo.module.ModuleVersionNumber)4 VersionNumber (org.alfresco.util.VersionNumber)4 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)3 ModuleDependency (org.alfresco.service.cmr.module.ModuleDependency)3 TFileInputStream (de.schlichtherle.truezip.file.TFileInputStream)2 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 ModulePackage (org.alfresco.rest.api.model.ModulePackage)2 AuditService (org.alfresco.service.cmr.audit.AuditService)2 BasicDataSource (org.apache.commons.dbcp.BasicDataSource)2 FsSyncException (de.schlichtherle.truezip.fs.FsSyncException)1 BufferedInputStream (java.io.BufferedInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1