jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1134535 - in /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk: MicroKernelImpl.java json/DiffHandler.java json/DiffParser.java
Date Sat, 11 Jun 2011 07:28:07 GMT
Author: thomasm
Date: Sat Jun 11 07:28:06 2011
New Revision: 1134535

URL: http://svn.apache.org/viewvc?rev=1134535&view=rev
Log:
Remove the old parsing.

Removed:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/DiffHandler.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/DiffParser.java
Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java?rev=1134535&r1=1134534&r2=1134535&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java
Sat Jun 11 07:28:06 2011
@@ -18,8 +18,6 @@ package org.apache.jackrabbit.mk;
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.api.MicroKernelException;
-import org.apache.jackrabbit.mk.json.DiffHandler;
-import org.apache.jackrabbit.mk.json.DiffParser;
 import org.apache.jackrabbit.mk.json.JsopBuilder;
 import org.apache.jackrabbit.mk.json.JsopTokenizer;
 import org.apache.jackrabbit.mk.store.Commit;
@@ -28,14 +26,11 @@ import org.apache.jackrabbit.mk.store.No
 import org.apache.jackrabbit.mk.store.NodeDiffHandler;
 import org.apache.jackrabbit.mk.store.NodeUtils;
 import org.apache.jackrabbit.mk.util.PathUtil;
-import org.json.simple.parser.ContainerFactory;
-import org.json.simple.parser.JSONParser;
 
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -270,69 +265,6 @@ public class MicroKernelImpl implements 
         }
     }
 
-    public String commitOld(final String path, String jsonDiff, String revisionId) throws
MicroKernelException {
-        if (rep == null) {
-            throw new IllegalStateException("this instance has already been disposed");
-        }
-
-        String newHeadRev;
-        try {
-            final CommitBuilder cb = rep.getCommitBuilder(revisionId);
-            final JSONParser jsonParser = new JSONParser();
-            final ContainerFactory containerFactory = new ContainerFactory() {
-                public List creatArrayContainer() {
-                    return new JSONArray();
-                }
-
-                public Map createObjectContainer() {
-                    return new JSONObject();
-                }
-            };
-
-            DiffHandler handler = new DiffHandler() {
-
-                public void addNode(String relPath, String jsonObject) throws Exception {
-                    if (jsonObject == null) {
-                        throw new Exception("illegal json object format: " + relPath);
-                    }
-                    Object obj = jsonParser.parse(jsonObject, containerFactory);
-                    if (!(obj instanceof Map)) {
-                        throw new Exception("illegal json object format: " + jsonObject);
-                    }
-
-                    String nodePath = PathUtil.concat(path, relPath);
-                    String parentPath = PathUtil.getParentPath(nodePath);
-                    String nodeName = PathUtil.getName(nodePath);
-                    MicroKernelImpl.addNode(cb, parentPath, nodeName, (JSONObject) obj);
-                }
-
-                public void setProperty(String relPath, String propValue) throws Exception
{
-                    String nodePath = PathUtil.concat(path, relPath);
-                    String parentPath = PathUtil.getParentPath(nodePath);
-                    String propName = PathUtil.getName(nodePath);
-
-                    cb.setProperty(parentPath, propName, propValue);
-                }
-
-                public void remove(String nodeName) throws Exception {
-                    cb.removeNode(PathUtil.concat(path, nodeName));
-                }
-
-                public void move(String nodeName, String targetPath) throws Exception {
-                    cb.moveNode(PathUtil.concat(path, nodeName), targetPath);
-                }
-            };
-            DiffParser parser = new DiffParser(handler);
-            parser.parse(jsonDiff);
-
-            newHeadRev = cb.doCommit();
-        } catch (Exception e) {
-            throw new MicroKernelException(e);
-        }
-
-        return newHeadRev;
-    }
-
     public String commit(String path, String jsonDiff, String revisionId) throws MicroKernelException
{
         if (rep == null) {
             throw new IllegalStateException("this instance has already been disposed");
@@ -457,29 +389,6 @@ public class MicroKernelImpl implements 
         }
     }
 
-    static void addNode(CommitBuilder cb, String path, String name, JSONObject jsonNode)
throws Exception {
-        Map<String, String> props = new HashMap<String, String>();
-
-        for (Iterator it = jsonNode.entrySet().iterator(); it.hasNext(); ) {
-            Map.Entry entry = (Map.Entry) it.next();
-            if (! (entry.getValue() instanceof JSONObject)) {
-                Object o = entry.getValue();
-                if (o instanceof String) {
-                    o = JsopBuilder.encode(o.toString());
-                }
-                props.put((String) entry.getKey(), o.toString());
-            }
-        }
-        cb.addNode(path, name, props);
-        // add nested json objects
-        for (Iterator it = jsonNode.entrySet().iterator(); it.hasNext(); ) {
-            Map.Entry entry = (Map.Entry) it.next();
-            if (entry.getValue() instanceof JSONObject) {
-                addNode(cb, PathUtil.concat(path, name), (String) entry.getKey(), (JSONObject)
entry.getValue());
-            }
-        }
-    }
-
     private static void parseRawValue(JsopTokenizer t, JsopBuilder buff) {
         if (t.matches('[')) {
             buff.array();
@@ -541,17 +450,4 @@ public class MicroKernelImpl implements 
         Map<String, String> props = new HashMap<String, String>();
     }
 
-    static class JSONObject extends LinkedHashMap<String, Object>{};
-    static class JSONArray extends LinkedList {
-        public String toString() {
-            JsopBuilder buff = new JsopBuilder().array();
-            for (Object o : this) {
-                if (o instanceof String) {
-                    o = JsopBuilder.encode(o.toString());
-                }
-                buff.value(o.toString());
-            }
-            return buff.endArray().toString();
-        }
-    }
 }



Mime
View raw message