Search in sources :

Example 6 with ConfiguredObjectFinder

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);
}
Also used : OutputStream(java.io.OutputStream) ConfiguredObjectFinder(org.apache.qpid.server.model.ConfiguredObjectFinder) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 7 with ConfiguredObjectFinder

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;
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectFinder(org.apache.qpid.server.model.ConfiguredObjectFinder) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ConfiguredObjectFinder (org.apache.qpid.server.model.ConfiguredObjectFinder)7 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)6 LinkedHashMap (java.util.LinkedHashMap)3 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 OutputStream (java.io.OutputStream)1 PrintWriter (java.io.PrintWriter)1 Collection (java.util.Collection)1 TreeMap (java.util.TreeMap)1 AbstractConfigurationChangeListener (org.apache.qpid.server.model.AbstractConfigurationChangeListener)1 Model (org.apache.qpid.server.model.Model)1 State (org.apache.qpid.server.model.State)1