View Javadoc

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;
21  
22  import javax.portlet.*;
23  import org.apache.pluto.portlet.*;
24  
25  public class CoreUtils
26  {
27      // Access to InternalPortletRequest
28      public static InternalPortletRequest getInternalRequest(PortletRequest request)
29      {
30          while (!(request instanceof InternalPortletRequest))
31          {
32              request = ((PortletRequestWrapper)request).getPortletRequest();
33              if (request == null)
34              {
35                  throw new IllegalStateException("The internal portlet request cannot be found.");                
36              }
37          }
38          return(InternalPortletRequest)request;
39      }
40  
41      // Access to InternalPortletResponse
42      public static InternalPortletResponse getInternalResponse(PortletResponse response)
43      {
44          while (!(response instanceof InternalPortletResponse))
45          {
46              response = ((PortletResponseWrapper)response).getPortletResponse();
47              if (response == null)
48              {
49                  throw new IllegalStateException("The internal portlet response cannot be found.");                
50              }
51          }
52          return(InternalPortletResponse)response;
53      }
54  
55      // Access to InternalPortletConfig
56      public static InternalPortletConfig getInternalConfig(PortletConfig config)
57      {
58          return(InternalPortletConfig)config;
59      }
60  
61      // Access to InternalPortletContext
62      public static InternalPortletContext getInternalContext(PortletContext context)
63      {
64          return(InternalPortletContext)context;
65      }
66  
67  }