list.addAll(resultNode.getEnabledChildNodes());
} else {
list.add(resultNode);
}
constructEntity(list, ar);
responseBuilder.entity(new ActionReportResult(ar));
} else {
//No monitoring data, so nothing to list
responseBuilder.status(NOT_FOUND);
responseBuilder.entity(new ActionReportResult(ar));
}
} else { //firstPathElement != currentInstanceName => A proxy request
if(isRunningOnDAS) { //Attempt to forward to instance if running on Das
//TODO validate that firstPathElement corresponds to a valid server name
Properties proxiedResponse = new MonitoringProxyImpl().proxyRequest(uriInfo, habitat);
ar.setExtraProperties(proxiedResponse);
responseBuilder.entity(new ActionReportResult(ar));
} else { // Not running on DAS and firstPathElement != currentInstanceName => Reject the request as invalid
return Response.status(FORBIDDEN).build();
}
}
} else { // Called for /monitoring/domain/
List<TreeNode> list = new ArrayList<TreeNode>();
list.add(rootNode); //Add currentInstance to response
constructEntity(list, ar);
if(isRunningOnDAS) { // Add links to instances from the cluster
Domain domain = habitat.getComponent(Domain.class);
Map<String, String> links = (Map<String, String>) ar.getExtraProperties().get("childResources");
for (Server s : domain.getServers().getServer()) {
if (!s.getName().equals("server")) {// add all non 'server' instances
links.put(s.getName(), getElementLink(uriInfo, s.getName()));
}
}
}
responseBuilder.entity(new ActionReportResult(ar));
}
return responseBuilder.build();
}