Search in sources :

Example 26 with ApplicationServiceException

use of org.codice.ddf.admin.application.service.ApplicationServiceException in project ddf by codice.

the class ApplicationFileInstaller method getAppDetails.

/**
     * Detects and Builds an AppDetail based on the zip file provided.
     *
     * To start the process, we find the features.xml file. Once we find it within the zip file, we
     * specifically get a stream to that file. Next we parse through the features.xml and extract
     * the version/appname.
     *
     * @param applicationFile
     *            the file to detect appname and version from.
     * @return {@link ZipFileApplicationDetails} containing appname and version.
     * @throws ApplicationServiceException
     *             any errors that happening during extracting the appname/version from the zipfile.
     */
public static ZipFileApplicationDetails getAppDetails(File applicationFile) throws ApplicationServiceException {
    ZipFile appZip = null;
    try {
        appZip = new ZipFile(applicationFile);
        LOGGER.debug("Extracting version and application name from zipfile {}.", applicationFile.getAbsolutePath());
        ZipEntry featureFileEntry = getFeatureFile(appZip);
        return getAppDetailsFromFeature(appZip, featureFileEntry);
    } catch (IOException | SAXException | ParserConfigurationException e) {
        throw new ApplicationServiceException("Could not get application details of the provided zipfile.", e);
    } finally {
        IOUtils.closeQuietly(appZip);
    }
}
Also used : ApplicationServiceException(org.codice.ddf.admin.application.service.ApplicationServiceException) ZipFile(java.util.zip.ZipFile) ZipEntry(java.util.zip.ZipEntry) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Example 27 with ApplicationServiceException

use of org.codice.ddf.admin.application.service.ApplicationServiceException in project ddf by codice.

the class ApplicationServiceBean method init.

/**
     * Initializes the initial variables and registers the class to the MBean
     * server. <br/>
     * <br/>
     * <b>NOTE: This should be run before any other operations are performed.
     * Operations will NOT be usable until this is called (and until destroy()
     * is called).</b>
     *
     * @throws ApplicationServiceException if an error occurs during registration.
     */
public void init() throws ApplicationServiceException {
    try {
        try {
            LOGGER.debug("Registering application service MBean under object name: {}", objectName.toString());
            mBeanServer.registerMBean(this, objectName);
        } catch (InstanceAlreadyExistsException iaee) {
            // Try to remove and re-register
            LOGGER.debug("Re-registering Application Service MBean");
            mBeanServer.unregisterMBean(objectName);
            mBeanServer.registerMBean(this, objectName);
        }
    } catch (Exception e) {
        LOGGER.warn("Could not register mbean.", e);
        throw new ApplicationServiceException(e);
    }
}
Also used : ApplicationServiceException(org.codice.ddf.admin.application.service.ApplicationServiceException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) URISyntaxException(java.net.URISyntaxException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) ApplicationServiceException(org.codice.ddf.admin.application.service.ApplicationServiceException) MalformedObjectNameException(javax.management.MalformedObjectNameException)

Aggregations

ApplicationServiceException (org.codice.ddf.admin.application.service.ApplicationServiceException)27 Test (org.junit.Test)14 Application (org.codice.ddf.admin.application.service.Application)9 ApplicationService (org.codice.ddf.admin.application.service.ApplicationService)7 Logger (org.slf4j.Logger)7 Appender (ch.qos.logback.core.Appender)6 SecurityServiceException (ddf.security.service.SecurityServiceException)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 URI (java.net.URI)6 ArgumentMatcher (org.mockito.ArgumentMatcher)6 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)6 File (java.io.File)5 HashSet (java.util.HashSet)5 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Response (javax.ws.rs.core.Response)3 Feature (org.apache.karaf.features.Feature)3 Repository (org.apache.karaf.features.Repository)3