use of com.dell.cpsd.paqx.fru.rest.representation.AboutRepresentation in project fru-paqx-parent by dellemc-symphony.
the class AboutResource method root.
@GET
public void root(@Suspended final AsyncResponse asyncResponse) {
asyncResponse.setTimeoutHandler(asyncResponse1 -> asyncResponse1.resume(Response.status(Response.Status.SERVICE_UNAVAILABLE).entity("{\"status\":\"timeout\"}").build()));
asyncResponse.setTimeout(10, TimeUnit.SECONDS);
final AboutRepresentation representation = new AboutRepresentation();
requiredCapabilities().forEach(capability -> representation.addRequiredCapability(capability));
try {
final ListCapabilityProvidersResponse listCapabilityProvidersResponse = this.capabilityRegistryLookupManager.listCapabilityProviders(TimeUnit.SECONDS.toMillis(2L));
for (final CapabilityProvider capabilityProvider : listCapabilityProvidersResponse.getResponse()) {
final String provider = capabilityProvider.getIdentity().getName();
for (final Capability capability : capabilityProvider.getCapabilities()) {
representation.capabilityMetBy(capability.getProfile(), provider);
}
}
} catch (CapabilityRegistryException e) {
asyncResponse.resume(e);
return;
} catch (ServiceTimeoutException e) {
asyncResponse.resume(Response.status(Response.Status.REQUEST_TIMEOUT).build());
return;
}
asyncResponse.resume(Response.ok(representation).build());
LOG.debug("Completed response");
/* nodeDiscovery.discover().thenAccept(nodes ->
{
nodes.stream().forEach(node -> representation.addNode(node.getId(), node.getName(),node.getType()));
asyncResponse.resume(Response.ok(representation).build());
LOG.debug("Completed response");
});*/
LOG.debug("Exiting about resource");
}
Aggregations