]> source.dussan.org Git - vaadin-framework.git/commitdiff
Remove resource related code from VaadinPortlet (#11527)
authorHenri Sara <hesara@vaadin.com>
Mon, 8 Apr 2013 07:10:32 +0000 (10:10 +0300)
committerHenri Sara <hesara@vaadin.com>
Mon, 8 Apr 2013 07:10:32 +0000 (10:10 +0300)
Change-Id: I33f489922bab432d1d85f4d46b73df8bd89ae91c
Merge: no

server/src/com/vaadin/server/VaadinPortlet.java

index b4a2390fa50c476df9513cbab3a00e068de936d9..7d4618d58e4fd99f786bca306cab8a431f53c61a 100644 (file)
@@ -17,7 +17,6 @@ package com.vaadin.server;
 
 import java.io.BufferedWriter;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
@@ -28,7 +27,6 @@ import java.security.GeneralSecurityException;
 import java.util.Enumeration;
 import java.util.Map;
 import java.util.Properties;
-import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.portlet.ActionRequest;
@@ -340,6 +338,9 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
             } else if (isDummyRequest(resourceRequest)) {
                 return RequestType.DUMMY;
             } else {
+                // these are not served with ResourceRequests, but by a servlet
+                // on the portal at portlet root path (configured by default by
+                // Liferay at deployment time, similar on other portals)
                 return RequestType.STATIC_FILE;
             }
         } else if (request instanceof ActionRequest) {
@@ -406,9 +407,6 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
                         new BufferedWriter(new OutputStreamWriter(out, "UTF-8")));
                 outWriter.print("<html><body>dummy page</body></html>");
                 outWriter.close();
-            } else if (requestType == RequestType.STATIC_FILE) {
-                serveStaticResources((ResourceRequest) request,
-                        (ResourceResponse) response);
             } else {
                 VaadinPortletSession vaadinSession = null;
 
@@ -589,31 +587,6 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
         handleRequest(request, response);
     }
 
-    private void serveStaticResources(ResourceRequest request,
-            ResourceResponse response) throws IOException, PortletException {
-        final String resourceID = request.getResourceID();
-        final PortletContext pc = getPortletContext();
-
-        InputStream is = pc.getResourceAsStream(resourceID);
-        if (is != null) {
-            final String mimetype = pc.getMimeType(resourceID);
-            if (mimetype != null) {
-                response.setContentType(mimetype);
-            }
-            final OutputStream os = response.getPortletOutputStream();
-            final byte buffer[] = new byte[DEFAULT_BUFFER_SIZE];
-            int bytes;
-            while ((bytes = is.read(buffer)) >= 0) {
-                os.write(buffer, 0, bytes);
-            }
-        } else {
-            getLogger().log(Level.INFO,
-                    "Requested resource [{0}] could not be found", resourceID);
-            response.setProperty(ResourceResponse.HTTP_STATUS_CODE,
-                    Integer.toString(HttpServletResponse.SC_NOT_FOUND));
-        }
-    }
-
     @Override
     public void processAction(ActionRequest request, ActionResponse response)
             throws PortletException, IOException {