incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r689917 - in /incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl: AbstractRepositoryEventHandler.java EventHelper.java JobEventHandler.java
Date Thu, 28 Aug 2008 17:59:25 GMT
Author: cziegeler
Date: Thu Aug 28 10:59:25 2008
New Revision: 689917

URL: http://svn.apache.org/viewvc?rev=689917&view=rev
Log:
Check if the job node has been removed in the meantime from the repository and store node
path into resulting event object.

Modified:
    incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
    incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/EventHelper.java
    incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java

Modified: incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java?rev=689917&r1=689916&r2=689917&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
(original)
+++ incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
Thu Aug 28 10:59:25 2008
@@ -103,6 +103,7 @@
     private static final String[] IGNORE_PROPERTIES = new String[] {
         EventUtil.PROPERTY_DISTRIBUTE,
         EventUtil.PROPERTY_APPLICATION,
+        EventHelper.NODE_PROPERTY_NODE_PATH,
         EventUtil.JobStatusNotifier.CONTEXT_PROPERTY_NAME
     };
 
@@ -310,6 +311,7 @@
                 EventHelper.NODE_PROPERTY_PROPERTIES,
                 IGNORE_PREFIXES);
 
+        eventProps.put(EventHelper.NODE_PROPERTY_NODE_PATH, eventNode.getPath());
         this.addEventProperties(eventNode, eventProps);
         try {
             final Event event = new Event(topic, eventProps);

Modified: incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/EventHelper.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/EventHelper.java?rev=689917&r1=689916&r2=689917&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/EventHelper.java
(original)
+++ incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/EventHelper.java
Thu Aug 28 10:59:25 2008
@@ -34,6 +34,7 @@
     public static final String NODE_PROPERTY_PROPERTIES = "slingevent:properties";
     public static final String NODE_PROPERTY_PROCESSOR = "slingevent:processor";
     public static final String NODE_PROPERTY_JOBID = "slingevent:id";
+    public static final String NODE_PROPERTY_NODE_PATH = "slingevent:nodePath";
     public static final String NODE_PROPERTY_FINISHED = "slingevent:finished";
     public static final String NODE_PROPERTY_TE_EXPRESSION = "slingevent:expression";
     public static final String NODE_PROPERTY_TE_DATE = "slingevent:date";

Modified: incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java?rev=689917&r1=689916&r2=689917&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
(original)
+++ incubator/sling/trunk/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
Thu Aug 28 10:59:25 2008
@@ -25,7 +25,6 @@
 import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -319,8 +318,7 @@
         this.backgroundSession.getWorkspace().getObservationManager()
                 .addEventListener(this,
                                   javax.jcr.observation.Event.PROPERTY_REMOVED
-                                    |javax.jcr.observation.Event.NODE_REMOVED
-                                    |javax.jcr.observation.Event.PROPERTY_CHANGED,
+                                    |javax.jcr.observation.Event.NODE_REMOVED,
                                   this.repositoryPath,
                                   true,
                                   null,
@@ -782,19 +780,18 @@
     }
 
     /**
-     * Create the job event.
-     * @param e
-     * @return
+     * Create the real job event.
+     * This generates a new event object with the same properties, but with the
+     * {@link EventUtil#PROPERTY_JOB_TOPIC} topic.
+     * @param e The job event.
+     * @return The real job event.
      */
     private Event getJobEvent(Event e, String nodePath) {
         final String eventTopic = (String)e.getProperty(EventUtil.PROPERTY_JOB_TOPIC);
-        final Dictionary<String, Object> properties = new Hashtable<String, Object>();
-        final String[] propertyNames = e.getPropertyNames();
-        for(int i=0; i<propertyNames.length; i++) {
-            properties.put(propertyNames[i], e.getProperty(propertyNames[i]));
-        }
+        final Dictionary<String, Object> properties = new EventPropertiesMap(e);
         // put properties for finished job callback
-        properties.put(EventUtil.JobStatusNotifier.CONTEXT_PROPERTY_NAME, new EventUtil.JobStatusNotifier.NotifierContext(this,
nodePath));
+        properties.put(EventUtil.JobStatusNotifier.CONTEXT_PROPERTY_NAME,
+                new EventUtil.JobStatusNotifier.NotifierContext(this, nodePath));
         return new Event(eventTopic, properties);
     }
 
@@ -883,9 +880,6 @@
                     } catch (RepositoryException re) {
                         this.logger.error("Exception during jcr event processing.", re);
                     }
-                } else if ( event.getType() == javax.jcr.observation.Event.NODE_REMOVED )
{
-                    final String nodePath = event.getPath();
-                    // TODO Cancel job
                 }
             }
         } catch (RepositoryException re) {
@@ -977,6 +971,10 @@
         synchronized ( this.backgroundSession ) {
             try {
                 this.backgroundSession.refresh(false);
+                // check if the job has been cancelled
+                if ( !this.backgroundSession.itemExists(eventNodePath) ) {
+                    return true;
+                }
                 final Node eventNode = (Node) this.backgroundSession.getItem(eventNodePath);
                 boolean unlock = true;
                 try {



Mime
View raw message