jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1202201 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ jackrabbit-jcr-server/ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/ jackrabbit-jcr2dav/ jackrabbit-s...
Date Tue, 15 Nov 2011 14:17:52 GMT
Author: reschke
Date: Tue Nov 15 14:17:52 2011
New Revision: 1202201

URL: http://svn.apache.org/viewvc?rev=1202201&view=rev
Log:
JCR-2542: spi2dav: EventFilters not respected

Add node type information to Jackrabbit events through an extension interface; serialize them
in JCR server, process them in spi2dav repository service; this fixes filtering by node types.


Added:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AdditionalEventInfo.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
    jackrabbit/trunk/jackrabbit-jcr-server/pom.xml
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
    jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml
    jackrabbit/trunk/jackrabbit-spi2dav/pom.xml
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java?rev=1202201&r1=1202200&r2=1202201&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
Tue Nov 15 14:17:52 2011
@@ -18,13 +18,16 @@ package org.apache.jackrabbit.core.obser
 
 import java.util.Map;
 import java.util.HashMap;
+import java.util.Set;
 
 import org.apache.jackrabbit.api.observation.JackrabbitEvent;
 import javax.jcr.observation.Event;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.value.InternalValue;
+import org.apache.jackrabbit.spi.commons.AdditionalEventInfo;
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
+import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
@@ -37,7 +40,7 @@ import javax.jcr.RepositoryException;
  * Implementation of the {@link javax.jcr.observation.Event} and
  * the {@link JackrabbitEvent} interface.
  */
-public final class EventImpl implements JackrabbitEvent, Event {
+public final class EventImpl implements JackrabbitEvent, AdditionalEventInfo, Event {
 
     /**
      * Logger instance for this class
@@ -221,6 +224,22 @@ public final class EventImpl implements 
     }
 
     /**
+     * @return the primary node type of the node associated with the event
+     * @see AdditionalEventInfo#getPrimaryNodeTypeName()
+     */
+    public Name getPrimaryNodeTypeName() {
+        return eventState.getNodeType();
+    }
+    
+    /**
+     * @return the mixin node types of the node associated with the event
+     * @see AdditionalEventInfo#getMixinTypeNames()
+     */
+    public Set<Name> getMixinTypeNames() {
+        return eventState.getMixinNames();
+    }
+
+    /**
      * Returns a String representation of this <code>Event</code>.
      *
      * @return a String representation of this <code>Event</code>.

Modified: jackrabbit/trunk/jackrabbit-jcr-server/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/pom.xml?rev=1202201&r1=1202200&r2=1202201&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/pom.xml Tue Nov 15 14:17:52 2011
@@ -95,6 +95,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-spi-commons</artifactId>
+      <version>2.4-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-jcr-commons</artifactId>
       <version>2.4-SNAPSHOT</version>
     </dependency>

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java?rev=1202201&r1=1202200&r2=1202201&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
Tue Nov 15 14:17:52 2011
@@ -17,13 +17,15 @@
 package org.apache.jackrabbit.webdav.jcr.observation;
 
 import org.apache.jackrabbit.commons.webdav.EventUtil;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.commons.AdditionalEventInfo;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
 import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.transaction.TransactionResource;
 import org.apache.jackrabbit.webdav.jcr.transaction.TransactionListener;
-import org.apache.jackrabbit.webdav.jcr.JcrDavSession;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
+import org.apache.jackrabbit.webdav.jcr.JcrDavSession;
 import org.apache.jackrabbit.webdav.observation.EventBundle;
 import org.apache.jackrabbit.webdav.observation.EventDiscovery;
 import org.apache.jackrabbit.webdav.observation.EventType;
@@ -450,6 +452,15 @@ public class SubscriptionImpl implements
                 // user id
                 DomUtil.addChildElement(eventElem, XML_EVENTUSERID, NAMESPACE, event.getUserID());
 
+                if (event instanceof AdditionalEventInfo) {
+                    DomUtil.addChildElement(eventElem, "primarynodetype", NAMESPACE,
+                            ((AdditionalEventInfo)event).getPrimaryNodeTypeName().toString());
+                    for (Name mixin : ((AdditionalEventInfo)event).getMixinTypeNames()) {
+                        DomUtil.addChildElement(eventElem, "mixinnodetype", NAMESPACE,
+                                mixin.toString());
+                    }
+                }
+
                 // Additional JCR 2.0 event information
                 // user data
                 try {

Modified: jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml?rev=1202201&r1=1202200&r2=1202201&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml Tue Nov 15 14:17:52 2011
@@ -81,7 +81,6 @@
                       <!-- JCR-2541 : event journal -->
                       org.apache.jackrabbit.test.api.observation.EventJournalTest
                       <!-- JCR-2542 : event filter -->
-                      org.apache.jackrabbit.test.api.observation.AddEventListenerTest#testNodeType
                       org.apache.jackrabbit.test.api.observation.AddEventListenerTest#testNoLocalTrue
                       <!-- JCR-2533 : missing impl of checkQueryStatement -->     
                
                       org.apache.jackrabbit.test.api.query.CreateQueryTest#testUnknownQueryLanguage

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AdditionalEventInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AdditionalEventInfo.java?rev=1202201&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AdditionalEventInfo.java
(added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AdditionalEventInfo.java
Tue Nov 15 14:17:52 2011
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.commons;
+
+import java.util.Set;
+
+import org.apache.jackrabbit.spi.Event;
+import org.apache.jackrabbit.spi.Name;
+
+/**
+ * Provides additional information for an {@link Event}.
+ */
+public interface AdditionalEventInfo {
+
+	/**
+	 * @return the name of the primary node type of the node associated with the event
+	 */
+    public Name getPrimaryNodeTypeName();
+    
+	/**
+	 * @return the names of the mixin node types of the node associated with the event
+	 */
+    public Set<Name> getMixinTypeNames();
+}

Modified: jackrabbit/trunk/jackrabbit-spi2dav/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/pom.xml?rev=1202201&r1=1202200&r2=1202201&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/pom.xml Tue Nov 15 14:17:52 2011
@@ -78,7 +78,6 @@
                   <!-- JCR-2541 : event journal -->
                   org.apache.jackrabbit.test.api.observation.EventJournalTest
                   <!-- JCR-2542 : event filter -->
-                  org.apache.jackrabbit.test.api.observation.AddEventListenerTest#testNodeType
                   org.apache.jackrabbit.test.api.observation.AddEventListenerTest#testNoLocalTrue
                   <!-- JCR-2533 : missing impl of checkQueryStatement -->
                   org.apache.jackrabbit.test.api.query.CreateQueryTest#testUnknownQueryLanguage

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java?rev=1202201&r1=1202200&r2=1202201&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java
Tue Nov 15 14:17:52 2011
@@ -24,6 +24,7 @@ import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
@@ -35,10 +36,14 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Element;
 
+import javax.jcr.NamespaceException;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
+
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -53,10 +58,10 @@ public class EventImpl
     private static final NameFactory N_FACTORY = NameFactoryImpl.getInstance();
 
     public EventImpl(ItemId eventId, Path eventPath, NodeId parentId, int eventType,
-                     Element eventElement, NamePathResolver resolver, QValueFactory qvFactory)
{
+                     Element eventElement, NamePathResolver resolver, QValueFactory qvFactory)
throws NamespaceException, IllegalNameException {
         super(getSpiEventType(eventType), eventPath, eventId, parentId,
-                null, // TODO not available from XML_EVENT element
-                null, // TODO not available from XML_EVENT element
+                resolver.getQName(DomUtil.getChildTextTrim(eventElement, "primarynodetype",
NAMESPACE)),
+                getNames(DomUtil.getChildren(eventElement, "mixinnodetype", NAMESPACE), resolver),
                 DomUtil.getChildTextTrim(eventElement, XML_EVENTUSERID, NAMESPACE),
                 DomUtil.getChildTextTrim(eventElement, XML_EVENTUSERDATA, NAMESPACE),
                 Long.parseLong(DomUtil.getChildTextTrim(eventElement, XML_EVENTDATE, NAMESPACE)),
@@ -115,4 +120,32 @@ public class EventImpl
         }
         return info;
     }
-}
+
+    private static Name[] getNames(ElementIterator elements,
+            NamePathResolver resolver) {
+
+        List<Name> results = Collections.emptyList();
+
+        while (elements.hasNext()) {
+            String rawname = DomUtil.getText(elements.nextElement());
+            Name name = null;
+
+            try {
+                name = resolver.getQName(rawname);
+
+                if (results.size() == 0) {
+                    results = Collections.singletonList(name);
+                } else if (results.size() == 1) {
+                    results = new ArrayList<Name>(results);
+                    results.add(name);
+                } else {
+                    results.add(name);
+                }
+            } catch (Exception ex) {
+                log.error("Exception converting name " + rawname, ex);
+            }
+        }
+
+        return results.toArray(new Name[results.size()]);
+    }
+}
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=1202201&r1=1202200&r2=1202201&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Tue Nov 15 14:17:52 2011
@@ -2025,9 +2025,7 @@ public class RepositoryServiceImpl imple
         for (EventFilter ef : filters) {
             if (ef instanceof EventFilterImpl) {
                 EventFilterImpl efi = (EventFilterImpl)ef;
-                if (efi.getNodeTypeNames() != null && ! efi.getNodeTypeNames().isEmpty())
{
-                    throw new UnsupportedRepositoryOperationException("This SPI implementation
does not support filtering by node types (see issue JCR-2542)");
-                }
+                // TODO: add code that verifies that the remote server can send node type
information
                 if (efi.getNoLocal()) {
                     throw new UnsupportedRepositoryOperationException("This SPI implementation
does not support filtering using the 'noLocal' flag (see issue JCR-2542)");
                 }
@@ -2150,7 +2148,7 @@ public class RepositoryServiceImpl imple
         }
     }
 
-    private List<Event> buildEventList(Element bundleElement, SessionInfoImpl sessionInfo)
{
+    private List<Event> buildEventList(Element bundleElement, SessionInfoImpl sessionInfo)
throws IllegalNameException, NamespaceException {
         List<Event> events = new ArrayList<Event>();
         ElementIterator eventElementIterator = DomUtil.getChildren(bundleElement, ObservationConstants.XML_EVENT,
ObservationConstants.NAMESPACE);
         while (eventElementIterator.hasNext()) {



Mime
View raw message