1
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
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 }