1
22
23 package com.liferay.portal.wsrp;
24
25 import com.liferay.portal.kernel.util.ByteArrayMaker;
26
27 import java.io.IOException;
28 import java.io.PrintWriter;
29 import java.io.Serializable;
30 import java.io.StringWriter;
31 import java.io.UnsupportedEncodingException;
32
33 import java.util.Locale;
34
35 import javax.servlet.ServletOutputStream;
36 import javax.servlet.http.Cookie;
37 import javax.servlet.http.HttpServletResponse;
38
39
45 public class WSRPServletResponse implements HttpServletResponse, Serializable {
46
47 public static final int DEFAULT_STATUS_CODE = 200;
48
49 public WSRPServletResponse() {
50 _locale = new Locale("en", "US");
51
52 setContentType("text/html");
53 }
54
55 public void setBufferSize(int size) {
56 }
57
58 public int getBufferSize() {
59 return 4096;
60 }
61
62 public void setCharacterEncoding(String encoding) {
63 _encoding = encoding;
64 }
65
66 public String getCharacterEncoding() {
67 return _encoding;
68 }
69
70 public boolean isCommitted() {
71 return false;
72 }
73
74 public void setContentLength(int size) {
75 }
76
77 public void setContentType(String contentType) {
78 _contentType = contentType;
79 }
80
81 public String getContentType() {
82 return _contentType;
83 }
84
85 public void setDateHeader(String name, long dateValue) {
86 }
87
88 public void setHeader(String name, String value) {
89 }
90
91 public void setIntHeader(String name, int value) {
92 }
93
94 public void setLocale(Locale locale) {
95 _locale = locale;
96 }
97
98 public java.util.Locale getLocale() {
99 return _locale;
100 }
101
102 public ServletOutputStream getOutputStream() {
103 _callGetOutputStream = true;
104
105 return _sos;
106 }
107
108 public void setStatus(int statusCode) {
109 }
110
111 public void setStatus(int statusCode, String message) {
112 }
113
114 public String getString() throws UnsupportedEncodingException {
115 if (_callGetOutputStream) {
116 return _bam.toString();
117 }
118 else if (_callGetWriter) {
119 return _sw.toString();
120 }
121 else {
122 return "";
123 }
124 }
125
126 public PrintWriter getWriter() {
127 _callGetWriter = true;
128
129 return _pw;
130 }
131
132 public void addCookie(Cookie cookie) {
133 }
134
135 public void addDateHeader(String name, long dateValue) {
136 }
137
138 public void addHeader(String name, String value) {
139 }
140
141 public void addIntHeader(String name, int value) {
142 }
143
144 public boolean containsHeader(String headerName) {
145 return false;
146 }
147
148 public String encodeRedirectURL(String url) {
149 return url;
150 }
151
152 public String encodeRedirectUrl(String url) {
153 return encodeRedirectURL(url);
154 }
155
156 public String encodeURL(String url) {
157 return url;
158 }
159
160 public String encodeUrl(String url) {
161 return encodeURL(url);
162 }
163
164 public void flushBuffer() {
165 }
166
167 public void reset() {
168 }
169
170 public void resetBuffer() {
171 }
172
173 public void sendError(int errorCode) throws IOException {
174 }
175
176 public void sendError(int errorCode, String message) throws IOException {
177 }
178
179 public void sendRedirect(String location) {
180 }
181
182 private ByteArrayMaker _bam = new ByteArrayMaker();
183 private Locale _locale;
184 private ServletOutputStream _sos = new ServletOutputStream() {
185 public void write(int b) throws IOException {
186 _bam.write(b);
187 }
188 };
189
190 private String _encoding;
191 private StringWriter _sw = new StringWriter();
192 private PrintWriter _pw = new PrintWriter(_sw);
193 private boolean _callGetOutputStream;
194 private boolean _callGetWriter;
195 private String _contentType;
196
197 }