001: /*
002: * Copyright 2002 Sun Microsystems, Inc. All
003: * rights reserved. Use of this product is subject
004: * to license terms. Federal Acquisitions:
005: * Commercial Software -- Government Users
006: * Subject to Standard License Terms and
007: * Conditions.
008: *
009: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010: * are trademarks or registered trademarks of Sun Microsystems,
011: * Inc. in the United States and other countries.
012: */
013: package com.sun.portal.portlet.impl;
014:
015: import java.io.IOException;
016: import java.io.PrintWriter;
017: import java.util.Enumeration;
018: import java.util.Locale;
019:
020: import javax.portlet.RenderResponse;
021: import javax.servlet.ServletOutputStream;
022: import javax.servlet.http.Cookie;
023: import javax.servlet.http.HttpServletResponse;
024: import javax.servlet.http.HttpServletResponseWrapper;
025:
026: /**
027: * RDResponseWrapper is a wrapped HttpServerResponse object that needs
028: * to be passed into the servlet request dispatcher.
029: */
030:
031: public class RDResponseWrapper extends HttpServletResponseWrapper {
032:
033: // private members
034: private RDRequestWrapper _rdRequestWrapper;
035: private RenderResponse _rResponse;
036: private PSServletOutputStream _psServletOutputStream;
037:
038: // constructor
039: public RDResponseWrapper(RDRequestWrapper rdReq, RenderResponse rRes) {
040: super (
041: (HttpServletResponse) rdReq
042: .getAttribute(PortletRequestConstants.HTTP_SERVLET_RESPONSE));
043: _rdRequestWrapper = rdReq;
044: _rResponse = rRes;
045: }
046:
047: /*************************************************************
048: * The following methods must return null based on the portlet
049: * specification.
050: *************************************************************/
051: public String encodeRedirectUrl(String url) {
052:
053: return null;
054: }
055:
056: public String encodeRedirectURL(java.lang.String url) {
057:
058: return null;
059: }
060:
061: /*************************************************************
062: * The following methods of the HttpServletResponse must be
063: * based on the methods of the RenderResponse of similar names.
064: *************************************************************/
065:
066: public String getCharacterEncoding() {
067:
068: return _rResponse.getCharacterEncoding();
069: }
070:
071: public void setBufferSize(int size) {
072:
073: _rResponse.setBufferSize(size);
074: }
075:
076: public void flushBuffer() throws IOException {
077:
078: _rResponse.flushBuffer();
079: }
080:
081: public void resetBuffer() {
082:
083: _rResponse.resetBuffer();
084: }
085:
086: public void reset() {
087:
088: _rResponse.reset();
089: }
090:
091: public int getBufferSize() {
092:
093: return _rResponse.getBufferSize();
094: }
095:
096: public boolean isCommitted() {
097:
098: return _rResponse.isCommitted();
099: }
100:
101: public ServletOutputStream getOutputStream()
102: throws java.io.IOException {
103:
104: if (_psServletOutputStream == null) {
105: _psServletOutputStream = new PSServletOutputStream(
106: _rResponse.getPortletOutputStream());
107: }
108: return _psServletOutputStream;
109: }
110:
111: public PrintWriter getWriter() throws java.io.IOException {
112:
113: return _rResponse.getWriter();
114: }
115:
116: public String encodeURL(String path) {
117:
118: return _rResponse.encodeURL(path);
119: }
120:
121: public String encodeUrl(java.lang.String url) {
122:
123: return _rResponse.encodeURL(url);
124: }
125:
126: /*************************************************************
127: * The following methods of the HttpServletResponse must
128: * perform no operations.
129: *************************************************************/
130:
131: public void setContentType(String type) {
132:
133: }
134:
135: public void setContentLength(int len) {
136:
137: }
138:
139: public void setLocale(Locale loc) {
140:
141: }
142:
143: public void addCookie(Cookie cookie) {
144:
145: }
146:
147: public void sendError(int sc) throws IOException {
148:
149: }
150:
151: public void sendError(int sc, String msg) throws IOException {
152:
153: }
154:
155: public void sendRedirect(String location) throws IOException {
156:
157: }
158:
159: public void setDateHeader(String name, long date) {
160:
161: }
162:
163: public void addDateHeader(String name, long date) {
164:
165: }
166:
167: public void setHeader(String name, String value) {
168:
169: }
170:
171: public void addHeader(String name, String value) {
172:
173: }
174:
175: public void setIntHeader(String name, int value) {
176:
177: }
178:
179: public void addIntHeader(String name, int value) {
180:
181: }
182:
183: public void setStatus(int sc) {
184:
185: }
186:
187: /*************************************************************
188: * The containsHeader method of the HttpServletResponse must
189: * return false.
190: *************************************************************/
191:
192: public boolean containsHeader(String name) {
193:
194: return false;
195: }
196:
197: /*************************************************************
198: * The getLocale method of the HttpServletResponse must be
199: * based on the getLocale method of the PortletRerquest.
200: *************************************************************/
201: public Locale getLocale() {
202:
203: return _rResponse.getLocale();
204: }
205: }
|