Author: fmeschbe
Date: Tue Dec 2 07:24:37 2008
New Revision: 722497
URL: http://svn.apache.org/viewvc?rev=722497&view=rev
Log:
SLING-750 Fixes to sling:VanityPath support:
- sling:vanityPath must come before configuration
- support two cases for each vanitypath:
1. without extension --> append .html
2. with selectors/extension --> use those
Modified:
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver2.java
Modified:
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver2.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver2.java?rev=722497&r1=722496&r2=722497&view=diff
==============================================================================
---
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver2.java
(original)
+++
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver2.java
Tue Dec 2 07:24:37 2008
@@ -622,12 +622,12 @@
gather(entries, res, "");
}
- // backwards-compatibility: read current configuration
- gatherConfiguration(entries);
-
// backwards-compatible sling:vanityPath stuff
gatherVanityPaths(entries);
+ // backwards-compatibility: read current configuration
+ gatherConfiguration(entries);
+
return entries;
}
@@ -668,7 +668,7 @@
// what is stored in the sling:vanityPath property
Object pVanityPath = row.get("sling:vanityPath");
if (pVanityPath != null) {
- String url = ANY_SCHEME_HOST + String.valueOf(pVanityPath);
+ String url = "^" + ANY_SCHEME_HOST +
String.valueOf(pVanityPath);
// redirect target is the node providing the sling:vanityPath
// property (or its parent if the node is called jcr:content)
@@ -676,7 +676,7 @@
if (ResourceUtil.getName(redirect).equals("jcr:content")) {
redirect = ResourceUtil.getParent(redirect);
}
-
+
// whether the target is attained by a 302/FOUND or by an
// internal redirect is defined by the sling:redirect property
int status = -1;
@@ -685,7 +685,11 @@
status = HttpServletResponse.SC_FOUND;
}
- entries.add(new MapEntry(url, redirect, status));
+ // 1. entry with exact match
+ entries.add(new MapEntry(url + "$", redirect + ".html",
status));
+
+ // 2. entry with match supporting selectors and extension
+ entries.add(new MapEntry(url + "(\\..*)", redirect + "$1",
status));
}
}
}