use of org.alfresco.service.cmr.module.ModuleDetails in project alfresco-repository by Alfresco.
the class ModuleDetailsHelper method createModuleDetailsFromPropertyLocation.
/**
* Creates a module details helper object based on a file location.
*
* @param location file location
* @param log logger
* @return Returns the module details or null if the location points to nothing
* @throws IOException
*/
public static ModuleDetails createModuleDetailsFromPropertyLocation(String location, LogOutput log) throws IOException {
ModuleDetails result = null;
TFileInputStream is;
try {
is = new TFileInputStream(location);
} catch (FileNotFoundException error) {
error.printStackTrace(System.out);
throw new ModuleManagementToolException("Unable to load module details from property file. File Not Found, " + error.getMessage(), error);
}
try {
result = createModuleDetailsFromPropertiesStream(is, log);
} catch (IOException exception) {
throw new ModuleManagementToolException("Unable to load module details from property file." + exception.getMessage(), exception);
} finally {
// ALWAYS close the stream!
is.close();
}
return result;
}
use of org.alfresco.service.cmr.module.ModuleDetails in project alfresco-remote-api by Alfresco.
the class DiscoveryApiWebscript method getModules.
private List<ModulePackage> getModules() {
List<ModuleDetails> details = moduleService.getAllModules();
if (details.isEmpty()) {
return null;
}
List<ModulePackage> packages = new ArrayList<>(details.size());
for (ModuleDetails detail : details) {
packages.add(ModulePackage.fromModuleDetails(detail));
}
return packages;
}
use of org.alfresco.service.cmr.module.ModuleDetails in project alfresco-remote-api by Alfresco.
the class ModulePackageTest method testConstructor.
@Test
public void testConstructor() throws IOException {
ModuleDetails details = new ModuleDetailsImpl(props);
ModulePackage modulePackage = ModulePackage.fromModuleDetails(details);
assertNotNull(modulePackage);
assertEquals(props.getProperty(ModuleDetails.PROP_ID), modulePackage.getId());
assertEquals(props.getProperty(ModuleDetails.PROP_VERSION), modulePackage.getVersion());
assertEquals(props.getProperty(ModuleDetails.PROP_REPO_VERSION_MIN), modulePackage.getVersionMin());
assertEquals(props.getProperty(ModuleDetails.PROP_REPO_VERSION_MAX), modulePackage.getVersionMax());
assertEquals(props.getProperty(ModuleDetails.PROP_INSTALL_STATE), modulePackage.getInstallState().toString());
}
use of org.alfresco.service.cmr.module.ModuleDetails in project alfresco-repository by Alfresco.
the class WarHelperImpl method checkModuleDependencies.
@Override
public void checkModuleDependencies(TFile war, ModuleDetails installingModuleDetails) {
// Check that the target war has the necessary dependencies for this install
List<ModuleDependency> installingModuleDependencies = installingModuleDetails.getDependencies();
List<ModuleDependency> missingDependencies = new ArrayList<ModuleDependency>(0);
for (ModuleDependency dependency : installingModuleDependencies) {
String dependencyId = dependency.getDependencyId();
ModuleDetails dependencyModuleDetails = getModuleDetails(war, dependencyId);
// Check the dependency. The API specifies that a null returns false, so no null check is required
if (!dependency.isValidDependency(dependencyModuleDetails)) {
missingDependencies.add(dependency);
continue;
}
}
if (missingDependencies.size() > 0) {
throw new ModuleManagementToolException("The following modules must first be installed: " + missingDependencies);
}
}
use of org.alfresco.service.cmr.module.ModuleDetails in project alfresco-repository by Alfresco.
the class WarHelperImpl method getModuleDetails.
/**
* Gets the module details for the specified module from the war.
* @param war a valid war file or exploded directory from a war
* @param moduleId String
* @return ModuleDetails
*/
protected ModuleDetails getModuleDetails(TFile war, String moduleId) {
ModuleDetails moduleDets = null;
TFile theFile = getModuleDetailsFile(war, moduleId);
if (theFile != null && theFile.exists()) {
moduleDets = new ModuleDetailsImpl(loadProperties(theFile));
}
return moduleDets;
}
Aggregations