incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r598347 - /incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java
Date Mon, 26 Nov 2007 17:12:59 GMT
Author: bdelacretaz
Date: Mon Nov 26 09:12:59 2007
New Revision: 598347

URL: http://svn.apache.org/viewvc?rev=598347&view=rev
Log:
SLING-92: send a 404 instead of doing default rendering if URL info includes a suffix, i.e.
if resource was found higher in the tree than what the URL says

Modified:
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java?rev=598347&r1=598346&r2=598347&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java
Mon Nov 26 09:12:59 2007
@@ -33,6 +33,7 @@
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceMetadata;
 import org.apache.sling.api.servlets.HttpConstants;
 import org.apache.sling.api.servlets.SlingAllMethodsServlet;
 import org.apache.sling.microsling.servlet.MicroslingServletConfig;
@@ -92,6 +93,17 @@
         // make sure we have an Item, and render it via one of our renderingServlets
         final Object data = r.getRawData();
         if(data!=null && (data instanceof Item)) {
+            final String suffix = req.getRequestPathInfo().getSuffix();
+            if(suffix != null && suffix.length() > 0) {
+                // accept exact addressing only for default rendering:
+                // a non-empty suffix means there was extra stuff after the path
+                // of the resource
+                throw new HttpStatusCodeException(
+                        HttpServletResponse.SC_NOT_FOUND,
+                        "Ancestor resource found (" + r.getResourceMetadata().get(ResourceMetadata.RESOLUTION_PATH)
+ ")"
+                        + " but URL suffix must be empty for default rendering (suffix="
+ suffix + ")"
+                );
+            }
             final String contentType = req.getResponseContentType();
             final Servlet s = renderingServlets.get(contentType);
             if(s!=null) {



Mime
View raw message