1
22
23 package com.liferay.portlet;
24
25 import java.util.Locale;
26
27 import javax.portlet.PortletRequest;
28 import javax.portlet.PortletURL;
29 import javax.portlet.ResourceResponse;
30 import javax.portlet.ResourceURL;
31
32 import javax.servlet.http.HttpServletResponse;
33
34 import org.apache.commons.logging.Log;
35 import org.apache.commons.logging.LogFactory;
36
37
43 public class ResourceResponseImpl
44 extends MimeResponseImpl implements ResourceResponse {
45
46 public PortletURL createActionURL() {
47 return super.createActionURL();
48 }
49
50 public PortletURLImpl createPortletURLImpl(
51 String portletName, String lifecycle) {
52
53 if (lifecycle.equals(PortletRequest.ACTION_PHASE)) {
54 throw new IllegalStateException(
55 "Unable to create an action URL from a resource response");
56 }
57 else if (lifecycle.equals(PortletRequest.RENDER_PHASE)) {
58 throw new IllegalStateException(
59 "Unable to create a render URL from a resource response");
60 }
61
62 return super.createPortletURLImpl(portletName, lifecycle);
63 }
64
65 public PortletURL createRenderURL() {
66 return super.createRenderURL();
67 }
68
69 public ResourceURL createResourceURL() {
70 return super.createResourceURL();
71 }
72
73 public int getBufferSize() {
74 return 0;
75 }
76
77 public String getLifecycle() {
78 return PortletRequest.RESOURCE_PHASE;
79 }
80
81 public void setCharacterEncoding(String charset) {
82 _res.setCharacterEncoding(charset);
83 }
84
85 public void setLocale(Locale locale) {
86 _res.setLocale(locale);
87 }
88
89 public void setContentLength(int length) {
90 _res.setContentLength(length);
91 }
92
93 protected ResourceResponseImpl() {
94 if (_log.isDebugEnabled()) {
95 _log.debug("Creating new instance " + hashCode());
96 }
97 }
98
99 protected void init(
100 PortletRequestImpl req, HttpServletResponse res, String portletName,
101 long companyId, long plid) {
102
103 super.init(req, res, portletName, companyId, plid);
104
105 _res = res;
106 }
107
108 protected void recycle() {
109 if (_log.isDebugEnabled()) {
110 _log.debug("Recycling instance " + hashCode());
111 }
112
113 super.recycle();
114
115 _res = null;
116 }
117
118 private static Log _log = LogFactory.getLog(ResourceResponseImpl.class);
119
120 private HttpServletResponse _res;
121
122 }