1
22
23 package com.liferay.portlet;
24
25 import com.liferay.portal.kernel.util.JavaConstants;
26
27 import java.io.BufferedReader;
28 import java.io.IOException;
29 import java.io.InputStream;
30 import java.io.UnsupportedEncodingException;
31
32 import javax.portlet.ActionRequest;
33 import javax.portlet.ActionResponse;
34 import javax.portlet.PortletConfig;
35 import javax.portlet.PortletPreferences;
36
37 import org.apache.commons.logging.Log;
38 import org.apache.commons.logging.LogFactory;
39
40
46 public class ActionRequestImpl
47 extends RenderRequestImpl implements ActionRequest {
48
49 public PortletPreferences getPreferences() {
50 return new PortletPreferencesWrapper(getPreferencesImpl(), true);
51 }
52
53 public String getCharacterEncoding() {
54 return getHttpServletRequest().getCharacterEncoding();
55 }
56
57 public void setCharacterEncoding(String enc)
58 throws UnsupportedEncodingException {
59
60 if (_calledGetReader) {
61 throw new IllegalStateException();
62 }
63
64 getHttpServletRequest().setCharacterEncoding(enc);
65 }
66
67 public int getContentLength() {
68 return getHttpServletRequest().getContentLength();
69 }
70
71 public String getContentType() {
72 return getHttpServletRequest().getContentType();
73 }
74
75 public InputStream getPortletInputStream() throws IOException {
76 return getHttpServletRequest().getInputStream();
77 }
78
79 public BufferedReader getReader()
80 throws IOException, UnsupportedEncodingException {
81
82 _calledGetReader = true;
83
84 return getHttpServletRequest().getReader();
85 }
86
87 public void defineObjects(PortletConfig portletConfig, ActionResponse res) {
88 setAttribute(JavaConstants.JAVAX_PORTLET_CONFIG, portletConfig);
89 setAttribute(JavaConstants.JAVAX_PORTLET_REQUEST, this);
90 setAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE, res);
91 }
92
93 public boolean isAction() {
94 return true;
95 }
96
97 protected ActionRequestImpl() {
98 if (_log.isDebugEnabled()) {
99 _log.debug("Creating new instance " + hashCode());
100 }
101 }
102
103 protected void recycle() {
104 if (_log.isDebugEnabled()) {
105 _log.debug("Recycling instance " + hashCode());
106 }
107
108 super.recycle();
109
110 _calledGetReader = false;
111 }
112
113 private static Log _log = LogFactory.getLog(ActionRequestImpl.class);
114
115 private boolean _calledGetReader;
116
117 }