From c0bf2608dd23051f11f2a031e08aebbfdf7b5472 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Mon, 8 Apr 2013 10:10:32 +0300 Subject: [PATCH] Remove resource related code from VaadinPortlet (#11527) Change-Id: I33f489922bab432d1d85f4d46b73df8bd89ae91c Merge: no --- .../src/com/vaadin/server/VaadinPortlet.java | 33 ++----------------- 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java index b4a2390fa5..7d4618d58e 100644 --- a/server/src/com/vaadin/server/VaadinPortlet.java +++ b/server/src/com/vaadin/server/VaadinPortlet.java @@ -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("dummy page"); 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 { -- 2.39.5