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.cocoon.environment.portlet;
18:
19: import java.io.BufferedReader;
20: import java.io.IOException;
21: import java.io.InputStream;
22:
23: /**
24: * Implements the {@link org.apache.cocoon.environment.Request} interface for the
25: * JSR-168 (Portlet) environment.
26: *
27: * @version CVS $Id: ActionRequest.java 433543 2006-08-22 06:22:54Z crossley $
28: * @author <a href="mailto:alex.rudnev@dc.gov">Alex Rudnev</a>
29: * @author <a href="mailto:vadim.gritsenko@dc.gov">Vadim Gritsenko</a>
30: */
31: public final class ActionRequest extends PortletRequest {
32:
33: /**
34: * Creates a ActionRequest based on a real ActionRequest object
35: */
36: protected ActionRequest(String servletPath, String pathInfo,
37: javax.portlet.ActionRequest request,
38: PortletEnvironment environment) {
39: super (servletPath, pathInfo, request, environment);
40: }
41:
42: // Request API methods
43:
44: public String getCharacterEncoding() {
45: if (super .getCharacterEncoding() == null) {
46: return getActionRequest().getCharacterEncoding();
47: }
48: return super .getCharacterEncoding();
49: }
50:
51: /**
52: * Action request can be always recognized by POST method
53: */
54: public String getMethod() {
55: return "POST";
56: }
57:
58: // ActionRequest API methods
59:
60: /**
61: * Type cast portletRequest to ActionRequest
62: *
63: * @return type casted portletRequest
64: */
65: public javax.portlet.ActionRequest getActionRequest() {
66: return (javax.portlet.ActionRequest) getPortletRequest();
67: }
68:
69: public InputStream getInputStream() throws IOException {
70: return getActionRequest().getPortletInputStream();
71: }
72:
73: public BufferedReader getReader() throws IOException {
74: return getActionRequest().getReader();
75: }
76:
77: /**
78: * Action request provides content length for custom upload handling
79: */
80: public int getContentLength() {
81: return getActionRequest().getContentLength();
82: }
83:
84: /**
85: * Action request provides content type for custom upload handling
86: */
87: public String getContentType() {
88: return getActionRequest().getContentType();
89: }
90: }
|