@GET
//@Produces({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML,MediaType.TEXT_HTML})
public List<TreeNode> getChildNodes() {
List<TreeNode> list = new ArrayList<TreeNode>();
MonitoringRuntimeDataRegistry monitoringRegistry = RestService.getMonitoringRegistry();
if (path == null) {
//FIXME - Return appropriate message to the user
//return Response.status(400).entity("match pattern is invalid or null").build();
return list;
}
if (monitoringRegistry == null) {
//FIXME - Return appropriate message to the user
//return Response.status(404).entity("monitoring facility not installed").build();
return list;
}
if ((path.equals("")) || (path.equals("/"))) {
//Return the sub-resource list of root nodes
//FIXME - No MonitoringRuntimeDataRegistry API available to get hold of
//all the root nodes. We need this in case of clustering. We need to
//get hold of root nodes for all the server instances.
TreeNode serverNode = monitoringRegistry.get("server");
if (serverNode != null) {
//check to make sure we do not display empty server resource
// - http://host:port/monitoring/domain/server
//When you turn monitoring levels HIGH and then turn them OFF,
//you may see empty server resource. This is because server tree
//node has children (disabled) even when all the monitoring
//levels are turned OFF.
//Issue: 9921
if (!serverNode.getEnabledChildNodes().isEmpty()) {
list.add(serverNode);
}
return list;
} else {
//No root node available, so nothing to list
//FIXME - Return appropriate message to the user
///return Response.status(404).entity("No monitoring data. Please check monitoring levels are configured").build();
return list;
}
}
//ignore the starting slash
if (path.startsWith("/")) {
path = path.substring(1);
}
//replace all . with \.
path = path.replaceAll("\\.", "\\\\.");
String dottedName = path.replace('/', '.');
String root;
int index = dottedName.indexOf('.');
if (index != -1) {
root = dottedName.substring(0, dottedName.indexOf('.'));
dottedName = dottedName.substring(dottedName.indexOf('.') + 1 );
} else {
root = dottedName;
dottedName = "";
}
//TreeNode rootNode = monitoringRegistry.get("server");
TreeNode rootNode = monitoringRegistry.get(root);
if (rootNode == null) {
//No monitoring data, so nothing to list
//FIXME - Return appropriate message to the user
///return Response.status(404).entity("No monitoring data. Please check monitoring levels are configured").build();
return list;