jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1138554 - in /jackrabbit/sandbox/spi2microkernel/src: main/java/org/apache/jackrabbit/spi2microkernel/ test/java/org/apache/jackrabbit/spi2microkernel/
Date Wed, 22 Jun 2011 17:07:20 GMT
Author: mduerig
Date: Wed Jun 22 17:07:19 2011
New Revision: 1138554

URL: http://svn.apache.org/viewvc?rev=1138554&view=rev
Log:
spi2microkernel prototype (WIP)
observation (WIP): addNode

Modified:
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java
    jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java?rev=1138554&r1=1138553&r2=1138554&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
Wed Jun 22 17:07:19 2011
@@ -343,10 +343,12 @@ public class RepositoryServiceImpl exten
     public EventFilter createEventFilter(SessionInfo sessionInfo, int eventTypes, Path absPath,
boolean isDeep,
              String[] uuid, Name[] nodeTypeName, boolean noLocal) throws RepositoryException
{
 
-        Set<Name> ntNames = new HashSet<Name>();
+        Set<Name> ntNames = null;
         if (nodeTypeName != null) {
+            ntNames = new HashSet<Name>();
             Collections.addAll(ntNames, nodeTypeName);
         }
+
         return new EventFilterImpl(eventTypes, absPath, isDeep, uuid, ntNames, noLocal);
     }
 

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=1138554&r1=1138553&r2=1138554&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 Jun 22 17:07:19 2011
@@ -32,6 +32,7 @@ import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.Subscription;
 import org.apache.jackrabbit.spi.commons.EventBundleImpl;
 import org.apache.jackrabbit.spi.commons.EventImpl;
+import org.apache.jackrabbit.spi.commons.identifier.IdFactoryImpl;
 import org.apache.jackrabbit.spi2microkernel.util.Paths;
 import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
@@ -111,22 +112,26 @@ public class SubscriptionImpl implements
     private class EventSource {
         private final EventFilter[] eventFilters;
         private final List<String> commitLog;
+        private final String startRevision;
 
         public EventSource(EventFilter[] eventFilters, SessionState sessionState) {
-            this(eventFilters, sessionState.getCommitLog());
+            this.eventFilters = eventFilters;
+            commitLog = sessionState.getCommitLog();
+            startRevision = commitLog.get(commitLog.size() - 1);
         }
 
-        public EventSource(EventFilter[] eventFilters, List<String> commitLog) {
+        public EventSource(EventFilter[] eventFilters, List<String> commitLog, String
startRevision) {
             this.eventFilters = eventFilters;
             this.commitLog = commitLog;
+            this.startRevision = startRevision;
         }
 
         public String getStartRevision() {
-            return commitLog.get(commitLog.size() - 1);
+            return startRevision;
         }
 
         public Collection<? extends EventBundle> getEventsBundles(String endRevision)
throws RepositoryException {
-            String journal = microKernel.getJournal(getStartRevision(), endRevision);
+            String journal = microKernel.getJournal(startRevision, endRevision);
             List<EventBundle> eventBundles = new ArrayList<EventBundle>();
 
             try {
@@ -152,7 +157,7 @@ public class SubscriptionImpl implements
         }
 
         public EventSource update(String startRevision) {
-            return new EventSource(eventFilters, commitLog);
+            return new EventSource(eventFilters, commitLog, startRevision);
         }
 
         //------------------------------------------< private >---
@@ -195,7 +200,7 @@ public class SubscriptionImpl implements
                     case '-': removeNode(jsopTokenizer, eventTemplate, events); break;
                     case '^': setProperty(jsopTokenizer, eventTemplate, events); break;
                     case '>': moveNode(jsopTokenizer, eventTemplate, events); break;
-                    default: throw new IllegalArgumentException("Invalid token: " + tokenType);
+                    default: // todo log and continue
                 }
             }
 
@@ -207,25 +212,35 @@ public class SubscriptionImpl implements
         private void addItem(JsopTokenizer jsopTokenizer, EventTemplate eventTemplate, Collection<Event>
events) {
             EventTemplate addNodeEvent = eventTemplate.copy();
 
-            String path = jsopTokenizer.readString();
-            Path p = Paths.stringToPath(path);
+            Path path = Paths.stringToPath(jsopTokenizer.readString());
+            addNodeEvent.setPath(path);
+
             jsopTokenizer.read(':');
-            
+
+            NodeId parentId = null;
+            try {
+                parentId = IdFactoryImpl.getInstance().createNodeId((String) null, path.getAncestor(1));
+                addNodeEvent.setParentId(parentId);
+            }
+            catch (RepositoryException e) {
+                e.printStackTrace();  // todo log
+            }
+
+            ItemId itemId;
             if (jsopTokenizer.read() == '{') {
                 addNodeEvent.setType(Event.NODE_ADDED);
+                itemId = IdFactoryImpl.getInstance().createNodeId((String) null, path);
+                // todo parse inner cruft
             }
             else {
                 addNodeEvent.setType(Event.PROPERTY_ADDED);
+                itemId = IdFactoryImpl.getInstance().createPropertyId(parentId, path.getName());
             }
+            addNodeEvent.setItemId(itemId);
 
-
-            // todo implement addNode
-
-            Path qpath = null;
-            ItemId itemId = null;
-            NodeId parentId = null;
-
+            // todo set type info
             // todo need more context in journal in case of property mod
+            // todo it seems type filtering does not respect the type hierarchy (https://issues.apache.org/jira/browse/JCR-2542)
             Name primaryNodeTypeName = null;
             Name[] mixinTypeNames = null;
 

Modified: jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java?rev=1138554&r1=1138553&r2=1138554&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Wed Jun 22 17:07:19 2011
@@ -934,7 +934,7 @@ public class RepositoryTest {
         n1.getProperty("prop2").remove();
         n.getNode("2").remove();  
         getSession().save();
-        Thread.sleep(10000);
+        Thread.sleep(20000);
     }
 
     @Ignore  // todo make this into real test



Mime
View raw message