sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r783017 - in /incubator/sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl: DefaultGetServlet.java JsonQueryServlet.java
Date Tue, 09 Jun 2009 14:42:25 GMT
Author: cziegeler
Date: Tue Jun  9 14:42:24 2009
New Revision: 783017

URL: http://svn.apache.org/viewvc?rev=783017&view=rev
Log:
SLING-994 : If the request is included, do not use sendError but throw an exception if no
renderer is found

Modified:
    incubator/sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/DefaultGetServlet.java
    incubator/sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/JsonQueryServlet.java

Modified: incubator/sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/DefaultGetServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/DefaultGetServlet.java?rev=783017&r1=783016&r2=783017&view=diff
==============================================================================
--- incubator/sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/DefaultGetServlet.java
(original)
+++ incubator/sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/DefaultGetServlet.java
Tue Jun  9 14:42:24 2009
@@ -26,6 +26,7 @@
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.sling.api.SlingConstants;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.resource.ResourceNotFoundException;
@@ -43,7 +44,7 @@
 
 /**
  * A SlingSafeMethodsServlet that renders the current Resource as simple HTML
- * 
+ *
  * @scr.component name="org.apache.sling.servlets.get.DefaultGetServlet"
  *                immediate="true" label="%servlet.get.name"
  *                description="%servlet.get.description"
@@ -156,17 +157,17 @@
             setupServlet(rendererMap, PlainTextRendererServlet.EXT_TXT,
                 new PlainTextRendererServlet());
         }
-        
+
         if (enableJson) {
             setupServlet(rendererMap, JsonRendererServlet.EXT_JSON,
                 new JsonRendererServlet());
         }
-        
+
         if (enableXml) {
             setupServlet(rendererMap, XMLRendererServlet.EXT_XML,
                 new XMLRendererServlet());
         }
-        
+
         // use the servlet for rendering StreamRendererServlet.EXT_RES as the
         // streamer servlet
         streamerServlet = rendererMap.get(StreamRendererServlet.EXT_RES);
@@ -204,7 +205,7 @@
         // cannot handle the request for missing resources
         if (ResourceUtil.isNonExistingResource(request.getResource())) {
             throw new ResourceNotFoundException(
-                request.getResource().getPath(), "No Resource found");
+                request.getResource().getPath(), "No resource found");
         }
 
         Servlet rendererServlet;
@@ -218,7 +219,13 @@
         // fail if we should not just stream or we cannot support the ext.
         if (rendererServlet == null) {
             request.getRequestProgressTracker().log(
-                "No Renderer for extension " + ext);
+                "No renderer for extension " + ext);
+            final boolean isIncluded = request.getAttribute(SlingConstants.ATTR_REQUEST_SERVLET)
!= null;
+            // if this is an included request, sendError() would fail
+            // as the response is already committed, in this case we throw an exception
+            if ( isIncluded ) {
+                throw new ServletException("No renderer found for extensions " + ext);
+            }
             response.sendError(HttpServletResponse.SC_FORBIDDEN);
             return;
         }

Modified: incubator/sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/JsonQueryServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/JsonQueryServlet.java?rev=783017&r1=783016&r2=783017&view=diff
==============================================================================
--- incubator/sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/JsonQueryServlet.java
(original)
+++ incubator/sling/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/JsonQueryServlet.java
Tue Jun  9 14:42:24 2009
@@ -39,7 +39,6 @@
 import org.apache.sling.commons.json.JSONException;
 import org.apache.sling.commons.json.io.JSONWriter;
 import org.apache.sling.jcr.resource.JcrResourceUtil;
-import org.apache.sling.servlets.get.impl.helpers.JsonRendererServlet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -48,10 +47,10 @@
  *
  * @scr.component immediate="true" metatype="no"
  * @scr.service interface="javax.servlet.Servlet"
- * 
+ *
  * @scr.property name="service.description" value="Default Query Servlet"
  * @scr.property name="service.vendor" value="The Apache Software Foundation"
- * 
+ *
  * Use this as the default query servlet for json get requests for Sling
  * @scr.property name="sling.servlet.resourceTypes"
  *               value="sling/servlet/default"



Mime
View raw message