jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1156248 - in /jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel: SubscriptionImpl.java util/Values.java
Date Wed, 10 Aug 2011 16:17:34 GMT
Author: mduerig
Date: Wed Aug 10 16:17:33 2011
New Revision: 1156248

URL: http://svn.apache.org/viewvc?rev=1156248&view=rev
Log:
spi2microkernel (WIP)
- observation: move

Modified:
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java?rev=1156248&r1=1156247&r2=1156248&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
Wed Aug 10 16:17:33 2011
@@ -37,6 +37,7 @@ import org.apache.jackrabbit.spi.commons
 import org.apache.jackrabbit.spi.commons.identifier.IdFactoryImpl;
 import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
 import org.apache.jackrabbit.spi2microkernel.util.Paths;
+import org.apache.jackrabbit.spi2microkernel.util.Values;
 import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 import org.json.simple.parser.JSONParser;
@@ -48,6 +49,7 @@ import javax.jcr.RepositoryException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
@@ -287,7 +289,7 @@ public class SubscriptionImpl implements
 
         //------------------------------------------< private >---
 
-        private EventBundle createEventBundle(JSONObject jsonObject) {
+        private EventBundle createEventBundle(JSONObject jsonObject) throws RepositoryException
{
             String revisionId = getString(jsonObject, "id", false);
             String userData = getString(jsonObject, "msg", true);
             long timeStamp = getLong(jsonObject, "ts");
@@ -318,7 +320,7 @@ public class SubscriptionImpl implements
             return new EventBundleImpl(events, isLocal);
         }
 
-        private Collection<Event> getEvents(String changes, EventTemplate eventTemplate)
{
+        private Collection<Event> getEvents(String changes, EventTemplate eventTemplate)
throws RepositoryException {
             Collection<Event> events = new ArrayList<Event>();
             JsopTokenizer jsopTokenizer = new JsopTokenizer(changes);
 
@@ -439,8 +441,24 @@ public class SubscriptionImpl implements
             }
         }
 
-        private void moveNode(JsopTokenizer jsopTokenizer, EventTemplate eventTemplate, Collection<Event>
events) {
-            // todo implement moveNode
+        private void moveNode(JsopTokenizer jsopTokenizer, EventTemplate eventTemplate, Collection<Event>
events)
+                throws RepositoryException {
+            
+            Path fromPath = readPath(jsopTokenizer);
+            jsopTokenizer.read(':');
+            Path toPath = readPath(jsopTokenizer);
+
+            EventTemplate moveNodeEvent = eventTemplate.copy();
+            moveNodeEvent.setType(Event.NODE_MOVED);
+            moveNodeEvent.setPath(toPath);
+            moveNodeEvent.setItemId(createNodeId(toPath));
+
+            Map<Name, QValue> info = new HashMap<Name, QValue>();
+            info.put(Paths.stringToName("srcAbsPath"), Values.pathToValue(fromPath));
+            info.put(Paths.stringToName("destAbsPath"), Values.pathToValue(toPath));
+            moveNodeEvent.setInfo(info);
+
+            events.add(moveNodeEvent.buildEvent());
         }
 
         private String getString(JSONObject jsonObject, String key, boolean allowNull) {

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java?rev=1156248&r1=1156247&r2=1156248&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java
Wed Aug 10 16:17:33 2011
@@ -247,6 +247,10 @@ public final class Values {
         }
     }
 
+    public static QValue pathToValue(Path path) throws RepositoryException {
+        return FACTORY.create(path);
+    }
+
     public static String dateToString(Calendar calendar) {
         return quoteAndEncode(DATE, ISO8601.format(calendar));
     }
@@ -305,7 +309,7 @@ public final class Values {
 
             case PATH:
                 return pathToString(value.getPath());
-            
+
             case URI:
                 return quoteAndEncode(type, JsonBuilder.escape(value.getString()));
 



Mime
View raw message