incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r691219 - in /incubator/sling/trunk/servlets/get/src/main/java/org/apache/sling/servlets/get/helpers: HtmlRendererServlet.java PlainTextRendererServlet.java StreamRendererServlet.java
Date Tue, 02 Sep 2008 12:48:49 GMT
Author: cziegeler
Date: Tue Sep  2 05:48:49 2008
New Revision: 691219

URL: http://svn.apache.org/viewvc?rev=691219&view=rev
Log:
Throw 404 exception if resource is non existing.

Modified:
    incubator/sling/trunk/servlets/get/src/main/java/org/apache/sling/servlets/get/helpers/HtmlRendererServlet.java
    incubator/sling/trunk/servlets/get/src/main/java/org/apache/sling/servlets/get/helpers/PlainTextRendererServlet.java
    incubator/sling/trunk/servlets/get/src/main/java/org/apache/sling/servlets/get/helpers/StreamRendererServlet.java

Modified: incubator/sling/trunk/servlets/get/src/main/java/org/apache/sling/servlets/get/helpers/HtmlRendererServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/get/src/main/java/org/apache/sling/servlets/get/helpers/HtmlRendererServlet.java?rev=691219&r1=691218&r2=691219&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/get/src/main/java/org/apache/sling/servlets/get/helpers/HtmlRendererServlet.java
(original)
+++ incubator/sling/trunk/servlets/get/src/main/java/org/apache/sling/servlets/get/helpers/HtmlRendererServlet.java
Tue Sep  2 05:48:49 2008
@@ -25,7 +25,9 @@
 
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.resource.NonExistingResource;
 import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceNotFoundException;
 import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
 
 /**
@@ -45,6 +47,10 @@
             SlingHttpServletResponse resp) throws ServletException, IOException {
         final Resource r = req.getResource();
 
+        if (r instanceof NonExistingResource) {
+            throw new ResourceNotFoundException("Resource not found at " + r.getPath());
+        }
+
         resp.setContentType(responseContentType);
         resp.setCharacterEncoding("UTF-8");
 

Modified: incubator/sling/trunk/servlets/get/src/main/java/org/apache/sling/servlets/get/helpers/PlainTextRendererServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/get/src/main/java/org/apache/sling/servlets/get/helpers/PlainTextRendererServlet.java?rev=691219&r1=691218&r2=691219&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/get/src/main/java/org/apache/sling/servlets/get/helpers/PlainTextRendererServlet.java
(original)
+++ incubator/sling/trunk/servlets/get/src/main/java/org/apache/sling/servlets/get/helpers/PlainTextRendererServlet.java
Tue Sep  2 05:48:49 2008
@@ -25,7 +25,9 @@
 
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.resource.NonExistingResource;
 import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceNotFoundException;
 import org.apache.sling.api.resource.ResourceUtil;
 import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
 
@@ -46,6 +48,10 @@
     protected void doGet(SlingHttpServletRequest req,
             SlingHttpServletResponse resp) throws ServletException, IOException {
         final Resource r = req.getResource();
+        if (r instanceof NonExistingResource) {
+            throw new ResourceNotFoundException("Resource not found at " + r.getPath());
+        }
+
         /*
          * TODO if(srd != null) { renderSyntheticResource(req, resp, srd);
          * return; }

Modified: incubator/sling/trunk/servlets/get/src/main/java/org/apache/sling/servlets/get/helpers/StreamRendererServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/get/src/main/java/org/apache/sling/servlets/get/helpers/StreamRendererServlet.java?rev=691219&r1=691218&r2=691219&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/get/src/main/java/org/apache/sling/servlets/get/helpers/StreamRendererServlet.java
(original)
+++ incubator/sling/trunk/servlets/get/src/main/java/org/apache/sling/servlets/get/helpers/StreamRendererServlet.java
Tue Sep  2 05:48:49 2008
@@ -30,8 +30,10 @@
 
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.resource.NonExistingResource;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceMetadata;
+import org.apache.sling.api.resource.ResourceNotFoundException;
 
 /**
  * The <code>StreamRendererServlet</code> streams the current resource to the
@@ -58,7 +60,10 @@
             return;
         }
 
-        Resource resource = request.getResource();
+        final Resource resource = request.getResource();
+        if (resource instanceof NonExistingResource) {
+            throw new ResourceNotFoundException("Resource not found at " + resource.getPath());
+        }
 
         // check the last modification time and If-Modified-Since header
         ResourceMetadata meta = resource.getResourceMetadata();
@@ -108,7 +113,7 @@
             if (length > 0 && length < Integer.MAX_VALUE) {
                 response.setContentLength((int) length);
             }
-            
+
             OutputStream out = response.getOutputStream();
 
             byte[] buf = new byte[1024];



Mime
View raw message