Search in sources :

Example 51 with Application

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

the class ApplicationNodeImplTest method testCompareToIAE.

/**
     * Tests the {@link ApplicationNodeImpl#compareTo(ApplicationNode)} method for the case
     * where the parameter node is null
     */
@Test(expected = IllegalArgumentException.class)
public void testCompareToIAE() {
    Application testApp = mock(Application.class);
    ApplicationNodeImpl testNode = new ApplicationNodeImpl(testApp);
    testNode.compareTo(null);
}
Also used : Application(org.codice.ddf.admin.application.service.Application) Test(org.junit.Test)

Example 52 with Application

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

the class ApplicationNodeImplTest method testHashCode.

/**
     * Tests the {@link ApplicationNodeImpl#hashCode()} method
     */
@Test
public void testHashCode() {
    try {
        Repository testRepo = new RepositoryImpl(ApplicationNodeImpl.class.getClassLoader().getResource(FEATURES_FILE_NAME).toURI());
        Application testApp = new ApplicationImpl(testRepo);
        ApplicationNode testNode = new ApplicationNodeImpl(testApp);
        assertEquals(testApp.hashCode(), testNode.hashCode());
    } catch (Exception e) {
        LOGGER.info("Exception: ", e);
        fail();
    }
}
Also used : Repository(org.apache.karaf.features.Repository) RepositoryImpl(org.apache.karaf.features.internal.service.RepositoryImpl) ApplicationNode(org.codice.ddf.admin.application.service.ApplicationNode) Application(org.codice.ddf.admin.application.service.Application) Test(org.junit.Test)

Example 53 with Application

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

the class StatusApplicationCommand method doExecute.

@Override
protected void doExecute(ApplicationService applicationService) throws ApplicationServiceException {
    Application application = applicationService.getApplication(appName);
    if (application != null) {
        ApplicationStatus appStatus = applicationService.getApplicationStatus(application);
        console.println(application.getName());
        console.println("\nCurrent State is: " + appStatus.getState().toString());
        console.println("\nFeatures Located within this Application:");
        for (Feature curFeature : application.getFeatures()) {
            console.println("\t" + curFeature.getName());
        }
        console.println("\nRequired Features Not Started");
        if (appStatus.getErrorFeatures().isEmpty()) {
            console.print(Ansi.ansi().fg(Ansi.Color.GREEN).toString());
            console.println("\tNONE");
            console.print(Ansi.ansi().reset().toString());
        } else {
            for (Feature curFeature : appStatus.getErrorFeatures()) {
                console.print(Ansi.ansi().fg(Ansi.Color.RED).toString());
                console.println("\t" + curFeature.getName());
                console.print(Ansi.ansi().reset().toString());
            }
        }
        console.println("\nRequired Bundles Not Started");
        if (appStatus.getErrorBundles().isEmpty()) {
            console.print(Ansi.ansi().fg(Ansi.Color.GREEN).toString());
            console.println("\tNONE");
            console.print(Ansi.ansi().reset().toString());
        } else {
            for (Bundle curBundle : appStatus.getErrorBundles()) {
                console.print(Ansi.ansi().fg(Ansi.Color.RED).toString());
                console.println("\t[" + curBundle.getBundleId() + "]\t" + curBundle.getSymbolicName());
                console.print(Ansi.ansi().reset().toString());
            }
        }
    } else {
        console.println("No application found with name " + appName);
    }
    return;
}
Also used : Bundle(org.osgi.framework.Bundle) ApplicationStatus(org.codice.ddf.admin.application.service.ApplicationStatus) Application(org.codice.ddf.admin.application.service.Application) Feature(org.apache.karaf.features.Feature)

Example 54 with Application

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

the class ListApplicationCommand method doExecute.

@Override
protected void doExecute(ApplicationService applicationService) throws ApplicationServiceException {
    Set<Application> applications = applicationService.getApplications();
    console.printf("%s%10s%n", "State", "Name");
    for (Application curApp : applications) {
        ApplicationStatus appStatus = applicationService.getApplicationStatus(curApp);
        // aggregator 'apps')
        if (!curApp.getFeatures().isEmpty()) {
            console.print("[");
            switch(appStatus.getState()) {
                case ACTIVE:
                    console.print(Ansi.ansi().fg(Ansi.Color.GREEN).toString());
                    break;
                case FAILED:
                    console.print(Ansi.ansi().fg(Ansi.Color.RED).toString());
                    break;
                case INACTIVE:
                    // don't set a color
                    break;
                case UNKNOWN:
                    console.print(Ansi.ansi().fg(Ansi.Color.YELLOW).toString());
                    break;
                default:
                    break;
            }
            console.print(StringUtils.rightPad(appStatus.getState().toString(), STATUS_COLUMN_LENGTH));
            console.print(Ansi.ansi().reset().toString());
            console.println("] " + curApp.getName());
        }
    }
    return;
}
Also used : ApplicationStatus(org.codice.ddf.admin.application.service.ApplicationStatus) Application(org.codice.ddf.admin.application.service.Application)

Example 55 with Application

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

the class ApplicationServiceBean method convertApplicationNode.

private Map<String, Object> convertApplicationNode(ApplicationNode application) {
    LOGGER.debug("Converting {} to a map", application.getApplication().getName());
    Map<String, Object> appMap = new HashMap<String, Object>();
    Application internalApplication = application.getApplication();
    appMap.put(MAP_NAME, internalApplication.getName());
    appMap.put(MAP_VERSION, internalApplication.getVersion());
    appMap.put(MAP_DESCRIPTION, internalApplication.getDescription());
    appMap.put(MAP_STATE, application.getStatus().getState().toString());
    appMap.put(MAP_URI, internalApplication.getURI().toString());
    List<Map<String, Object>> children = new ArrayList<Map<String, Object>>();
    for (ApplicationNode curNode : application.getChildren()) {
        children.add(convertApplicationNode(curNode));
    }
    appMap.put(MAP_CHILDREN, children);
    return appMap;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ApplicationNode(org.codice.ddf.admin.application.service.ApplicationNode) Application(org.codice.ddf.admin.application.service.Application) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Application (org.codice.ddf.admin.application.service.Application)55 Test (org.junit.Test)43 HashSet (java.util.HashSet)28 ApplicationService (org.codice.ddf.admin.application.service.ApplicationService)26 Repository (org.apache.karaf.features.Repository)21 FeaturesService (org.apache.karaf.features.FeaturesService)19 Feature (org.apache.karaf.features.Feature)14 ApplicationServiceException (org.codice.ddf.admin.application.service.ApplicationServiceException)13 ApplicationStatus (org.codice.ddf.admin.application.service.ApplicationStatus)13 ApplicationNode (org.codice.ddf.admin.application.service.ApplicationNode)11 ArrayList (java.util.ArrayList)9 RepositoryImpl (org.apache.karaf.features.internal.service.RepositoryImpl)7 HashMap (java.util.HashMap)5 Logger (org.slf4j.Logger)5 Appender (ch.qos.logback.core.Appender)4 URI (java.net.URI)4 TreeSet (java.util.TreeSet)4 ArgumentMatcher (org.mockito.ArgumentMatcher)4 Mockito.anyString (org.mockito.Mockito.anyString)4 SecurityServiceException (ddf.security.service.SecurityServiceException)3