jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1489815 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/EventFilter.java oak-jcr/pom.xml
Date Wed, 05 Jun 2013 11:26:03 GMT
Author: mduerig
Date: Wed Jun  5 11:26:03 2013
New Revision: 1489815

URL: http://svn.apache.org/r1489815
Log:
OAK-775 Implement backward compatible observation
filter by uuid

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/EventFilter.java
    jackrabbit/oak/trunk/oak-jcr/pom.xml

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/EventFilter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/EventFilter.java?rev=1489815&r1=1489814&r2=1489815&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/EventFilter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/EventFilter.java
Wed Jun  5 11:26:03 2013
@@ -25,7 +25,10 @@ import javax.annotation.Nullable;
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.core.ReadOnlyTree;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
@@ -42,13 +45,13 @@ class EventFilter {
     private final int eventTypes;
     private final String path;
     private final boolean deep;
-    private final String[] uuid;          // TODO implement filtering by uuid
+    private final String[] uuids;
     private final String[] nodeTypeOakName;
     private final boolean noLocal;
 
     public EventFilter(ReadOnlyNodeTypeManager ntMgr,
             NamePathMapper namePathMapper, int eventTypes,
-            String path, boolean deep, String[] uuid,
+            String path, boolean deep, String[] uuids,
             String[] nodeTypeName, boolean noLocal)
             throws NoSuchNodeTypeException, RepositoryException {
         this.ntMgr = ntMgr;
@@ -56,7 +59,7 @@ class EventFilter {
         this.eventTypes = eventTypes;
         this.path = path;
         this.deep = deep;
-        this.uuid = uuid;
+        this.uuids = uuids;
         this.nodeTypeOakName = validateNodeTypeNames(nodeTypeName);
         this.noLocal = noLocal;
     }
@@ -64,8 +67,8 @@ class EventFilter {
     public boolean include(int eventType, String path, @Nullable NodeState associatedParentNode)
{
         return include(eventType)
                 && include(path)
-                && (associatedParentNode == null
-                    || includeByType(new ReadOnlyTree(associatedParentNode)));
+                && (associatedParentNode == null || includeByType(new ReadOnlyTree(associatedParentNode)))
+                && (associatedParentNode == null || includeByUuid(associatedParentNode));
     }
 
     public boolean includeChildren(String path) {
@@ -84,7 +87,7 @@ class EventFilter {
                 .add("types", eventTypes)
                 .add("path", path)
                 .add("deep", deep)
-                .add("uuids", uuid)
+                .add("uuids", uuids)
                 .add("node types", nodeTypeOakName)
                 .add("noLocal", noLocal)
             .toString();
@@ -129,6 +132,28 @@ class EventFilter {
         }
     }
 
+    private boolean includeByUuid(NodeState associatedParentNode) {
+        if (uuids == null) {
+            return true;
+        }
+        if (uuids.length == 0) {
+            return false;
+        }
+
+        PropertyState uuidProperty = associatedParentNode.getProperty(JcrConstants.JCR_UUID);
+        if (uuidProperty == null) {
+            return false;
+        }
+
+        String parentUuid = uuidProperty.getValue(Type.STRING);
+        for (String uuid : uuids) {
+            if (parentUuid.equals(uuid)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     /**
      * Validates the given node type names.
      *

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1489815&r1=1489814&r2=1489815&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Wed Jun  5 11:26:03 2013
@@ -231,7 +231,6 @@
       org.apache.jackrabbit.test.api.observation.GetIdentifierTest#testPropertyAdded
       org.apache.jackrabbit.test.api.observation.GetIdentifierTest#testPropertyChanged
       org.apache.jackrabbit.test.api.observation.GetIdentifierTest#testPropertyRemoved
-      org.apache.jackrabbit.test.api.observation.AddEventListenerTest#testUUID
       org.apache.jackrabbit.test.api.observation.LockingTest#testAddLockToNode
       org.apache.jackrabbit.test.api.observation.LockingTest#testRemoveLockFromNode
       <!-- Versioning -->



Mime
View raw message