qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1775306 - in /qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest: ApiDocsServlet.java StructureServlet.java
Date Tue, 20 Dec 2016 15:24:35 GMT
Author: rgodfrey
Date: Tue Dec 20 15:24:35 2016
New Revision: 1775306

URL: http://svn.apache.org/viewvc?rev=1775306&view=rev
Log:
QPID-7563 : Update in response to review comments

Modified:
    qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ApiDocsServlet.java
    qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/StructureServlet.java

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ApiDocsServlet.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ApiDocsServlet.java?rev=1775306&r1=1775305&r2=1775306&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ApiDocsServlet.java
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ApiDocsServlet.java
Tue Dec 20 15:24:35 2016
@@ -133,7 +133,7 @@ public class ApiDocsServlet extends Abst
                 Class<? extends ConfiguredObject> objClass = category;
                 String path = pathStem + category.getSimpleName().toLowerCase();
                 writer.println("<tr>");
-                writer.println("<td class=\"type\"><a href=\"latest/"+ objClass.getSimpleName().toLowerCase()+"\">"+objClass.getSimpleName()+"</a></td>");
+                writer.println("<td class=\"type\"><a href=" + ((servletPathParts.length
== 2) ? "\"latest/" : "")+ objClass.getSimpleName().toLowerCase()+"\">"+objClass.getSimpleName()+"</a></td>");
                 writer.println("<td class=\"path\">" + path + "</td>");
                 writer.println("<td class=\"description\">"+
                                objClass.getAnnotation(ManagedObject.class).description()+"</td>");
@@ -146,7 +146,7 @@ public class ApiDocsServlet extends Abst
         else
         {
             final List<Class<? extends ConfiguredObject>> types = _typeSpecialisations.get(configuredClass);
-            writeCategoryDescription(writer, hierarchy, configuredClass);
+            writeCategoryDescription(writer, configuredClass);
             writeUsage(writer, request, hierarchy, configuredClass);
             writeTypes(writer, model, types);
             writeAttributes(writer, configuredClass, model, types);
@@ -196,7 +196,6 @@ public class ApiDocsServlet extends Abst
     }
 
     private void writeCategoryDescription(PrintWriter writer,
-                                          final Class<? extends ConfiguredObject>[]
hierarchy,
                                           final Class<? extends ConfiguredObject> configuredClass)
     {
         writer.println("<h1>"+configuredClass.getSimpleName()+"</h1>");

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/StructureServlet.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/StructureServlet.java?rev=1775306&r1=1775305&r2=1775306&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/StructureServlet.java
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/StructureServlet.java
Tue Dec 20 15:24:35 2016
@@ -1,18 +1,22 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
  */
 package org.apache.qpid.server.management.plugin.servlet.rest;
 
@@ -44,67 +48,55 @@ public class StructureServlet extends Ab
                          HttpServletResponse response,
                          final ConfiguredObject<?> managedObject) throws IOException,
ServletException
     {
-
-        // TODO filtering??? request.getParameter("filter"); // filter=1,2,3   /groups/*/*
-
-        Map<String,Object> structure = generateStructure(managedObject, managedObject.getCategoryClass(),
true);
-
-        sendJsonResponse(structure, request, response);
-
+        sendJsonResponse(generateStructure(managedObject, managedObject.getCategoryClass(),
true), request, response);
     }
 
-    private Map<String, Object> generateStructure(ConfiguredObject object,
+    private Map<String, Object> generateStructure(ConfiguredObject<?> object,
                                                   Class<? extends ConfiguredObject>
clazz,
                                                   final boolean includeAssociated)
     {
-        Map<String, Object> structure = new LinkedHashMap<String, Object>();
+        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))
         {
-            Collection<? extends ConfiguredObject> children = object.getChildren(childClass);
-            if(children != null)
-            {
-                List<Map<String, Object>> childObjects = new ArrayList<Map<String,
Object>>();
-
-                for(ConfiguredObject child : children)
-                {
-                    childObjects.add(generateStructure(child, childClass, false));
-                }
-
-                if(!childObjects.isEmpty())
-                {
-                    structure.put(pluralize(childClass),childObjects);
-                }
-            }
+            addChildrenToStructure(structure, childClass, object.getChildren(childClass));
         }
+
         if(includeAssociated)
         {
-
             ConfiguredObjectFinder finder = getConfiguredObjectFinder(object);
+
             for(Class<? extends ConfiguredObject> childClass : finder.getAssociatedChildCategories())
             {
-                Collection<? extends ConfiguredObject> children = finder.getAssociatedChildren(childClass);
-                if(children != null)
-                {
-                    List<Map<String, Object>> childObjects = new ArrayList<Map<String,
Object>>();
-
-                    for(ConfiguredObject child : children)
-                    {
-                        childObjects.add(generateStructure(child, childClass, false));
-                    }
-
-                    if(!childObjects.isEmpty())
-                    {
-                        structure.put(pluralize(childClass),childObjects);
-                    }
-                }
+                addChildrenToStructure(structure, childClass, finder.getAssociatedChildren(childClass));
             }
         }
 
         return structure;
     }
 
+    private void addChildrenToStructure(final Map<String, Object> structure,
+                                        final Class<? extends ConfiguredObject> childClass,
+                                        final Collection<? extends ConfiguredObject>
children)
+    {
+        if(children != null)
+        {
+            List<Map<String, Object>> childObjects = new ArrayList<>();
+
+            for(ConfiguredObject child : children)
+            {
+                childObjects.add(generateStructure(child, childClass, false));
+            }
+
+            if(!childObjects.isEmpty())
+            {
+                structure.put(pluralize(childClass),childObjects);
+            }
+        }
+    }
+
     private String pluralize(Class<? extends ConfiguredObject> childClass)
     {
         String name = childClass.getSimpleName().toLowerCase();



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message