From 513675e3a5f06dcc9e232870fba5cf761f012080 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Wed, 25 Nov 2009 13:52:55 +0000 Subject: [PATCH] Minor refactoring: split out common nested class RestrictedRenderResponse from PortletApplicationContext* svn changeset:10022/svn branch:6.2 --- .../gwt/server/PortletApplicationContext.java | 136 ---------------- .../server/PortletApplicationContext2.java | 132 ---------------- .../gwt/server/RestrictedRenderResponse.java | 146 ++++++++++++++++++ 3 files changed, 146 insertions(+), 268 deletions(-) create mode 100644 src/com/vaadin/terminal/gwt/server/RestrictedRenderResponse.java diff --git a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java index 621ef1b246..0e3289dea6 100644 --- a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java +++ b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java @@ -3,34 +3,21 @@ */ package com.vaadin.terminal.gwt.server; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintWriter; import java.io.Serializable; -import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashSet; -import java.util.Locale; import java.util.Map; import java.util.Set; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; -import javax.portlet.CacheControl; import javax.portlet.Portlet; -import javax.portlet.PortletMode; import javax.portlet.PortletSession; -import javax.portlet.PortletURL; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; -import javax.portlet.ResourceURL; -import javax.servlet.http.Cookie; import javax.servlet.http.HttpSession; -import org.w3c.dom.DOMException; -import org.w3c.dom.Element; - import com.vaadin.Application; /** @@ -186,127 +173,4 @@ public class PortletApplicationContext extends WebApplicationContext implements ActionResponse response); } - private class RestrictedRenderResponse implements RenderResponse, - Serializable { - - private RenderResponse response; - - private RestrictedRenderResponse(RenderResponse response) { - this.response = response; - } - - public void addProperty(String key, String value) { - response.addProperty(key, value); - } - - public PortletURL createActionURL() { - return response.createActionURL(); - } - - public PortletURL createRenderURL() { - return response.createRenderURL(); - } - - public String encodeURL(String path) { - return response.encodeURL(path); - } - - public void flushBuffer() throws IOException { - // NOP - // TODO throw? - } - - public int getBufferSize() { - return response.getBufferSize(); - } - - public String getCharacterEncoding() { - return response.getCharacterEncoding(); - } - - public String getContentType() { - return response.getContentType(); - } - - public Locale getLocale() { - return response.getLocale(); - } - - public String getNamespace() { - return response.getNamespace(); - } - - public OutputStream getPortletOutputStream() throws IOException { - // write forbidden - return null; - } - - public PrintWriter getWriter() throws IOException { - // write forbidden - return null; - } - - public boolean isCommitted() { - return response.isCommitted(); - } - - public void reset() { - // NOP - // TODO throw? - } - - public void resetBuffer() { - // NOP - // TODO throw? - } - - public void setBufferSize(int size) { - // NOP - // TODO throw? - } - - public void setContentType(String type) { - // NOP - // TODO throw? - } - - public void setProperty(String key, String value) { - response.setProperty(key, value); - } - - public void setTitle(String title) { - response.setTitle(title); - } - - public void setNextPossiblePortletModes( - Collection portletModes) { - // NOP - // TODO throw? - } - - public ResourceURL createResourceURL() { - return response.createResourceURL(); - } - - public CacheControl getCacheControl() { - return response.getCacheControl(); - } - - public void addProperty(Cookie cookie) { - // NOP - // TODO throw? - } - - public void addProperty(String key, Element element) { - // NOP - // TODO throw? - } - - public Element createElement(String tagName) throws DOMException { - // NOP - return null; - } - - } - } diff --git a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java index 84b85d866a..a8814b4c88 100644 --- a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java +++ b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java @@ -1,8 +1,6 @@ package com.vaadin.terminal.gwt.server; import java.io.File; -import java.io.IOException; -import java.io.OutputStream; import java.io.PrintWriter; import java.io.Serializable; import java.io.StringWriter; @@ -13,30 +11,22 @@ import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.LinkedList; -import java.util.Locale; import java.util.Map; import java.util.Set; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; -import javax.portlet.CacheControl; import javax.portlet.EventRequest; import javax.portlet.EventResponse; -import javax.portlet.PortletMode; import javax.portlet.PortletRequest; import javax.portlet.PortletSession; -import javax.portlet.PortletURL; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import javax.portlet.ResourceRequest; import javax.portlet.ResourceResponse; -import javax.portlet.ResourceURL; -import javax.servlet.http.Cookie; import javax.servlet.http.HttpSessionBindingEvent; import javax.servlet.http.HttpSessionBindingListener; -import org.w3c.dom.DOMException; -import org.w3c.dom.Element; import com.vaadin.Application; import com.vaadin.service.ApplicationContext; @@ -281,126 +271,4 @@ public class PortletApplicationContext2 implements ApplicationContext, ResourceResponse response); } - private class RestrictedRenderResponse implements RenderResponse, - Serializable { - - private RenderResponse response; - - private RestrictedRenderResponse(RenderResponse response) { - this.response = response; - } - - public void addProperty(String key, String value) { - response.addProperty(key, value); - } - - public PortletURL createActionURL() { - return response.createActionURL(); - } - - public PortletURL createRenderURL() { - return response.createRenderURL(); - } - - public String encodeURL(String path) { - return response.encodeURL(path); - } - - public void flushBuffer() throws IOException { - // NOP - // TODO throw? - } - - public int getBufferSize() { - return response.getBufferSize(); - } - - public String getCharacterEncoding() { - return response.getCharacterEncoding(); - } - - public String getContentType() { - return response.getContentType(); - } - - public Locale getLocale() { - return response.getLocale(); - } - - public String getNamespace() { - return response.getNamespace(); - } - - public OutputStream getPortletOutputStream() throws IOException { - // write forbidden - return null; - } - - public PrintWriter getWriter() throws IOException { - // write forbidden - return null; - } - - public boolean isCommitted() { - return response.isCommitted(); - } - - public void reset() { - // NOP - // TODO throw? - } - - public void resetBuffer() { - // NOP - // TODO throw? - } - - public void setBufferSize(int size) { - // NOP - // TODO throw? - } - - public void setContentType(String type) { - // NOP - // TODO throw? - } - - public void setProperty(String key, String value) { - response.setProperty(key, value); - } - - public void setTitle(String title) { - response.setTitle(title); - } - - public void setNextPossiblePortletModes( - Collection portletModes) { - // NOP - // TODO throw? - } - - public ResourceURL createResourceURL() { - return response.createResourceURL(); - } - - public CacheControl getCacheControl() { - return response.getCacheControl(); - } - - public void addProperty(Cookie cookie) { - // NOP - // TODO throw? - } - - public void addProperty(String key, Element element) { - // NOP - // TODO throw? - } - - public Element createElement(String tagName) throws DOMException { - // NOP - return null; - } - } - } diff --git a/src/com/vaadin/terminal/gwt/server/RestrictedRenderResponse.java b/src/com/vaadin/terminal/gwt/server/RestrictedRenderResponse.java new file mode 100644 index 0000000000..95458d59d9 --- /dev/null +++ b/src/com/vaadin/terminal/gwt/server/RestrictedRenderResponse.java @@ -0,0 +1,146 @@ +package com.vaadin.terminal.gwt.server; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.io.Serializable; +import java.util.Collection; +import java.util.Locale; + +import javax.portlet.CacheControl; +import javax.portlet.PortletMode; +import javax.portlet.PortletURL; +import javax.portlet.RenderResponse; +import javax.portlet.ResourceURL; +import javax.servlet.http.Cookie; + +import org.w3c.dom.DOMException; +import org.w3c.dom.Element; + +/** + * Read-only wrapper for a {@link RenderResponse}. + * + * Only for use by {@link PortletApplicationContext} and + * {@link PortletApplicationContext2}. + */ +class RestrictedRenderResponse implements RenderResponse, + Serializable { + + private RenderResponse response; + + RestrictedRenderResponse(RenderResponse response) { + this.response = response; + } + + public void addProperty(String key, String value) { + response.addProperty(key, value); + } + + public PortletURL createActionURL() { + return response.createActionURL(); + } + + public PortletURL createRenderURL() { + return response.createRenderURL(); + } + + public String encodeURL(String path) { + return response.encodeURL(path); + } + + public void flushBuffer() throws IOException { + // NOP + // TODO throw? + } + + public int getBufferSize() { + return response.getBufferSize(); + } + + public String getCharacterEncoding() { + return response.getCharacterEncoding(); + } + + public String getContentType() { + return response.getContentType(); + } + + public Locale getLocale() { + return response.getLocale(); + } + + public String getNamespace() { + return response.getNamespace(); + } + + public OutputStream getPortletOutputStream() throws IOException { + // write forbidden + return null; + } + + public PrintWriter getWriter() throws IOException { + // write forbidden + return null; + } + + public boolean isCommitted() { + return response.isCommitted(); + } + + public void reset() { + // NOP + // TODO throw? + } + + public void resetBuffer() { + // NOP + // TODO throw? + } + + public void setBufferSize(int size) { + // NOP + // TODO throw? + } + + public void setContentType(String type) { + // NOP + // TODO throw? + } + + public void setProperty(String key, String value) { + response.setProperty(key, value); + } + + public void setTitle(String title) { + response.setTitle(title); + } + + public void setNextPossiblePortletModes( + Collection portletModes) { + // NOP + // TODO throw? + } + + public ResourceURL createResourceURL() { + return response.createResourceURL(); + } + + public CacheControl getCacheControl() { + return response.getCacheControl(); + } + + public void addProperty(Cookie cookie) { + // NOP + // TODO throw? + } + + public void addProperty(String key, Element element) { + // NOP + // TODO throw? + } + + public Element createElement(String tagName) throws DOMException { + // NOP + return null; + } +} \ No newline at end of file -- 2.39.5