jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1133735 - /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/DiffParser.java
Date Thu, 09 Jun 2011 09:08:01 GMT
Author: thomasm
Date: Thu Jun  9 09:08:01 2011
New Revision: 1133735

URL: http://svn.apache.org/viewvc?rev=1133735&view=rev
Log:
Removing a node should just be "-nodeName" and not require a 'value'

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/DiffParser.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=1133735&r1=1133734&r2=1133735&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
Thu Jun  9 09:08:01 2011
@@ -145,14 +145,7 @@ public class DiffParser {
                         path = bf.substring(0, bf.lastIndexOf(":")).trim();
 
                         // trim leading/trailing '"'
-                        int start = 0, end = path.length();
-                        if (path.startsWith("\"")) {
-                            start++;
-                        }
-                        if (path.endsWith("\"")) {
-                            end--;
-                        }
-                        path = path.substring(start, end);
+                        path = removeQuotes(path);
 
                         state = STATE_START_VALUE;
                         // reset buffer
@@ -193,7 +186,11 @@ public class DiffParser {
         }
 
         // a diff ending after a command or within the target is invalid.
-        if (state == STATE_START_TARGET || state == STATE_TARGET) {
+        if (state == STATE_TARGET && action == SYMBOL_REMOVE) {
+            // ok
+            path = bf.toString();
+            path = removeQuotes(path);
+        } else if (state == STATE_START_TARGET || state == STATE_TARGET) {
             throw new Exception("Invalid end of DIFF string: missing separator and value.");
         }
         if (state == STATE_START_VALUE ) {
@@ -211,6 +208,18 @@ public class DiffParser {
         informAction(action, path, bf);
     }
 
+    private String removeQuotes(String s) {
+        int start = 0, end = s.length();
+        if (s.startsWith("\"")) {
+            start++;
+        }
+        if (s.endsWith("\"")) {
+            end--;
+        }
+        s = s.substring(start, end);
+        return s;
+    }
+
     private void informAction(int action, String path, StringBuilder diffVal) throws Exception
{
         if (path == null) {
             throw new Exception("Missing path for action " + action + "(diffValue = '"+ diffVal
+"')");
@@ -221,6 +230,7 @@ public class DiffParser {
                 handler.addNode(path, value);
                 break;
             case SYMBOL_SET_PROPERTY:
+                // handler.setProperty(path, JsopTokenizer.encode(value));
                 handler.setProperty(path, value);
                 break;
             case SYMBOL_MOVE:



Mime
View raw message