You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2014/04/02 12:30:20 UTC
svn commit: r1583954 - in
/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal:
OakResourceListener.java ObservationListenerSupport.java
Author: cziegeler
Date: Wed Apr 2 10:30:19 2014
New Revision: 1583954
URL: http://svn.apache.org/r1583954
Log:
SLING-3487: Resource added events missing when using new OakResourceListener. Minor code modifications and make sure to refresh the session for plain jcr listener as well
Modified:
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/OakResourceListener.java
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ObservationListenerSupport.java
Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/OakResourceListener.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/OakResourceListener.java?rev=1583954&r1=1583953&r2=1583954&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/OakResourceListener.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/OakResourceListener.java Wed Apr 2 10:30:19 2014
@@ -161,11 +161,13 @@ public class OakResourceListener extends
final Map<String, Object> changes,
final Map<String, String> properties) {
// set the path (will be changed for nt:file jcr:content sub resource)
+ final String changePath;
if ( this.mountPrefix == null ) {
- changes.put(PROPERTY_PATH, path);
+ changePath = path;
} else {
- changes.put(PROPERTY_PATH, this.mountPrefix + path);
+ changePath = this.mountPrefix + path;
}
+ changes.put(PROPERTY_PATH, changePath);
try {
final EventAdmin localEa = this.support.getEventAdmin();
@@ -183,13 +185,11 @@ public class OakResourceListener extends
sendEvent = false;
logger.debug("resource resolver is null");
} else {
- resolver.refresh();
- String changesPath = (String)changes.get(PROPERTY_PATH);
- final Resource rsrc = resolver.getResource(changesPath);
+ final Resource rsrc = resolver.getResource(changePath);
if ( rsrc == null ) {
resolver.refresh();
sendEvent = false;
- logger.debug("not able to get resource for changes path {}", changesPath);
+ logger.debug("not able to get resource for changes path {}", changePath);
} else {
// check if this is a JCR backed resource, otherwise it is not visible!
final Node node = rsrc.adaptTo(Node.class);
@@ -212,7 +212,7 @@ public class OakResourceListener extends
} else {
// this is not a jcr backed resource
sendEvent = false;
- logger.debug("not able to adapt resource {} to node", rsrc.getPath());
+ logger.debug("not able to adapt resource {} to node", changePath);
}
}
@@ -222,7 +222,7 @@ public class OakResourceListener extends
// resolve the resource
logger.warn(
"processOsgiEventQueue: Resource at {} not found, which is not expected for an added or modified node",
- path);
+ changePath);
}
}
Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ObservationListenerSupport.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ObservationListenerSupport.java?rev=1583954&r1=1583953&r2=1583954&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ObservationListenerSupport.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ObservationListenerSupport.java Wed Apr 2 10:30:19 2014
@@ -114,6 +114,9 @@ public class ObservationListenerSupport
}
}
}
+ if ( this.resourceResolver != null ) {
+ this.resourceResolver.refresh();
+ }
return this.resourceResolver;
}
}