You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2011/11/22 15:14:53 UTC

svn commit: r1205007 - /sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceListener.java

Author: fmeschbe
Date: Tue Nov 22 14:14:52 2011
New Revision: 1205007

URL: http://svn.apache.org/viewvc?rev=1205007&view=rev
Log:
SLING-2296 Make sure the event path is changed if the event is for the jcr:content child node of an nt:file node. Also log an error message if the resource for the changed/added node cannot be retrieved from the resource resolver.

Modified:
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceListener.java

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceListener.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceListener.java?rev=1205007&r1=1205006&r2=1205007&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceListener.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceListener.java Tue Nov 22 14:14:52 2011
@@ -271,7 +271,6 @@ public class JcrResourceListener impleme
         path = createWorkspacePath(path);
 
         final Dictionary<String, Object> properties = new Hashtable<String, Object>();
-        properties.put(SlingConstants.PROPERTY_PATH, path);
         properties.put(SlingConstants.PROPERTY_USERID, event.getUserID());
         if ( this.isExternal(event) ) {
             properties.put("event.application", "unknown");
@@ -293,6 +292,7 @@ public class JcrResourceListener impleme
                                 final Resource parentResource = ResourceUtil.getParent(resource);
                                 if (parentResource != null) {
                                     resource = parentResource;
+                                    path = resource.getPath();
                                 }
                             }
                         } catch (RepositoryException re) {
@@ -309,9 +309,16 @@ public class JcrResourceListener impleme
                 if (resourceSuperType != null) {
                     properties.put(SlingConstants.PROPERTY_RESOURCE_SUPER_TYPE, resource.getResourceSuperType());
                 }
+            } else {
+                logger.error(
+                    "sendOsgiEvent: Resource at {} not found, which is not expected for an added or modified node",
+                    path);
             }
         }
 
+        // set the path (might have been changed for nt:file content)
+        properties.put(SlingConstants.PROPERTY_PATH, path);
+
         localEA.postEvent(new org.osgi.service.event.Event(topic, properties));
     }