incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r592053 - /incubator/sling/trunk/event/src/main/java/org/apache/sling/event/impl/TimedEventHandler.java
Date Mon, 05 Nov 2007 16:02:01 GMT
Author: cziegeler
Date: Mon Nov  5 08:02:00 2007
New Revision: 592053

URL: http://svn.apache.org/viewvc?rev=592053&view=rev
Log:
Synchronize removal of nodes for date based timed events. This should fix SLING-96.

Modified:
    incubator/sling/trunk/event/src/main/java/org/apache/sling/event/impl/TimedEventHandler.java

Modified: incubator/sling/trunk/event/src/main/java/org/apache/sling/event/impl/TimedEventHandler.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/event/src/main/java/org/apache/sling/event/impl/TimedEventHandler.java?rev=592053&r1=592052&r2=592053&view=diff
==============================================================================
--- incubator/sling/trunk/event/src/main/java/org/apache/sling/event/impl/TimedEventHandler.java
(original)
+++ incubator/sling/trunk/event/src/main/java/org/apache/sling/event/impl/TimedEventHandler.java
Mon Nov  5 08:02:00 2007
@@ -194,7 +194,9 @@
                     if ( EventUtil.isLocal(event) ) {
                         // if the node is present, we check if the timed event is based on
                         // a date and has already expired
-                        if ( foundNode != null && scheduleInfo.date != null &&
foundNode.hasProperty(EventHelper.NODE_PROPERTY_TE_DATE) ) {
+                        if ( foundNode != null
+                            && scheduleInfo.date != null
+                            && foundNode.hasProperty(EventHelper.NODE_PROPERTY_TE_DATE)
) {
                             final Calendar oldScheduledDate = foundNode.getProperty(EventHelper.NODE_PROPERTY_TE_DATE).getDate();
                             final Calendar now = Calendar.getInstance();
                             if ( oldScheduledDate.compareTo(now) <= 0 ) {
@@ -384,18 +386,29 @@
             Session s = null;
             try {
                 s = this.createSession();
-                final Node eventNode = this.queryJob(session, info.jobId);
-                if ( eventNode != null ) {
-                    try {
-                        eventNode.remove();
-                        session.save();
-                    } catch (RepositoryException re) {
-                        // we ignore the exception if removing fails
-                        ignoreException(re);
+                final Session mySession = s;
+                final Node parentNode = (Node)s.getItem(this.repositoryPath);
+                new Locked() {
+
+                    protected Object run(Node node) throws RepositoryException {
+                        final Node eventNode = queryJob(mySession, info.jobId);
+                        if ( eventNode != null ) {
+                            try {
+                                eventNode.remove();
+                                parentNode.save();
+                            } catch (RepositoryException re) {
+                                // we ignore the exception if removing fails
+                                ignoreException(re);
+                            }
+                        }
+                        return null;
                     }
-                }
+                }.with(parentNode, false);
             } catch (RepositoryException re) {
                 this.logger.error("Unable to create a session.", re);
+            } catch (InterruptedException e) {
+                 // This should never happen from the lock, so we ignore it
+                 this.ignoreException(e);
             } finally {
                 if ( s != null ) {
                     s.logout();



Mime
View raw message