KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > wsrp > consumer > WSRPRequestImpl


1 /*
2  * Copyright 2000-2001,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 package org.apache.cocoon.portal.wsrp.consumer;
18
19 import oasis.names.tc.wsrp.v1.types.ClientData;
20 import oasis.names.tc.wsrp.v1.types.MarkupContext;
21 import oasis.names.tc.wsrp.v1.types.NamedString;
22 import oasis.names.tc.wsrp.v1.types.SessionContext;
23
24 import org.apache.wsrp4j.consumer.ConsumerEnvironment;
25 import org.apache.wsrp4j.consumer.InteractionRequest;
26 import org.apache.wsrp4j.consumer.MarkupRequest;
27 import org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl;
28
29 /**
30  * Holds all parameters to communicate with the producer to get the right portlet.
31  * It uses the {@link org.apache.cocoon.portal.wsrp.consumer#SimplePortletSessionImpl}
32  * to get the window-information, the {@link org.apache.cocoon.portal.wsrp.consumer#Request}
33  * for the interaction-state, form-parameters and so on, last but not least the
34  * {@link org.apache.cocoon.portal.wsrp.consumer#consumerEnvironment} for all
35  * other information.<br/>
36  *
37  * @author <a HREF="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
38  * @author <a HREF="mailto:malessandrini@s-und-n.de">Michel Alessandrini</a>
39  *
40  * @version $Id: WSRPRequestImpl.java 264755 2005-08-30 10:29:21Z cziegeler $
41  */

42 public class WSRPRequestImpl extends GenericWSRPBaseRequestImpl
43                              implements InteractionRequest, MarkupRequest {
44
45     /** Portlet-window settings */
46     protected final SimplePortletWindowSession windowSession;
47     
48     /** Request-parameters */
49     protected final Request request;
50     
51     /** Consumer environment contains all registries to get the required information*/
52     protected final ConsumerEnvironment consEnv;
53     
54     /**
55      * Constructor
56      *
57      * @param session
58      * @param request
59      * @param env ConsumerEnvironment
60      */

61     public WSRPRequestImpl(SimplePortletWindowSession session,
62                            Request request,
63                            ConsumerEnvironment env) {
64         if (session == null) {
65             throw(new IllegalStateException JavaDoc("session must not be null"));
66         }
67         if (env == null) {
68             throw(new IllegalStateException JavaDoc("environment must not be null"));
69         }
70         if ( request == null ) {
71             this.request = new RequestImpl();
72         } else {
73             this.request = request;
74         }
75         this.windowSession = session;
76         this.consEnv = env;
77     }
78     
79     /**
80      * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getSessionID()
81      */

82     public String JavaDoc getSessionID() {
83         SessionContext sessionCtx = windowSession.getPortletSession().getSessionContext();
84         if (sessionCtx != null) {
85             return sessionCtx.getSessionID();
86         }
87         return null;
88     }
89
90     /**
91      * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getPortletInstanceKey()
92      */

93     public String JavaDoc getPortletInstanceKey() {
94         return windowSession.getWindowID();
95     }
96
97     /**
98      * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getNavigationalState()
99      */

100     public String JavaDoc getNavigationalState() {
101         return windowSession.getNavigationalState();
102     }
103
104     /**
105      * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getWindowState()
106      */

107     public String JavaDoc getWindowState() {
108         return windowSession.getWindowState();
109     }
110
111     /**
112      * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getMode()
113      */

114     public String JavaDoc getMode() {
115         return this.windowSession.getMode();
116     }
117
118     /**
119      * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getClientData()
120      */

121     public ClientData getClientData() {
122         return null;
123     }
124
125     /**
126      * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getLocales()
127      */

128     public String JavaDoc[] getLocales() {
129         return this.consEnv.getSupportedLocales();
130     }
131
132     /**
133      * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getModes()
134      */

135     public String JavaDoc[] getModes() {
136         return this.consEnv.getSupportedModes();
137     }
138
139     /**
140      * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getWindowStates()
141      */

142     public String JavaDoc[] getWindowStates() {
143         return this.consEnv.getSupportedWindowStates();
144     }
145
146     /**
147      * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getMimeTypes()
148      */

149     public String JavaDoc[] getMimeTypes() {
150         return consEnv.getMimeTypes();
151     }
152
153     /**
154      * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getCharacterEncodingSet()
155      */

156     public String JavaDoc[] getCharacterEncodingSet() {
157         return this.consEnv.getCharacterEncodingSet();
158     }
159
160     /**
161      * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getUserAuthentication()
162      */

163     public String JavaDoc getUserAuthentication() {
164         return this.consEnv.getUserAuthentication();
165     }
166
167     /**
168      * @see org.apache.wsrp4j.consumer.InteractionRequest#getInteractionState()
169      */

170     public String JavaDoc getInteractionState() {
171         return this.request.getInteractionState();
172     }
173
174     /**
175      * @see org.apache.wsrp4j.consumer.InteractionRequest#getFormParameters()
176      */

177     public NamedString[] getFormParameters() {
178         return this.request.getFormParameters();
179     }
180
181     /**
182      * @see org.apache.wsrp4j.consumer.MarkupRequest#getCachedMarkup()
183      */

184     public MarkupContext getCachedMarkup() {
185         return this.windowSession.getCachedMarkup();
186     }
187 }
188
Popular Tags