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 2012/12/03 14:57:01 UTC

svn commit: r1416522 - /sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java

Author: cziegeler
Date: Mon Dec  3 13:57:01 2012
New Revision: 1416522

URL: http://svn.apache.org/viewvc?rev=1416522&view=rev
Log:
SLING-2691 :  Correctly update mapping if a jcr:content node is removed 

Modified:
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java

Modified: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java?rev=1416522&r1=1416521&r2=1416522&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java (original)
+++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java Mon Dec  3 13:57:01 2012
@@ -360,15 +360,21 @@ public class MapEntries implements Event
         // check whether a remove event has an influence on vanity paths
         boolean doInit = true;
         if (SlingConstants.TOPIC_RESOURCE_REMOVED.equals(event.getTopic()) && !path.startsWith(this.mapRoot)) {
+            final String checkPath;
+            if ( path.endsWith("/jcr:content") ) {
+                checkPath = path.substring(0, path.length() - 12);
+            } else {
+                checkPath = path;
+            }
             doInit = false;
             for (final String target : this.vanityTargets) {
-                if (target.startsWith(path)) {
+                if (target.startsWith(checkPath)) {
                     doInit = true;
                     break;
                 }
             }
             for (final String target : this.aliasMap.keySet()) {
-                if (target.startsWith(path)) {
+                if (target.startsWith(checkPath)) {
                     doInit = true;
                     break;
                 }
@@ -747,7 +753,7 @@ public class MapEntries implements Event
                         PROP_REDIRECT_EXTERNAL_REDIRECT_STATUS, PROP_REDIRECT_EXTERNAL,
                         ResourceResolverImpl.PROP_REDIRECT_INTERNAL, PROP_REDIRECT_EXTERNAL_STATUS,
                         PROP_REG_EXP, ResourceResolverImpl.PROP_ALIAS };
-        final String[] eventProps = { "resourceAddedAttributes", "resourceChangedAttributes", "resourceRemovedAttributes" };
+        final String[] eventProps = { SlingConstants.PROPERTY_ADDED_ATTRIBUTES, SlingConstants.PROPERTY_CHANGED_ATTRIBUTES, SlingConstants.PROPERTY_REMOVED_ATTRIBUTES };
         final StringBuilder filter = new StringBuilder();
         filter.append("(|");
         for (final String eventProp : eventProps) {
@@ -757,7 +763,7 @@ public class MapEntries implements Event
             }
             filter.append(")");
         }
-        filter.append("(" + EventConstants.EVENT_TOPIC + "=" + SlingConstants.TOPIC_RESOURCE_REMOVED + ")");
+        filter.append("(").append(EventConstants.EVENT_TOPIC).append("=").append(SlingConstants.TOPIC_RESOURCE_REMOVED).append(")");
         filter.append(")");
 
         return filter.toString();