incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1240974 - /sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/MapEntries.java
Date Mon, 06 Feb 2012 10:57:03 GMT
Author: fmeschbe
Date: Mon Feb  6 10:57:03 2012
New Revision: 1240974

URL: http://svn.apache.org/viewvc?rev=1240974&view=rev
Log:
SLING-2403 Ignore /jcr:system subtree events and vanity paths

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

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/MapEntries.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/MapEntries.java?rev=1240974&r1=1240973&r2=1240974&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/MapEntries.java
(original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/MapEntries.java
Mon Feb  6 10:57:03 2012
@@ -65,6 +65,8 @@ public class MapEntries implements Event
 
     public static final String DEFAULT_MAP_ROOT = "/etc/map";
 
+    private static final String JCR_SYSTEM_PREFIX = "/jcr:system/";
+
     static final String ANY_SCHEME_HOST = "[^/]+/[^/]+";
 
     /** default log */
@@ -174,10 +176,10 @@ public class MapEntries implements Event
      * has been null-ed after having been triggered.
      */
     void init() {
-        while (MapEntries.this.resolver != null) {
+        while (this.resolver != null) {
             try {
-                MapEntries.this.initTrigger.acquire();
-                MapEntries.this.doInit();
+                this.initTrigger.acquire();
+                this.doInit();
             } catch (InterruptedException ie) {
                 // just continue acquisition
             }
@@ -307,21 +309,30 @@ public class MapEntries implements Event
      * appropriate events.
      */
     public void handleEvent(final Event event) {
+
+        // check for path (used for some tests below
+        final Object p = event.getProperty(SlingConstants.PROPERTY_PATH);
+        final String path;
+        if (p instanceof String) {
+            path = (String) p;
+        } else {
+            // not a string path or null, ignore this event
+            return;
+        }
+
+        // don't care for system area
+        if (path.startsWith(JCR_SYSTEM_PREFIX)) {
+            return;
+        }
+
         // check whether a remove event has an influence on vanity paths
         boolean doInit = true;
-        if (SlingConstants.TOPIC_RESOURCE_REMOVED.equals(event.getTopic())) {
+        if (SlingConstants.TOPIC_RESOURCE_REMOVED.equals(event.getTopic()) && !path.startsWith(this.mapRoot))
{
             doInit = false;
-            final Object p = event.getProperty(SlingConstants.PROPERTY_PATH);
-            if (p instanceof String) {
-                final String path = (String) p;
-                doInit = path.startsWith(this.mapRoot);
-                if (!doInit) {
-                    for (String target : this.vanityTargets) {
-                        if (target.startsWith(path)) {
-                            doInit = true;
-                            break;
-                        }
-                    }
+            for (String target : this.vanityTargets) {
+                if (target.startsWith(path)) {
+                    doInit = true;
+                    break;
                 }
             }
         }
@@ -419,8 +430,17 @@ public class MapEntries implements Event
             queryString, "sql");
         while (i.hasNext()) {
             Resource resource = i.next();
+
+            // ignore system tree
+            if (resource.getPath().startsWith(JCR_SYSTEM_PREFIX)) {
+                log.debug("loadVanityPaths: Ignoring {}", resource);
+                continue;
+            }
+
+            // require properties
             ValueMap row = resource.adaptTo(ValueMap.class);
             if (row == null) {
+                log.debug("loadVanityPaths: Ignoring {} without properties", resource);
                 continue;
             }
 



Mime
View raw message