| PortletServletResponse.java |
1 /**
2 * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 package com.liferay.portlet;
24
25 import java.util.Locale;
26
27 import javax.portlet.ActionResponse;
28 import javax.portlet.PortletResponse;
29 import javax.portlet.RenderResponse;
30
31 import javax.servlet.http.HttpServletResponse;
32 import javax.servlet.http.HttpServletResponseWrapper;
33
34 /**
35 * <a href="PortletServletResponse.java.html"><b><i>View Source</i></b></a>
36 *
37 * @author Brian Wing Shun Chan
38 *
39 */
40 public class PortletServletResponse extends HttpServletResponseWrapper {
41
42 public PortletServletResponse(HttpServletResponse res,
43 PortletResponse portletResponse) {
44
45 super(res);
46
47 _portletResponse = portletResponse;
48
49 if (_portletResponse instanceof ActionResponse) {
50 _action = true;
51 }
52 else {
53 _action = false;
54 }
55 }
56
57 public String encodeRedirectUrl(String url) {
58 return encodeRedirectURL(url);
59 }
60
61 public String encodeRedirectURL(String url) {
62 return null;
63 }
64
65 public String encodeUrl(String path) {
66 return encodeURL(path);
67 }
68
69 public String encodeURL(String path) {
70 if (_action) {
71 throw new UnsupportedOperationException();
72 }
73 else {
74 RenderResponse res = (RenderResponse)_portletResponse;
75
76 return res.encodeURL(path);
77 }
78 }
79
80 public Locale getLocale() {
81 if (_action) {
82 return null;
83 }
84 else {
85 RenderResponse res = (RenderResponse)_portletResponse;
86
87 return res.getLocale();
88 }
89 }
90 public int getBufferSize() {
91 if (_action) {
92 return 0;
93 }
94 else {
95 RenderResponse res = (RenderResponse)_portletResponse;
96
97 return res.getBufferSize();
98 }
99 }
100
101 public boolean isCommitted() {
102 if (_action) {
103 return false;
104 }
105 else {
106 RenderResponse res = (RenderResponse)_portletResponse;
107
108 return res.isCommitted();
109 }
110 }
111
112 private PortletResponse _portletResponse;
113 private boolean _action;
114
115 }