]> source.dussan.org Git - vaadin-framework.git/commitdiff
Extract WrappedPortletResponse to a separate class
authorLeif Åstrand <leif@vaadin.com>
Tue, 8 Nov 2011 12:40:12 +0000 (14:40 +0200)
committerLeif Åstrand <leif@vaadin.com>
Tue, 8 Nov 2011 12:40:12 +0000 (14:40 +0200)
src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java
src/com/vaadin/terminal/gwt/server/WrappedPortletResponse.java [new file with mode: 0644]

index 89ce1e4d2c9ef7d7c2acff9923bd25d7dd9b99b8..96e371d74917b586af7123dd260b47fdfde22e4c 100644 (file)
@@ -5,12 +5,9 @@ package com.vaadin.terminal.gwt.server;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.portlet.MimeResponse;
 import javax.portlet.PortletRequest;
 import javax.portlet.PortletResponse;
 import javax.portlet.ResourceRequest;
@@ -38,40 +35,6 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
 
     private transient ResourceResponse currentUidlResponse;
 
-    private static class PortletResponseWrapper implements WrappedResponse {
-
-        private final PortletResponse response;
-
-        public PortletResponseWrapper(PortletResponse response) {
-            this.response = response;
-        }
-
-        public OutputStream getOutputStream() throws IOException {
-            return ((MimeResponse) response).getPortletOutputStream();
-        }
-
-        public MimeResponse getPortletResponse() {
-            return (MimeResponse) response;
-        }
-
-        public void setContentType(String type) {
-            ((MimeResponse) response).setContentType(type);
-        }
-
-        public PrintWriter getWriter() throws IOException {
-            return ((MimeResponse) response).getWriter();
-        }
-
-        public void setStatus(int responseStatus) {
-            response.setProperty(ResourceResponse.HTTP_STATUS_CODE,
-                    Integer.toString(responseStatus));
-        }
-
-        public void setHeader(String name, String value) {
-            response.setProperty(name, value);
-        }
-    }
-
     private static class AbstractApplicationPortletWrapper implements Callback {
 
         private final AbstractApplicationPortlet portlet;
@@ -86,7 +49,7 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
                 String details, String outOfSyncURL) throws IOException {
             portlet.criticalNotification(
                     ((WrappedPortletRequest) request).getPortletRequest(),
-                    ((PortletResponseWrapper) response).getPortletResponse(),
+                    ((WrappedPortletResponse) response).getPortletResponse(),
                     cap, msg, details, outOfSyncURL);
         }
 
@@ -119,11 +82,11 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
         if (contentType.contains("boundary")) {
             doHandleSimpleMultipartFileUpload(
                     new WrappedPortletRequest(request),
-                    new PortletResponseWrapper(response), streamVariable, name,
+                    new WrappedPortletResponse(response), streamVariable, name,
                     variableOwner, contentType.split("boundary=")[1]);
         } else {
             doHandleXhrFilePost(new WrappedPortletRequest(request),
-                    new PortletResponseWrapper(response), streamVariable, name,
+                    new WrappedPortletResponse(response), streamVariable, name,
                     variableOwner, request.getContentLength());
         }
 
@@ -143,7 +106,7 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
             throws InvalidUIDLSecurityKeyException, IOException {
         currentUidlResponse = response;
         doHandleUidlRequest(new WrappedPortletRequest(request),
-                new PortletResponseWrapper(response),
+                new WrappedPortletResponse(response),
                 new AbstractApplicationPortletWrapper(applicationPortlet), root);
         currentUidlResponse = null;
     }
@@ -211,7 +174,7 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
     public boolean handleApplicationRequest(PortletRequest request,
             PortletResponse response) throws IOException {
         return handleApplicationRequest(new WrappedPortletRequest(request),
-                new PortletResponseWrapper(response));
+                new WrappedPortletResponse(response));
     }
 
 }
diff --git a/src/com/vaadin/terminal/gwt/server/WrappedPortletResponse.java b/src/com/vaadin/terminal/gwt/server/WrappedPortletResponse.java
new file mode 100644 (file)
index 0000000..3f2f67a
--- /dev/null
@@ -0,0 +1,45 @@
+package com.vaadin.terminal.gwt.server;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+import javax.portlet.MimeResponse;
+import javax.portlet.PortletResponse;
+import javax.portlet.ResourceResponse;
+
+import com.vaadin.terminal.WrappedResponse;
+
+public class WrappedPortletResponse implements WrappedResponse {
+
+    private final PortletResponse response;
+
+    public WrappedPortletResponse(PortletResponse response) {
+        this.response = response;
+    }
+
+    public OutputStream getOutputStream() throws IOException {
+        return ((MimeResponse) response).getPortletOutputStream();
+    }
+
+    public MimeResponse getPortletResponse() {
+        return (MimeResponse) response;
+    }
+
+    public void setContentType(String type) {
+        ((MimeResponse) response).setContentType(type);
+    }
+
+    public PrintWriter getWriter() throws IOException {
+        return ((MimeResponse) response).getWriter();
+    }
+
+    public void setStatus(int responseStatus) {
+        response.setProperty(ResourceResponse.HTTP_STATUS_CODE,
+                Integer.toString(responseStatus));
+    }
+
+    public void setHeader(String name, String value) {
+        response.setProperty(name, value);
+    }
+}
\ No newline at end of file