jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1152173 - /jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
Date Fri, 29 Jul 2011 11:35:17 GMT
Author: mduerig
Date: Fri Jul 29 11:35:17 2011
New Revision: 1152173

URL: http://svn.apache.org/viewvc?rev=1152173&view=rev
Log:
spi2microkernel (WIP)
- avoid IndexOutOfBoundException in observation
- logging 

Modified:
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.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=1152173&r1=1152172&r2=1152173&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
Fri Jul 29 11:35:17 2011
@@ -41,6 +41,8 @@ import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 import org.json.simple.parser.JSONParser;
 import org.json.simple.parser.ParseException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.jcr.RepositoryException;
 import java.util.ArrayList;
@@ -56,6 +58,8 @@ import java.util.concurrent.ExecutionExc
 import java.util.concurrent.FutureTask;
 
 public class SubscriptionImpl implements Subscription {
+    static final Logger log = LoggerFactory.getLogger(SubscriptionImpl.class);
+
     private final MicroKernel microKernel;
     private final SessionState sessionState;
     private final WaitForCommit waitForCommit;
@@ -140,7 +144,7 @@ public class SubscriptionImpl implements
             return path.getAncestor(1);
         }
         catch (RepositoryException e) {
-            // todo log
+            log.error("Error getting parent of " + path, e);
             return null;
         }
     }
@@ -150,14 +154,18 @@ public class SubscriptionImpl implements
             return PathFactoryImpl.getInstance().create(parent, name, true);
         }
         catch (RepositoryException e) {
-            // todo log
+            log.error("Error creating path for " + parent + ", " + name, e);
             return null;
         }
     }
 
     private static Path readPath(JsopTokenizer jsopTokenizer) {
         String path = jsopTokenizer.readString();
-        path = path.substring(PathUtils.getNextSlash(path, 1)); // slash off workspace name
+        int index = PathUtils.getNextSlash(path, 1); // slash off workspace name
+        path = index == -1
+            ? "/"
+            : path.substring(index);
+        
         return Paths.stringToPath(path);
     }
 
@@ -324,7 +332,10 @@ public class SubscriptionImpl implements
 
         private void addItem(JsopTokenizer jsopTokenizer, EventTemplate eventTemplate, Collection<Event>
events) {
             Path path = readPath(jsopTokenizer);
-            NodeId parentId = createNodeId(getParent(path));
+            NodeId parentId = path.denotesRoot()
+                ? null
+                : createNodeId(getParent(path));
+            
             addItem(jsopTokenizer, eventTemplate, events, path, parentId);
         }
 
@@ -379,7 +390,9 @@ public class SubscriptionImpl implements
 
         private void removeNode(JsopTokenizer jsopTokenizer, EventTemplate eventTemplate,
Collection<Event> events) {
             Path path = readPath(jsopTokenizer);
-            NodeId parentId = createNodeId(getParent(path));
+            NodeId parentId = path.denotesRoot()
+                ? null
+                : createNodeId(getParent(path));
 
             EventTemplate removeNodeEvent = eventTemplate.copy();
             removeNodeEvent.setType(Event.NODE_REMOVED);



Mime
View raw message