jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1134533 - in /jackrabbit/sandbox/microkernel/src: main/java/org/apache/jackrabbit/mk/json/DiffParser.java main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java test/java/org/apache/jackrabbit/mk/HelloWorld.java
Date Sat, 11 Jun 2011 07:21:11 GMT
Author: thomasm
Date: Sat Jun 11 07:21:11 2011
New Revision: 1134533

URL: http://svn.apache.org/viewvc?rev=1134533&view=rev
Log:
Fix the parser.

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/DiffParser.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/DiffParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/DiffParser.java?rev=1134533&r1=1134532&r2=1134533&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/DiffParser.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/DiffParser.java
Sat Jun 11 07:21:11 2011
@@ -130,6 +130,8 @@ public class DiffParser {
                     break;
 
                 case STATE_START_TARGET:
+                    // TODO this will not allow a space between the operation and the path,
+                    // so that "- /path/" is not allowed
                     if (Character.isWhitespace((char) next) || next == ':') {
                         throw new Exception("Invalid start of target path '" + next + "'");
                     }
@@ -188,7 +190,7 @@ public class DiffParser {
         // a diff ending after a command or within the target is invalid.
         if (state == STATE_TARGET && action == SYMBOL_REMOVE) {
             // ok
-            path = bf.toString();
+            path = bf.toString().trim();
             path = removeQuotes(path);
         } else if (state == STATE_START_TARGET || state == STATE_TARGET) {
             throw new Exception("Invalid end of DIFF string: missing separator and value.");
@@ -209,6 +211,7 @@ public class DiffParser {
     }
 
     private String removeQuotes(String s) {
+        // TODO this method doesn't correct de-escape strings
         int start = 0, end = s.length();
         if (s.startsWith("\"")) {
             start++;
@@ -227,16 +230,21 @@ public class DiffParser {
         String value = (diffVal == null) ? null : diffVal.toString();
         switch (action) {
             case SYMBOL_ADD_NODE:
-                handler.addNode(path, value);
+                handler.addNode(path, value.trim());
                 break;
             case SYMBOL_SET_PROPERTY:
-                handler.setProperty(path, value);
+                value = value.trim();
+                if ("null".equals(value)) {
+                    handler.setProperty(path, null);
+                } else {
+                    handler.setProperty(path, value);
+                }
                 break;
             case SYMBOL_MOVE:
-                handler.move(path, value);
+                handler.move(path, value.trim());
                 break;
             case SYMBOL_REMOVE:
-                handler.remove(path);
+                handler.remove(path.trim());
                 break;
             default:
                 throw new Exception("Invalid action " + action);

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java?rev=1134533&r1=1134532&r2=1134533&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java
Sat Jun 11 07:21:11 2011
@@ -133,7 +133,7 @@ public class CommitBuilder {
         MutableNode node = getOrCreateStagedNode(nodePath);
 
         Map<String, String> properties = node.getProperties();
-        if ("null".equals(propValue)) {
+        if (propValue == null) {
             properties.remove(propName);
         } else {
             properties.put(propName, propValue);

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java?rev=1134533&r1=1134532&r2=1134533&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java
Sat Jun 11 07:21:11 2011
@@ -51,6 +51,7 @@ public class HelloWorld {
 
         // head = mk.commit(null, "+\"/test\" : {\"name\":\"hello\"}", head);
         head = mk.commit("/", "^\"test/x\" : false", head);
+        head = mk.commit("/", "^\"test/x\" : null", head);
 
         // head = mk.getHeadRevision();
         s = mk.getNodes("/test", 0, head);



Mime
View raw message