You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2008/01/15 10:40:00 UTC
svn commit: r612061 -
/incubator/sling/whiteboard/fmeschbe/resource/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/PathSupport.java
Author: fmeschbe
Date: Tue Jan 15 01:39:59 2008
New Revision: 612061
URL: http://svn.apache.org/viewvc?rev=612061&view=rev
Log:
Add utility method to "convert" a resource type into a path replacing
all colons by slashes.
Modified:
incubator/sling/whiteboard/fmeschbe/resource/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/PathSupport.java
Modified: incubator/sling/whiteboard/fmeschbe/resource/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/PathSupport.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/PathSupport.java?rev=612061&r1=612060&r2=612061&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/PathSupport.java (original)
+++ incubator/sling/whiteboard/fmeschbe/resource/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/PathSupport.java Tue Jan 15 01:39:59 2008
@@ -26,12 +26,16 @@
public class PathSupport {
+ public static String toPath(String resourceType) {
+ return resourceType.replaceAll("\\:", "/");
+ }
+
public static String getScriptBaseName(SlingHttpServletRequest request) {
String methodName = request.getMethod();
String extension = request.getRequestPathInfo().getExtension();
if (methodName == null || methodName.length() == 0) {
-
+
throw new IllegalArgumentException(
"HTTP Method name must not be empty");
@@ -49,12 +53,11 @@
}
public static Iterator<String> getPathIterator(
- SlingHttpServletRequest request, String[] path) {
+ SlingHttpServletRequest request, String[] path) {
return new ScriptPathIterator(request, path);
}
-
- public static Iterator<String> getPathIterator(
- String relPath, String[] path) {
+
+ public static Iterator<String> getPathIterator(String relPath, String[] path) {
return new ScriptPathIterator(relPath, path);
}
@@ -73,10 +76,9 @@
private ScriptPathIterator(SlingHttpServletRequest request,
String[] path) {
-
- this.resourceTypePath = request.getResource().getResourceType().replaceAll(
- "\\:", "/");
-
+
+ this.resourceTypePath = toPath(request.getResource().getResourceType());
+
String selectors = request.getRequestPathInfo().getSelectorString();
if (selectors == null) {
this.selectorsPath = null;
@@ -84,16 +86,16 @@
this.selectorsPath = "/"
+ selectors.toLowerCase().replace('.', '/');
}
-
+
// path prefixes
this.path = path;
this.pathIdx = -1;
-
+
// prepare the first entry
this.nextPath = "";
seek();
}
-
+
private ScriptPathIterator(String relPath, String[] path) {
this.resourceTypePath = relPath;