incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1155107 - /sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java
Date Mon, 08 Aug 2011 21:20:28 GMT
Author: justin
Date: Mon Aug  8 21:20:28 2011
New Revision: 1155107

URL: http://svn.apache.org/viewvc?rev=1155107&view=rev
Log:
SLING-2138 - initial implementation

Modified:
    sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java

Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java?rev=1155107&r1=1155106&r2=1155107&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java
(original)
+++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java
Mon Aug  8 21:20:28 2011
@@ -40,6 +40,8 @@ import org.slf4j.LoggerFactory;
  */
 class SlingIOProvider implements IOProvider {
 
+    private static final String WEB_INF_TAGS = "/WEB-INF/tags";
+
     /** default log */
     private final Logger log = LoggerFactory.getLogger(SlingIOProvider.class);
 
@@ -165,11 +167,19 @@ class SlingIOProvider implements IOProvi
         ResourceResolver resolver = requestResourceResolver.get();
         if (resolver != null) {
             try {
-                Resource resource = resolver.getResource(cleanPath(path));
+                final String cleanedPath = cleanPath(path, false);
+                final boolean startsWithWebInfTags = cleanedPath.startsWith(WEB_INF_TAGS);
+
+                Resource resource = resolver.getResource(startsWithWebInfTags ? cleanedPath.substring(WEB_INF_TAGS.length())
: cleanedPath);
                 if (resource != null) {
                     Iterator<Resource> entries = resolver.listChildren(resource);
                     while (entries.hasNext()) {
-                        paths.add(entries.next().getPath());
+                        final String entryPath = entries.next().getPath();
+                        if (startsWithWebInfTags) {
+                            paths.add(WEB_INF_TAGS + entryPath);
+                        } else {
+                            paths.add(entryPath);
+                        }
                     }
                 }
             } catch (SlingException se) {
@@ -184,7 +194,7 @@ class SlingIOProvider implements IOProvi
     private Resource getResourceInternal(String path) throws SlingException {
         ResourceResolver resolver = requestResourceResolver.get();
         if (resolver != null) {
-            return resolver.getResource(cleanPath(path));
+            return resolver.getResource(cleanPath(path, true));
         }
 
         return null;
@@ -192,7 +202,7 @@ class SlingIOProvider implements IOProvi
 
     // ---------- internal -----------------------------------------------------
 
-    private String cleanPath(String path) {
+    private String cleanPath(String path, boolean removeWebInfTags) {
         // replace backslash by slash
         path = path.replace('\\', '/');
 
@@ -201,6 +211,10 @@ class SlingIOProvider implements IOProvi
             path = path.substring(0, path.length() - 1);
         }
 
+        if (removeWebInfTags && path.startsWith(WEB_INF_TAGS)) {
+            path = path.substring(WEB_INF_TAGS.length());
+        }
+
         return path;
     }
 }



Mime
View raw message