jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1136040 - in /jackrabbit/sandbox/spi2microkernel/src: main/java/org/apache/jackrabbit/spi2microkernel/ main/java/org/apache/jackrabbit/spi2microkernel/util/ test/java/org/apache/jackrabbit/spi2microkernel/
Date Wed, 15 Jun 2011 13:46:36 GMT
Author: thomasm
Date: Wed Jun 15 13:46:35 2011
New Revision: 1136040

URL: http://svn.apache.org/viewvc?rev=1136040&view=rev
Log:
Use the changed API.

Modified:
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/ItemInfos.java
    jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
    jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java?rev=1136040&r1=1136039&r2=1136040&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
Wed Jun 15 13:46:35 2011
@@ -131,12 +131,27 @@ public class RepositoryServiceImpl exten
         final List<String> workspaces = new ArrayList<String>();
 
         try {
-            String json = microKernel.getChildNodes("/", 0, Integer.MAX_VALUE, 0, rev);
-            new JSONParser().parse(json, new JsonHandlerBase(){
+            String json = microKernel.getNodes("/", rev, 0, 0, -1);
+            new JSONParser().parse(json, new JsonHandlerBase() {
+
+                private String key;
+
+                @Override
+                public boolean startObjectEntry(String key) throws ParseException, IOException
{
+                    this.key = key;
+                    return true;
+                }
+
+                public boolean startObject() throws ParseException, IOException {
+                    if (key != null) {
+                        workspaces.add(key);
+                    }
+                    return true;
+                }
 
                 @Override
-                public boolean primitive(Object value) throws ParseException, IOException
{
-                    workspaces.add(value.toString());
+                public boolean endObjectEntry() throws ParseException, IOException {
+                    key = null;
                     return true;
                 }
 
@@ -177,7 +192,7 @@ public class RepositoryServiceImpl exten
             String rev = getRevision(sessionInfo);
 
             if (microKernel.nodeExists(mkPath, rev)) {
-                String json = microKernel.getNodes(mkPath, 1, rev);
+                String json = microKernel.getNodes(mkPath, rev);
                 return ItemInfos.buildItemInfos(path, json);
             }
             else {
@@ -198,7 +213,7 @@ public class RepositoryServiceImpl exten
 
             NodeInfo info = null;
             if (microKernel.nodeExists(mkPath, rev)) {
-                String json = microKernel.getNodes(mkPath, 1, rev);
+                String json = microKernel.getNodes(mkPath, rev);
                 info = ItemInfos.buildNodeInfo(path, json);
             }
 
@@ -223,7 +238,7 @@ public class RepositoryServiceImpl exten
 
             PropertyInfo info = null;
             if (microKernel.nodeExists(mkPath, rev)) {
-                String json = microKernel.getNodes(mkPath, 0, rev);
+                String json = microKernel.getNodes(mkPath, rev);
                 info = ItemInfos.buildPropertyInfo(path, json);
             }
 

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/ItemInfos.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/ItemInfos.java?rev=1136040&r1=1136039&r2=1136040&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/ItemInfos.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/ItemInfos.java
Wed Jun 15 13:46:35 2011
@@ -64,7 +64,8 @@ public final class ItemInfos {
 
         try {
             JSONParser parser = new JSONParser();
-            parser.parse(json, new JsonHandler(parent(path), infoListener));
+            JsonHandler handler = new JsonHandler(parent(path), path.getName(), infoListener);
+            parser.parse(json, handler);
             return itemInfos.iterator();
         }
         catch (ParseException e) {
@@ -93,7 +94,8 @@ public final class ItemInfos {
 
         try {
             JSONParser parser = new JSONParser();
-            parser.parse(json, new JsonHandler(parent(parent(path)), infoListener));
+            JsonHandler handler = new JsonHandler(parent(parent(path)), parent(path).getName(),
infoListener);
+            parser.parse(json, handler);
             return nodeInfos[0];
         }
         catch (ParseException e) {
@@ -122,7 +124,8 @@ public final class ItemInfos {
 
         try {
             JSONParser parser = new JSONParser();
-            parser.parse(json, new JsonHandler(parent(parent(path)), infoListener));
+            JsonHandler handler = new JsonHandler(parent(parent(path)), parent(path).getName(),
infoListener);
+            parser.parse(json, handler);
             return propertyInfos[0];
         }
         catch (ParseException e) {
@@ -144,14 +147,17 @@ public final class ItemInfos {
         private final Path parent;
         private final InfoListener infoListener;
 
+        private Name name;
+
         private String currentKey;
         private boolean isObjectEmpty;
         private NodeInfoBuilder nodeInfoBuilder;
         private PropertyInfoBuilder propertyInfoBuilder;
 
-        public JsonHandler(Path parent, InfoListener infoListener) {
+        public JsonHandler(Path parent, Name name, InfoListener infoListener) {
             this.infoListener = infoListener;
             this.parent = parent;
+            this.name = name;
         }
 
         @Override
@@ -163,6 +169,10 @@ public final class ItemInfos {
             else {
                 nodeInfoBuilder = nodeInfoBuilder.createNodeInfo();
             }
+            if (currentKey != null) {
+                name = Paths.translateName(currentKey);
+            }
+            nodeInfoBuilder.setName(name);
 
             isObjectEmpty = true;
             return !infoListener.done();
@@ -198,12 +208,6 @@ public final class ItemInfos {
 
         @Override
         public boolean primitive(Object value) throws ParseException, IOException {
-            if (":name".equals(currentKey)) {
-                Name name = Paths.translateName((String) value);
-                nodeInfoBuilder.setName(name);
-                return !infoListener.done();
-            }
-
             if (currentKey.startsWith(":")) {  // ignore other internal values
                 return !infoListener.done();
             }

Modified: jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java?rev=1136040&r1=1136039&r2=1136040&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
Wed Jun 15 13:46:35 2011
@@ -63,8 +63,8 @@ public class MicrokernelTest {
         MicroKernel mk = getMicroKernel();
         String head = mk.getHeadRevision();
 
-        String s1 = mk.getNodes("/test", 0, head);
-        String s2 = mk.getNodes("/test/", 0, head);
+        String s1 = mk.getNodes("/test", head);
+        String s2 = mk.getNodes("/test/", head);
         assertEquals(s1, s2);
     }
 
@@ -86,8 +86,8 @@ public class MicrokernelTest {
         head = mk.commit("/",
                 "+\"fuu\" : {} \n" +
                 "^\"fuu/bar\" : 42", head);
-        String n = mk.getNodes("/fuu", 2, head);
-        assertEquals("{\":name\":\"fuu\",\"bar\":42,\":childNodeCount\":0}", n);
+        String n = mk.getNodes("/fuu", head);
+        assertEquals("{\"bar\":42,\":childNodeCount\":0}", n);
     }
 
     @Test
@@ -120,11 +120,11 @@ public class MicrokernelTest {
                 "^\"" + node + "/child1/grandchild11/prop3\" : 43",
                 head);
 
-        String json = mk.getNodes('/' + node, 2, head);
-        assertEquals("{\":name\":\"" + node + "\",\"prop1\":41,\":childNodeCount\":2," +
-                "\"child1\":{\":name\":\"child1\",\"prop2\":42,\":childNodeCount\":1," +
-                "\"grandchild11\":{\":name\":\"grandchild11\",\"prop3\":43,\":childNodeCount\":0}},"
+
-                "\"child2\":{\":name\":\"child2\",\":childNodeCount\":0}}", json);
+        String json = mk.getNodes('/' + node, head, 3, 0, -1);
+        assertEquals("{\"prop1\":41,\":childNodeCount\":2," +
+                "\"child1\":{\"prop2\":42,\":childNodeCount\":1," +
+                "\"grandchild11\":{\"prop3\":43,\":childNodeCount\":0}}," +
+                "\"child2\":{\":childNodeCount\":0}}", json);
     }
 
     @Test
@@ -136,8 +136,8 @@ public class MicrokernelTest {
         head = mk.commit("/", "+\"" + node + "\" : {\"child\":{}}", head);
 
         head = mk.commit('/' + node, "-\"child\"", head);
-        String json = mk.getNodes('/' + node, 2, head);
-        assertEquals("{\":name\":\"" + node + "\",\":childNodeCount\":0}", json);
+        String json = mk.getNodes('/' + node, head);
+        assertEquals("{\":childNodeCount\":0}", json);
     }
 
     @Test
@@ -150,8 +150,8 @@ public class MicrokernelTest {
         head = mk.commit("/", "+\"" + node + "\" : {\"prop\":\"value\"}", head);
 
         head = mk.commit("/", "^\"" + node + "/prop\" : null", head);
-        String json = mk.getNodes('/' + node, 2, head);
-        assertEquals("{\":name\":\"removeProperty_" + t + "\",\":childNodeCount\":0}", json);
+        String json = mk.getNodes('/' + node, head);
+        assertEquals("{\":childNodeCount\":0}", json);
     }
 
     @Test
@@ -159,7 +159,7 @@ public class MicrokernelTest {
         MicroKernel mk = getMicroKernel();
         String head = mk.getHeadRevision();
 
-        String json = mk.getNodes("/test", 2, head);
+        String json = mk.getNodes("/test", head);
         JSONObject result = (JSONObject) new JSONParser().parse(json);
         Object stringProp = result.get("stringProp");
         assertTrue(stringProp instanceof String);
@@ -171,7 +171,7 @@ public class MicrokernelTest {
         MicroKernel mk = getMicroKernel();
         String head = mk.getHeadRevision();
 
-        String json = mk.getNodes("/test", 2, head);
+        String json = mk.getNodes("/test", head);
         JSONObject result = (JSONObject) new JSONParser().parse(json);
         Object intProp = result.get("intProp");
         assertTrue(intProp instanceof Long);
@@ -183,7 +183,7 @@ public class MicrokernelTest {
         MicroKernel mk = getMicroKernel();
         String head = mk.getHeadRevision();
 
-        String json = mk.getNodes("/test", 2, head);
+        String json = mk.getNodes("/test", head);
         JSONObject result = (JSONObject) new JSONParser().parse(json);
         Object floatProp = result.get("floatProp");
         assertTrue(floatProp instanceof Double);
@@ -195,7 +195,7 @@ public class MicrokernelTest {
         MicroKernel mk = getMicroKernel();
         String head = mk.getHeadRevision();
 
-        String json = mk.getNodes("/test", 2, head);
+        String json = mk.getNodes("/test", head);
         JSONObject result = (JSONObject) new JSONParser().parse(json);
         Object multiIntProp = result.get("multiIntProp");
         assertTrue(multiIntProp instanceof JSONArray);

Modified: jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java?rev=1136040&r1=1136039&r2=1136040&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Wed Jun 15 13:46:35 2011
@@ -49,6 +49,7 @@ import static org.junit.Assert.*;
 public class RepositoryTest {
 
     private static final String URL = "fs:target/repository-test/repository";
+    // private static final String URL = "mem:";
 
     private final String testNode = "node_" + System.currentTimeMillis();
     private final String testPath = '/' + testNode;



Mime
View raw message