jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1132695 - in /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk: MicroKernelImpl.java json/DiffHandler.java
Date Mon, 06 Jun 2011 16:34:19 GMT
Author: mduerig
Date: Mon Jun  6 16:34:18 2011
New Revision: 1132695

URL: http://svn.apache.org/viewvc?rev=1132695&view=rev
Log:
MicroKernel prototype (WIP)
allow relative paths for addNode and addProperty

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/DiffHandler.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=1132695&r1=1132694&r2=1132695&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
Mon Jun  6 16:34:18 2011
@@ -321,20 +321,27 @@ public class MicroKernelImpl implements 
 
             DiffHandler handler = new DiffHandler() {
 
-                public void addNode(String nodeName, String jsonObject) throws Exception
{
+                public void addNode(String relPath, String jsonObject) throws Exception {
                     if (jsonObject == null) {
-                        throw new Exception("illegal json object format: " + nodeName);
+                        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);
                     }
 
-                    MicroKernelImpl.addNode(cb, path, nodeName, (JSONObject) obj);
+                    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 propName, String propValue) throws Exception
{
-                    cb.setProperty(path, propName, propValue);
+                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 {

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/DiffHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/DiffHandler.java?rev=1132695&r1=1132694&r2=1132695&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/DiffHandler.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/DiffHandler.java
Mon Jun  6 16:34:18 2011
@@ -24,9 +24,9 @@ package org.apache.jackrabbit.mk.json;
  */
 public interface DiffHandler {
 
-    void addNode(String nodeName, String jsonObject) throws Exception;
+    void addNode(String relPath, String jsonObject) throws Exception;
 
-    void setProperty(String propName, String propValue) throws Exception;
+    void setProperty(String relPath, String propValue) throws Exception;
 
     void remove(String nodeName) throws Exception;
 



Mime
View raw message