incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1451631 - in /sling/trunk/bundles: api/src/main/java/org/apache/sling/api/request/ engine/src/main/java/org/apache/sling/engine/impl/request/
Date Fri, 01 Mar 2013 16:18:55 GMT
Author: cziegeler
Date: Fri Mar  1 16:18:55 2013
New Revision: 1451631

URL: http://svn.apache.org/r1451631
Log:
SLING-2670 : Add support for suffix addressed resources

Modified:
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/request/RequestPathInfo.java
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/request/package-info.java
    sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestPathInfo.java

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/request/RequestPathInfo.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/request/RequestPathInfo.java?rev=1451631&r1=1451630&r2=1451631&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/request/RequestPathInfo.java
(original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/request/RequestPathInfo.java
Fri Mar  1 16:18:55 2013
@@ -16,6 +16,8 @@
  */
 package org.apache.sling.api.request;
 
+import org.apache.sling.api.resource.Resource;
+
 /**
  * Sling breaks the request URI into four parts: the path itself, optional
  * dot-separated selectors and extension that follow it, and an optional path
@@ -201,4 +203,16 @@ public interface RequestPathInfo {
      */
     String getSuffix();
 
+    /**
+     * Returns the resource addressed by the suffix or null if the request does
+     * not have a suffix or the suffix does not address an accessible resource.
+     * <p>
+     * The suffix is expected to be the absolute path to the resource suitable
+     * as an argument to the
+     * {@link org.apache.sling.api.resource.ResourceResolver#getResource(String)}
+     * method.
+     *
+     * @since 2.3 (Sling API 2.3.2)
+     */
+    Resource getSuffixResource();
 }

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/request/package-info.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/request/package-info.java?rev=1451631&r1=1451630&r2=1451631&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/request/package-info.java (original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/request/package-info.java Fri
Mar  1 16:18:55 2013
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-@Version("2.2")
+@Version("2.3")
 package org.apache.sling.api.request;
 
 import aQute.bnd.annotation.Version;

Modified: sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestPathInfo.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestPathInfo.java?rev=1451631&r1=1451630&r2=1451631&view=diff
==============================================================================
--- sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestPathInfo.java
(original)
+++ sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestPathInfo.java
Fri Mar  1 16:18:55 2013
@@ -43,6 +43,8 @@ public class SlingRequestPathInfo implem
 
     private final String resourcePath;
 
+    private final Resource resource;
+
     private final static String[] NO_SELECTORS = new String[0];
 
     /** break requestPath as required by SlingRequestPathInfo */
@@ -53,7 +55,8 @@ public class SlingRequestPathInfo implem
             throw new NullPointerException("resource");
         }
 
-        resourcePath = r.getResourceMetadata().getResolutionPath();
+        this.resource = r;
+        this.resourcePath = r.getResourceMetadata().getResolutionPath();
 
         // the extra path in the request URI
         String pathToParse = r.getResourceMetadata().getResolutionPathInfo();
@@ -95,8 +98,9 @@ public class SlingRequestPathInfo implem
                 : null;
     }
 
-    private SlingRequestPathInfo(String resourcePath, String selectorString,
-            String extension, String suffix) {
+    private SlingRequestPathInfo(Resource resource, String resourcePath, String selectorString,
String extension,
+            String suffix) {
+        this.resource = resource;
         this.resourcePath = resourcePath;
         this.selectorString = selectorString;
         this.selectors = (selectorString != null)
@@ -108,9 +112,8 @@ public class SlingRequestPathInfo implem
 
     public SlingRequestPathInfo merge(RequestPathInfo baseInfo) {
         if (getExtension() == null) {
-            return new SlingRequestPathInfo(getResourcePath(),
-                baseInfo.getSelectorString(), baseInfo.getExtension(),
-                baseInfo.getSuffix());
+            return new SlingRequestPathInfo(getResource(), getResourcePath(), baseInfo.getSelectorString(),
+                baseInfo.getExtension(), baseInfo.getSuffix());
         }
 
         return this;
@@ -155,8 +158,7 @@ public class SlingRequestPathInfo implem
             }
 
             if (needCreate) {
-                return new SlingRequestPathInfo(getResourcePath(), selectors,
-                    getExtension(), suffix);
+                return new SlingRequestPathInfo(getResource(), getResourcePath(), selectors,
getExtension(), suffix);
             }
         }
 
@@ -186,6 +188,18 @@ public class SlingRequestPathInfo implem
         return suffix;
     }
 
+    public Resource getSuffixResource() {
+        if (this.suffix != null) {
+            return getResource().getResourceResolver().getResource(this.suffix);
+        }
+
+        return null;
+    }
+
+    private Resource getResource() {
+        return resource;
+    }
+
     public String getResourcePath() {
         return resourcePath;
     }



Mime
View raw message