incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1338488 - /sling/trunk/bundles/jcr/webconsole/src/main/java/org/apache/sling/jcr/webconsole/internal/NodeTypeConfigurationPrinter.java
Date Tue, 15 May 2012 00:25:55 GMT
Author: justin
Date: Tue May 15 00:25:55 2012
New Revision: 1338488

URL: http://svn.apache.org/viewvc?rev=1338488&view=rev
Log:
SLING-2479 - print types in alpha order

Modified:
    sling/trunk/bundles/jcr/webconsole/src/main/java/org/apache/sling/jcr/webconsole/internal/NodeTypeConfigurationPrinter.java

Modified: sling/trunk/bundles/jcr/webconsole/src/main/java/org/apache/sling/jcr/webconsole/internal/NodeTypeConfigurationPrinter.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/webconsole/src/main/java/org/apache/sling/jcr/webconsole/internal/NodeTypeConfigurationPrinter.java?rev=1338488&r1=1338487&r2=1338488&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/webconsole/src/main/java/org/apache/sling/jcr/webconsole/internal/NodeTypeConfigurationPrinter.java
(original)
+++ sling/trunk/bundles/jcr/webconsole/src/main/java/org/apache/sling/jcr/webconsole/internal/NodeTypeConfigurationPrinter.java
Tue May 15 00:25:55 2012
@@ -17,6 +17,10 @@
 package org.apache.sling.jcr.webconsole.internal;
 
 import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Comparator;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
@@ -73,9 +77,9 @@ public class NodeTypeConfigurationPrinte
                 session = slingRepository.loginAdministrative(null);
                 NodeTypeManager ntm = session.getWorkspace().getNodeTypeManager();
                 NodeTypeIterator it = ntm.getAllNodeTypes();
-                while (it.hasNext()) {
-                    NodeType nt = it.nextNodeType();
+                List<NodeType> sortedTypes = sortTypes(it);
 
+                for (NodeType nt : sortedTypes) {
                     pw.printf("[%s]", nt.getName());
 
                     printSuperTypes(pw, nt);
@@ -179,6 +183,20 @@ public class NodeTypeConfigurationPrinte
 
     }
 
+    private List<NodeType> sortTypes(NodeTypeIterator it) {
+        List<NodeType> types = new ArrayList<NodeType>();
+        while (it.hasNext()) {
+            NodeType nt = it.nextNodeType();
+            types.add(nt);
+        }
+        Collections.sort(types, new Comparator<NodeType>(){
+            public int compare(NodeType o1, NodeType o2) {
+                return o1.getName().compareTo(o2.getName());
+            }
+        });
+        return types;
+    }
+
     private void linebreak(PrintWriter pw, String mode) {
         if (ConfigurationPrinter.MODE_WEB.equals(mode)) {
             pw.println("<br/>");



Mime
View raw message