01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.pluto.internal.impl;
18:
19: import java.io.IOException;
20: import java.io.InputStream;
21:
22: import javax.portlet.ActionRequest;
23: import javax.portlet.PortletPreferences;
24: import javax.servlet.http.HttpServletRequest;
25:
26: import org.apache.pluto.Constants;
27: import org.apache.pluto.PortletContainer;
28: import org.apache.pluto.internal.InternalActionRequest;
29: import org.apache.pluto.internal.InternalPortletWindow;
30: import org.apache.commons.logging.LogFactory;
31: import org.apache.commons.logging.Log;
32:
33: /**
34: * Implementation of the <code>javax.portlet.ActionRequest</code> interface.
35: */
36: public class ActionRequestImpl extends PortletRequestImpl implements
37: ActionRequest, InternalActionRequest {
38:
39: /** Logger. */
40: private static final Log LOG = LogFactory
41: .getLog(ActionRequestImpl.class);
42:
43: // Private Member Variables ------------------------------------------------
44:
45: /** FIXME: The portlet preferences. */
46: private PortletPreferences portletPreferences;
47:
48: // Constructor -------------------------------------------------------------
49:
50: public ActionRequestImpl(PortletContainer container,
51: InternalPortletWindow internalPortletWindow,
52: HttpServletRequest servletRequest) {
53: super (container, internalPortletWindow, servletRequest);
54: if (LOG.isDebugEnabled()) {
55: LOG.debug("Created action request for: "
56: + internalPortletWindow);
57: }
58: }
59:
60: // ActionRequest impl ------------------------------------------------------
61:
62: /* (non-Javadoc)
63: * FIXME: should we set the bodyAccessed flag?
64: * @see org.apache.pluto.core.InternalActionResponse#getPortletInputStream()
65: */
66: public InputStream getPortletInputStream() throws IOException {
67: HttpServletRequest servletRequest = (HttpServletRequest) getRequest();
68: if (servletRequest.getMethod().equals("POST")) {
69: String contentType = servletRequest.getContentType();
70: if (contentType == null
71: || contentType
72: .equals("application/x-www-form-urlencoded")) {
73: throw new IllegalStateException(
74: "User request HTTP POST data is of type "
75: + "application/x-www-form-urlencoded. "
76: + "This data has been already processed "
77: + "by the portal/portlet-container and is available "
78: + "as request parameters.");
79: }
80: }
81: return servletRequest.getInputStream();
82: }
83:
84: // PortletRequestImpl impl -------------------------------------------------
85:
86: /**
87: * FIXME:
88: */
89: public PortletPreferences getPreferences() {
90: if (portletPreferences == null) {
91: portletPreferences = new PortletPreferencesImpl(
92: getPortletContainer(), getInternalPortletWindow(),
93: this, Constants.METHOD_ACTION);
94: }
95: return portletPreferences;
96: }
97:
98: }
|