incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r619006 - in /incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/launchpad: renderers/StreamRendererServlet.java servlets/LaunchpadDefaultServlet.java
Date Wed, 06 Feb 2008 14:55:53 GMT
Author: fmeschbe
Date: Wed Feb  6 06:55:49 2008
New Revision: 619006

URL: http://svn.apache.org/viewvc?rev=619006&view=rev
Log:
StreamRenderServlet is now a PlainTextServlet, such that resources, which do not
adapt to an InputStream are handled by the default PlainTextServlet.

Modified:
    incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/launchpad/renderers/StreamRendererServlet.java
    incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/launchpad/servlets/LaunchpadDefaultServlet.java

Modified: incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/launchpad/renderers/StreamRendererServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/launchpad/renderers/StreamRendererServlet.java?rev=619006&r1=619005&r2=619006&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/launchpad/renderers/StreamRendererServlet.java
(original)
+++ incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/launchpad/renderers/StreamRendererServlet.java
Wed Feb  6 06:55:49 2008
@@ -24,6 +24,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 
+import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -36,19 +37,25 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class StreamRendererServlet extends SlingSafeMethodsServlet {
+public class StreamRendererServlet extends PlainTextRendererServlet {
 
     private static final long serialVersionUID = -1L;
 
     /** default log */
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    public StreamRendererServlet() {
+    public StreamRendererServlet(String contentType, ServletConfig config)
+            throws ServletException {
+        super(contentType);
+
+        // not quite correct, but ok
+        init(config);
     }
 
     @Override
     protected void doGet(SlingHttpServletRequest request,
-            SlingHttpServletResponse response) throws IOException {
+            SlingHttpServletResponse response) throws ServletException,
+            IOException {
 
         Resource resource = request.getResource();
         ResourceMetadata meta = resource.getResourceMetadata();
@@ -60,12 +67,10 @@
             return;
         }
 
-        // fail if the resource does not adapt to an InputStream
+        // fall back to plain text rendering if the resource has no stream
         InputStream stream = resource.adaptTo(InputStream.class);
         if (stream == null) {
-            log.error("service: Resource {} does not adapt to an InputStream",
-                resource);
-            response.sendError(HttpServletResponse.SC_NOT_FOUND);
+            super.doGet(request, response);
             return;
         }
 

Modified: incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/launchpad/servlets/LaunchpadDefaultServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/launchpad/servlets/LaunchpadDefaultServlet.java?rev=619006&r1=619005&r2=619006&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/launchpad/servlets/LaunchpadDefaultServlet.java
(original)
+++ incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/launchpad/servlets/LaunchpadDefaultServlet.java
Wed Feb  6 06:55:49 2008
@@ -90,7 +90,7 @@
         ujaxInfoServlet.init(config);
 
         defaultGetServlet = new PlainTextRendererServlet("text/plain");
-        streamServlet = new StreamRendererServlet();
+        streamServlet = new StreamRendererServlet("text/plain", config);
 
         getServlets = new HashMap<String, Servlet>();
         getServlets.put("html", new DefaultHtmlRendererServlet("text/html"));



Mime
View raw message