use of org.onosproject.core.Application in project onos by opennetworkinglab.
the class ApplicationsWebResource method getApps.
/**
* Get all installed applications.
* Returns array of all installed applications.
*
* @return 200 OK
* @onos.rsModel Applications
*/
@GET
public Response getApps() {
ApplicationAdminService service = get(ApplicationAdminService.class);
Set<Application> apps = service.getApplications();
return ok(encodeArray(Application.class, "applications", apps)).build();
}
use of org.onosproject.core.Application in project onos by opennetworkinglab.
the class ApplicationResource method getIcon.
@Path("{name}/icon")
@GET
@Produces("image/png")
public Response getIcon(@PathParam("name") String name) throws IOException {
ApplicationAdminService service = get(ApplicationAdminService.class);
ApplicationId appId = service.getId(name);
Application app = service.getApplication(appId);
return Response.ok(app.icon()).build();
}
use of org.onosproject.core.Application in project onos by opennetworkinglab.
the class ApplicationsWebResource method health.
/**
* Get application health.
*
* @param name application name
* @return 200 OK with app health in the body; 404 if app is not found
*/
@GET
@Path("{name}/health")
public Response health(@PathParam("name") String name) {
ApplicationAdminService service = get(ApplicationAdminService.class);
ApplicationId appId = service.getId(name);
nullIsNotFound(appId, APP_ID_NOT_FOUND + ": " + name);
Application app = service.getApplication(appId);
nullIsNotFound(app, APP_NOT_FOUND + ": " + appId);
ComponentsMonitorService componentsMonitorService = get(ComponentsMonitorService.class);
boolean ready = componentsMonitorService.isFullyStarted(app.features());
return Response.ok(mapper().createObjectNode().put("message", ready ? APP_READY : APP_PENDING)).build();
}
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