Search in sources :

Example 11 with ModuleDetails

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;
}
Also used : TFileInputStream(de.schlichtherle.truezip.file.TFileInputStream) FileNotFoundException(java.io.FileNotFoundException) ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails) IOException(java.io.IOException)

Example 12 with ModuleDetails

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;
}
Also used : ModulePackage(org.alfresco.rest.api.model.ModulePackage) ArrayList(java.util.ArrayList) ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails)

Example 13 with ModuleDetails

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());
}
Also used : ModuleDetailsImpl(org.alfresco.repo.module.ModuleDetailsImpl) ModulePackage(org.alfresco.rest.api.model.ModulePackage) ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails) Test(org.junit.Test) ModuleDetailsImplTest(org.alfresco.repo.module.ModuleDetailsImplTest)

Example 14 with ModuleDetails

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);
    }
}
Also used : ModuleDependency(org.alfresco.service.cmr.module.ModuleDependency) ArrayList(java.util.ArrayList) ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails)

Example 15 with ModuleDetails

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

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