jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r781295 - in /jackrabbit/trunk: jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/ jackrabbit-webdav/src/main/java/org/apache/jackrabbit/we...
Date Wed, 03 Jun 2009 08:25:16 GMT
Author: angela
Date: Wed Jun  3 08:25:16 2009
New Revision: 781295

URL: http://svn.apache.org/viewvc?rev=781295&view=rev
Log:
JCR-2108: JSR 283 Observation   (work in progress)

- adjust jcr-server

Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java?rev=781295&r1=781294&r2=781295&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
Wed Jun  3 08:25:16 2009
@@ -736,7 +736,13 @@
      */
     class EListener implements EventListener {
 
-        private static final int ALL_EVENTS = Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_ADDED
| Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED;
+        private static final int ALL_EVENTS = Event.NODE_ADDED
+                | Event.NODE_REMOVED
+                | Event.PROPERTY_ADDED
+                | Event.PROPERTY_CHANGED
+                | Event.PROPERTY_REMOVED
+                | Event.NODE_MOVED
+                | Event.PERSIST;
 
         private final DavPropertyNameSet propNameSet;
         private MultiStatus ms;

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=781295&r1=781294&r2=781295&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
Wed Jun  3 08:25:16 2009
@@ -34,6 +34,7 @@
 import org.apache.jackrabbit.webdav.observation.SubscriptionInfo;
 import org.apache.jackrabbit.webdav.observation.DefaultEventType;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.webdav.xml.Namespace;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -48,6 +49,7 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 /**
  * The <code>Subscription</code> class encapsulates a single subscription with
@@ -92,6 +94,18 @@
      */
     private static final String EVENT_PROPERTYCHANGED = "propertychanged";
 
+    /**
+     * Element representing the 'nodemoved' event type.
+     * @see javax.jcr.observation.Event#NODE_MOVED
+     */
+    private static final String EVENT_NODEMOVED = "nodemoved";
+
+    /**
+     * Element representing the 'persist' event type.
+     * @see javax.jcr.observation.Event#PERSIST
+     */
+    private static final String EVENT_PERSIST = "persist";
+
     private SubscriptionInfo info;
     private long expirationTime;
 
@@ -383,6 +397,8 @@
      * <li>{@link Event#PROPERTY_ADDED}</li>
      * <li>{@link Event#PROPERTY_REMOVED}</li>
      * <li>{@link Event#PROPERTY_CHANGED}</li>
+     * <li>{@link Event#NODE_MOVED}</li>
+     * <li>{@link Event#PERSIST}</li>
      * </ul>
      */
     public static EventType getEventType(int jcrEventType) {
@@ -403,6 +419,12 @@
             case Event.PROPERTY_REMOVED:
                 localName = EVENT_PROPERTYREMOVED;
                 break;
+            case Event.NODE_MOVED:
+                localName = EVENT_NODEMOVED;
+                break;
+            case Event.PERSIST:
+                localName = EVENT_PERSIST;
+                break;
             default: // no default
                 throw new IllegalArgumentException("Invalid JCR event type: " + jcrEventType);
         }
@@ -423,6 +445,8 @@
      * <li>{@link Event#PROPERTY_ADDED}</li>
      * <li>{@link Event#PROPERTY_REMOVED}</li>
      * <li>{@link Event#PROPERTY_CHANGED}</li>
+     * <li>{@link Event#NODE_MOVED}</li>
+     * <li>{@link Event#PERSIST}</li>
      * </ul>
      * @throws DavException if the given event type does not define a valid
      * JCR event type, such as returned by {@link #getEventType(int)}.
@@ -443,6 +467,10 @@
             eType = Event.PROPERTY_CHANGED;
         } else if (EVENT_PROPERTYREMOVED.equals(eventName)) {
             eType = Event.PROPERTY_REMOVED;
+        } else if (EVENT_NODEMOVED.equals(eventName)) {
+            eType = Event.NODE_MOVED;
+        } else if (EVENT_PERSIST.equals(eventName)) {
+            eType = Event.PERSIST;
         } else {
             throw new DavException(DavServletResponse.SC_UNPROCESSABLE_ENTITY, "Invalid event
type: "+eventName);
         }
@@ -495,6 +523,42 @@
                 eType.appendChild(getEventType(event.getType()).toXml(document));
                 // user id
                 DomUtil.addChildElement(eventElem, XML_EVENTUSERID, NAMESPACE, event.getUserID());
+
+                // Additional JCR 2.0 event information
+                // userdata
+                try {
+                    DomUtil.addChildElement(eventElem, XML_EVENTUSERDATA, NAMESPACE, event.getUserData());
+                } catch (RepositoryException e) {
+                    log.error("Internal error while retrieving event user data.", e.getMessage());
+                }
+                // timestamp
+                try {
+                    DomUtil.addChildElement(eventElem, XML_EVENTDATE, NAMESPACE, String.valueOf(event.getDate()));
+                } catch (RepositoryException e) {
+                    log.error("Internal error while retrieving event date.", e.getMessage());
+                }
+                // identifier
+                try {
+                    DomUtil.addChildElement(eventElem, XML_EVENTIDENTIFIER, NAMESPACE, event.getIdentifier());
+                } catch (RepositoryException e) {
+                    log.error("Internal error while retrieving event identifier.", e.getMessage());
+                }
+                // info
+                Element info = DomUtil.addChildElement(eventElem, XML_EVENTINFO, NAMESPACE);
+                try {
+                    Map m = event.getInfo();
+                    for (Iterator it = m.keySet().iterator(); it.hasNext();) {
+                        String key = it.next().toString();
+                        Object value = m.get(key);
+                        if (value != null) {
+                            DomUtil.addChildElement(info, key, Namespace.EMPTY_NAMESPACE,
value.toString());
+                        } else {
+                            DomUtil.addChildElement(info, key, Namespace.EMPTY_NAMESPACE);
+                        }
+                    }
+                } catch (RepositoryException e) {
+                    log.error("Internal error while retrieving event info.", e.getMessage());
+                }
             }
             return bundle;
         }

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java?rev=781295&r1=781294&r2=781295&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java
Wed Jun  3 08:25:16 2009
@@ -69,7 +69,11 @@
     public static final String XML_EVENT_TRANSACTION_ID = "transactionid";
     public static final String XML_EVENT = "event";
     public static final String XML_EVENTUSERID = "eventuserid";
-
+    public static final String XML_EVENTUSERDATA = "eventuserdata";
+    public static final String XML_EVENTDATE = "eventdate";
+    public static final String XML_EVENTIDENTIFIER = "eventidentifier";
+    public static final String XML_EVENTINFO = "eventinfo";
+    
     //---< Property Names >-----------------------------------------------------
     /**
      * The protected subscription discovery property is used to find out about



Mime
View raw message