use of org.onosproject.core.Application in project onos by opennetworkinglab.
the class ReviewCommand method doExecute.
@Override
protected void doExecute() {
ApplicationAdminService applicationAdminService = get(ApplicationAdminService.class);
ApplicationId appId = applicationAdminService.getId(name);
if (appId == null) {
print("No such application: %s", name);
return;
}
Application app = applicationAdminService.getApplication(appId);
SecurityAdminService smService = SecurityUtil.getSecurityService();
if (smService == null) {
print("Security Mode is disabled");
return;
}
if (accept == null) {
smService.review(appId);
printPolicy(smService, app);
} else if ("accept".equals(accept.trim())) {
smService.acceptPolicy(appId);
printPolicy(smService, app);
} else {
print("Unknown command");
}
}
use of org.onosproject.core.Application in project onos by opennetworkinglab.
the class SimpleApplicationStore method remove.
@Override
public void remove(ApplicationId appId) {
Application app = apps.remove(appId);
if (app != null) {
states.remove(appId);
delegate.notify(new ApplicationEvent(APP_UNINSTALLED, app));
purgeApplication(app.id().name());
}
}
use of org.onosproject.core.Application in project onos by opennetworkinglab.
the class SimpleApplicationStoreTest method deactivate.
@Test
public void deactivate() {
Application app = createTestApp();
store.deactivate(app.id());
assertEquals("incorrect app count", 1, store.getApplications().size());
assertEquals("incorrect app state", INSTALLED, store.getState(app.id()));
assertEquals("incorrect event type", APP_DEACTIVATED, delegate.event.type());
assertEquals("incorrect event app", app, delegate.event.subject());
}
use of org.onosproject.core.Application in project onos by opennetworkinglab.
the class ApplicationsListCommand method doExecute.
@Override
protected void doExecute() {
ApplicationService service = get(ApplicationService.class);
List<Application> apps = newArrayList(service.getApplications());
if (sortByName) {
apps.sort(Comparator.comparing(app -> app.id().name()));
} else {
Collections.sort(apps, Comparators.APP_COMPARATOR);
}
if (outputJson()) {
print("%s", json(service, apps));
} else {
for (Application app : apps) {
boolean isActive = service.getState(app.id()) == ACTIVE;
if (activeOnly && isActive || !activeOnly) {
if (shortOnly) {
String shortDescription = app.title().equals(app.id().name()) ? app.description().replaceAll("[\\r\\n]", " ").replaceAll(" +", " ") : app.title();
print(SHORT_FMT, isActive ? "*" : " ", app.id().id(), app.id().name(), app.version(), shortDescription);
} else {
print(FMT, isActive ? "*" : " ", app.id().id(), app.id().name(), app.version(), app.origin(), app.category(), app.description(), app.features(), app.featuresRepo().map(URI::toString).orElse(""), app.requiredApps(), app.permissions(), app.url());
}
}
}
}
}
use of org.onosproject.core.Application in project onos by opennetworkinglab.
the class ApplicationsListCommand method json.
private JsonNode json(ApplicationService service, List<Application> apps) {
ObjectMapper mapper = new ObjectMapper();
ArrayNode result = mapper.createArrayNode();
for (Application app : apps) {
boolean isActive = service.getState(app.id()) == ACTIVE;
if (activeOnly && isActive || !activeOnly) {
result.add(jsonForEntity(app, Application.class));
}
}
return result;
}
Aggregations