KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > pluto > core > CoreUtils


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