KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > pluto > core > impl > ActionRequestImpl


1 /*
2  * Copyright 2003,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 /*
17
18  */

19
20 package org.apache.pluto.core.impl;
21
22 import java.io.InputStream JavaDoc;
23
24 import javax.portlet.ActionRequest;
25 import javax.portlet.PortletPreferences;
26
27 import org.apache.pluto.factory.PortletObjectAccess;
28 import org.apache.pluto.om.window.PortletWindow;
29
30 /**
31
32  *
33  * To change this generated comment edit the template variable "typecomment":
34  * Window>Preferences>Java>Templates.
35  * To enable and disable the creation of type comments go to
36  * Window>Preferences>Java>Code Generation.
37  */

38 public class ActionRequestImpl extends PortletRequestImpl implements ActionRequest
39 {
40     /**
41      * Holds the portlet preferences
42      */

43     private PortletPreferences portletPreferences;
44
45     public ActionRequestImpl(PortletWindow portletWindow,
46                              javax.servlet.http.HttpServletRequest JavaDoc servletRequest)
47     {
48         super(portletWindow, servletRequest);
49     }
50
51     // javax.portlet.ActionRequest implementation -------------------------------------------------
52
/* (non-Javadoc)
53      * @see org.apache.pluto.core.InternalActionResponse#getPortletInputStream()
54      */

55     public InputStream JavaDoc getPortletInputStream () throws java.io.IOException JavaDoc
56     {
57         javax.servlet.http.HttpServletRequest JavaDoc servletRequest = (javax.servlet.http.HttpServletRequest JavaDoc) super.getRequest();
58
59         if (servletRequest.getMethod().equals("POST"))
60         {
61             String JavaDoc contentType=servletRequest.getContentType();
62             if (contentType==null||contentType.equals("application/x-www-form-urlencoded"))
63             {
64                 throw new java.lang.IllegalStateException JavaDoc(
65                                                          "User request HTTP POST data is of type application/x-www-form-urlencoded. This data has been already processed by the portal/portlet-container and is available as request parameters."
66                                                          );
67             }
68         }
69         return servletRequest.getInputStream();
70     }
71
72     // --------------------------------------------------------------------------------------------
73
// PortletRequestImpl implementation ----------------------------------------------------------
74
public PortletPreferences getPreferences()
75     {
76         if (this.portletPreferences == null)
77         {
78             this.portletPreferences = PortletObjectAccess.getPortletPreferences(org.apache.pluto.Constants.METHOD_ACTION, super.getInternalPortletWindow().getPortletEntity());
79         }
80         return this.portletPreferences;
81     }
82     // --------------------------------------------------------------------------------------------
83
}
84
Popular Tags