//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;
}
TreeNode currentNode;
if (dottedName.length() > 0) {
currentNode = rootNode.getNode(dottedName);
} else {
currentNode = rootNode;
}
if (currentNode == null) {
//No monitoring data, so nothing to list
return list;
///return Response.status(404).entity("Monitoring object not found").build();
}
if (currentNode.hasChildNodes()) {
//print(currentNode.getChildNodes());
//TreeNode.getChildNodes() is returning disabled nodes too.
//Switching to new api TreeNode.getEnabledChildNodes() which returns
//only the enabled nodes. Reference Issue: 9921
list.addAll(currentNode.getEnabledChildNodes());
} else {
Object result = currentNode.getValue();
System.out.println("result: " + result);
list.add(currentNode);
}
return list;
}