use of org.apache.qpid.server.model.ConfiguredObjectFinder in project qpid-broker-j by apache.
the class MetaDataServlet method doGet.
@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response, final ConfiguredObject<?> managedObject) throws ServletException, IOException {
response.setContentType("application/json");
sendCachingHeadersOnResponse(response);
response.setStatus(HttpServletResponse.SC_OK);
ConfiguredObjectFinder finder = getConfiguredObjectFinder(managedObject);
Map<String, Map> classToDataMap = new TreeMap<>();
for (Class<? extends ConfiguredObject> clazz : finder.getManagedCategories()) {
classToDataMap.put(clazz.getSimpleName(), processCategory(clazz, managedObject.getModel()));
}
final OutputStream stream = getOutputStream(request, response);
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
mapper.writeValue(stream, classToDataMap);
response.setContentType("application/json");
response.setStatus(HttpServletResponse.SC_OK);
}
use of org.apache.qpid.server.model.ConfiguredObjectFinder in project qpid-broker-j by apache.
the class StructureServlet method generateStructure.
private Map<String, Object> generateStructure(ConfiguredObject<?> object, Class<? extends ConfiguredObject> clazz, final boolean includeAssociated) {
Map<String, Object> structure = new LinkedHashMap<>();
structure.put("id", object.getId());
structure.put("name", object.getName());
for (Class<? extends ConfiguredObject> childClass : object.getModel().getChildTypes(clazz)) {
addChildrenToStructure(structure, childClass, object.getChildren(childClass));
}
if (includeAssociated) {
ConfiguredObjectFinder finder = getConfiguredObjectFinder(object);
for (Class<? extends ConfiguredObject> childClass : finder.getAssociatedChildCategories()) {
addChildrenToStructure(structure, childClass, finder.getAssociatedChildren(childClass));
}
}
return structure;
}
Aggregations