001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet;
022:
023: import com.liferay.portal.kernel.util.JavaConstants;
024:
025: import java.io.BufferedReader;
026: import java.io.IOException;
027: import java.io.InputStream;
028: import java.io.UnsupportedEncodingException;
029:
030: import javax.portlet.ActionRequest;
031: import javax.portlet.ActionResponse;
032: import javax.portlet.PortletConfig;
033: import javax.portlet.PortletPreferences;
034:
035: import org.apache.commons.logging.Log;
036: import org.apache.commons.logging.LogFactory;
037:
038: /**
039: * <a href="ActionRequestImpl.java.html"><b><i>View Source</i></b></a>
040: *
041: * @author Brian Wing Shun Chan
042: *
043: */
044: public class ActionRequestImpl extends RenderRequestImpl implements
045: ActionRequest {
046:
047: public PortletPreferences getPreferences() {
048: return new PortletPreferencesWrapper(getPreferencesImpl(), true);
049: }
050:
051: public String getCharacterEncoding() {
052: return getHttpServletRequest().getCharacterEncoding();
053: }
054:
055: public void setCharacterEncoding(String enc)
056: throws UnsupportedEncodingException {
057:
058: if (_calledGetReader) {
059: throw new IllegalStateException();
060: }
061:
062: getHttpServletRequest().setCharacterEncoding(enc);
063: }
064:
065: public int getContentLength() {
066: return getHttpServletRequest().getContentLength();
067: }
068:
069: public String getContentType() {
070: return getHttpServletRequest().getContentType();
071: }
072:
073: public InputStream getPortletInputStream() throws IOException {
074: return getHttpServletRequest().getInputStream();
075: }
076:
077: public BufferedReader getReader() throws IOException,
078: UnsupportedEncodingException {
079:
080: _calledGetReader = true;
081:
082: return getHttpServletRequest().getReader();
083: }
084:
085: public void defineObjects(PortletConfig portletConfig,
086: ActionResponse res) {
087: setAttribute(JavaConstants.JAVAX_PORTLET_CONFIG, portletConfig);
088: setAttribute(JavaConstants.JAVAX_PORTLET_REQUEST, this );
089: setAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE, res);
090: }
091:
092: public boolean isAction() {
093: return true;
094: }
095:
096: protected ActionRequestImpl() {
097: if (_log.isDebugEnabled()) {
098: _log.debug("Creating new instance " + hashCode());
099: }
100: }
101:
102: protected void recycle() {
103: if (_log.isDebugEnabled()) {
104: _log.debug("Recycling instance " + hashCode());
105: }
106:
107: super .recycle();
108:
109: _calledGetReader = false;
110: }
111:
112: private static Log _log = LogFactory
113: .getLog(ActionRequestImpl.class);
114:
115: private boolean _calledGetReader;
116:
117: }
|