Author: cziegeler
Date: Fri Sep 14 12:28:28 2012
New Revision: 1384739
URL: http://svn.apache.org/viewvc?rev=1384739&view=rev
Log:
SLING-2598 : Don't process already defined vanity paths
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=1384739&r1=1384738&r2=1384739&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
Fri Sep 14 12:28:28 2012
@@ -525,9 +525,11 @@ public class MapEntries implements Event
// sling:VanityPath (uppercase V) is the mixin name
// sling:vanityPath (lowercase) is the property name
final Set<String> targetPaths = new HashSet<String>();
- final String queryString = "SELECT sling:vanityPath, sling:redirect, sling:redirectStatus
FROM sling:VanityPath WHERE sling:vanityPath IS NOT NULL ORDER BY sling:vanityOrder DESC";
+ final String queryString = "SELECT sling:vanityPath, sling:redirect, sling:redirectStatus,
sling:vanityOrder FROM sling:VanityPath WHERE sling:vanityPath IS NOT NULL ORDER BY sling:vanityOrder
DESC";
final Iterator<Resource> i = resolver.findResources(queryString, "sql");
+ final Set<String> processedVanityPaths = new HashSet<String>();
+
while (i.hasNext()) {
final Resource resource = i.next();
@@ -552,33 +554,36 @@ public class MapEntries implements Event
if (result != null) {
final String url = result[0] + result[1];
- // redirect target is the node providing the
- // sling:vanityPath
- // property (or its parent if the node is called
- // jcr:content)
- final String redirect;
- if (resource.getName().equals("jcr:content")) {
- redirect = resource.getParent().getPath();
- } else {
- redirect = resource.getPath();
- }
+ if ( !processedVanityPaths.contains(url) ) {
+ processedVanityPaths.add(url);
+ // redirect target is the node providing the
+ // sling:vanityPath
+ // property (or its parent if the node is called
+ // jcr:content)
+ final String redirect;
+ if (resource.getName().equals("jcr:content")) {
+ redirect = resource.getParent().getPath();
+ } else {
+ redirect = resource.getPath();
+ }
- // whether the target is attained by a 302/FOUND or by an
- // internal redirect is defined by the sling:redirect
- // property
- final int status = props.get("sling:redirect", false) ? props.get(
- PROP_REDIRECT_EXTERNAL_REDIRECT_STATUS, HttpServletResponse.SC_FOUND)
- : -1;
-
- final String checkPath = result[1];
- // 1. entry with exact match
- this.addEntry(entryMap, checkPath, new MapEntry(url +
"$", status, false, redirect + ".html"));
+ // whether the target is attained by a 302/FOUND or by an
+ // internal redirect is defined by the sling:redirect
+ // property
+ final int status = props.get("sling:redirect", false) ? props.get(
+ PROP_REDIRECT_EXTERNAL_REDIRECT_STATUS, HttpServletResponse.SC_FOUND)
+ : -1;
+
+ final String checkPath = result[1];
+ // 1. entry with exact match
+ this.addEntry(entryMap, checkPath, new MapEntry(url + "$", status,
false, redirect + ".html"));
- // 2. entry with match supporting selectors and extension
- this.addEntry(entryMap, checkPath, new MapEntry(url +
"(\\..*)", status, false, redirect + "$1"));
+ // 2. entry with match supporting selectors and extension
+ this.addEntry(entryMap, checkPath, new MapEntry(url + "(\\..*)",
status, false, redirect + "$1"));
- // 3. keep the path to return
- targetPaths.add(redirect);
+ // 3. keep the path to return
+ targetPaths.add(redirect);
+ }
}
}
}
|