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;
}
}
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);
}
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));
}
}
}
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);
}
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"));
}
}
Aggregations