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  /* 
18  
19   */
20  
21  package org.apache.wsrp4j.consumer.driver;
22  
23  import oasis.names.tc.wsrp.v1.types.StateChange;
24  
25  import org.apache.wsrp4j.consumer.ConsumerEnvironment;
26  import org.apache.wsrp4j.consumer.PortletDriverRegistry;
27  import org.apache.wsrp4j.consumer.PortletRegistry;
28  import org.apache.wsrp4j.consumer.ProducerRegistry;
29  import org.apache.wsrp4j.consumer.SessionHandler;
30  import org.apache.wsrp4j.consumer.URLRewriter;
31  import org.apache.wsrp4j.consumer.URLTemplateComposer;
32  import org.apache.wsrp4j.consumer.UserRegistry;
33  
34  public abstract class GenericConsumerEnvironment implements ConsumerEnvironment {
35  
36      private String consumerAgent = null;
37  
38      private String[] supportedLocales = null;
39  
40      private String[] supportedModes = null;
41  
42      private String[] supportedWindowStates = null;
43  
44      private StateChange portletStateChange = null;
45  
46      private String userAuthMethod = null;
47  
48      private String[] characterEncoding = null;
49  
50      private String[] mimeTypes = null;
51  
52      private UserRegistry userRegistry = null;
53  
54      private ProducerRegistry producerRegistry = null;
55  
56      private PortletRegistry portletRegistry = null;
57  
58      private PortletDriverRegistry portletDriverRegistry = null;
59  
60      private SessionHandler sessionHandler = null;
61  
62      private URLTemplateComposer templateComposer = null;
63  
64      private URLRewriter urlRewriter = null;
65  
66      public GenericConsumerEnvironment() {
67      }
68  
69      /**
70       * Get the name of the consumer
71       * 
72       * @return The name of the consumer
73       **/
74      public String getConsumerAgent() {
75          return consumerAgent;
76      }
77  
78      /**
79       * Set the name of the consumer
80       * 
81       * @param name The new name of the consumer    
82       **/
83      public void setConsumerAgent(String name) {
84          consumerAgent = name;
85      }
86  
87      /**
88       * Get the locales which are supported by the consumer.
89       * (ISO-639 + "_" + ISO-3166)
90       * 
91       * @return Array with String representations of the locales which are
92       * supported by the consumer
93       **/
94      public String[] getSupportedLocales() {
95          return supportedLocales;
96      }
97  
98      /**
99       * Set the locales which are supported by the consumer.
100      * Pattern: ISO-639 + "_" + ISO-3166
101      * 
102      * @param locales Array of String representations of the supported locales     
103      **/
104     public void setSupportedLocales(String[] locales) {
105         supportedLocales = locales;
106     }
107 
108     /**
109      * Get the portlet modes the consumer is willing to manage.     
110      * 
111      * @return Array with string representations of the portlet modes which are
112      * supported by the consumer
113      **/
114     public String[] getSupportedModes() {
115         return supportedModes;
116     }
117 
118     /**
119      * Set the portlet modes which are supported by the consumer.     
120      * 
121      * @param modes Array of string representations of portlet modes
122      **/
123     public void setSupportedModes(String[] modes) {
124         supportedModes = modes;
125     }
126 
127     /**
128      * Get the window states the consumer is willing to manage.     
129      * 
130      * @return Array with string representations of the window states which are
131      * supported by the consumer
132      **/
133     public String[] getSupportedWindowStates() {
134         return supportedWindowStates;
135     }
136 
137     /**
138      * Set the window states which are supported by the consumer.     
139      * 
140      * @param states Array of string representations of window states
141      **/
142     public void setSupportedWindowStates(String[] states) {
143         supportedWindowStates = states;
144     }
145 
146     /**
147      * Returns a flag which is used to indicate the producer wether or not
148      * the processing of portlets is allowed to modify the portlet state.
149      * 
150      * @return A flag
151      **/
152     public StateChange getPortletStateChange() {
153         return portletStateChange;
154     }
155 
156     /**
157      * Set a flag which is used to indicate the producer wether or not
158      * the processing of portlets is allowed to modify the portlet state.
159      * 
160      * @param portletStateChange A flag with one of the following values (OK, Clone, Fault)
161      **/
162     public void setPortletStateChange(StateChange portletStateChange) {
163         this.portletStateChange = portletStateChange;
164     }
165 
166     /**
167      * Get the character sets the consumer wants the remote portlet to use for encoding the markup.
168      * Valid character sets are defined <a href='http://www.iana.org/assignments/character-sets'>here</a>
169      * 
170      * @return Array of string representations of the character encoding.
171      **/
172     public String[] getCharacterEncodingSet() {
173         return characterEncoding;
174     }
175 
176     /**
177      * Set the character set the consumer wants the remote portlet to use for encoding the markup.
178      * Valid character sets are defined <a href='http://www.iana.org/assignments/character-sets'>here</a>
179      * 
180      * @param charEncoding Array of string representations of the character encoding.
181      **/
182     public void setCharacterEncodingSet(String[] charEncoding) {
183         characterEncoding = charEncoding;
184     }
185 
186     /**
187      * Get an array of mime types which are supported by the consumer.
188      * The order in the array defines the order of preference of the consumer.
189      * 
190      * @return An array of mimes types the consumer supports.
191      **/
192     public String[] getMimeTypes() {
193         return mimeTypes;
194     }
195 
196     /**
197      * Set the mime types the consumer supports
198      * The order in the array defines the order of preference of the consumer.
199      * 
200      * @param mimeTypes An array of mimes types the consumer supports.
201      **/
202     public void setMimeTypes(String[] mimeTypes) {
203         this.mimeTypes = mimeTypes;
204     }
205 
206     /**
207      * Get the method which is used by the consumer to authenticate its users.
208      *      
209      * @return String indicating how end-users were authenticated by the consumer.
210      **/
211     public String getUserAuthentication() {
212         return userAuthMethod;
213     }
214 
215     /**
216      * Set the method of end user authentication used by the consumer..
217      *      
218      * @param authMethod String indicating how end-users are authenticated by the consumer.
219      **/
220     public void setUserAuthentication(String authMethod) {
221         userAuthMethod = authMethod;
222     }
223 
224     /**
225      * Get the user registry of the consumer.
226      * 
227      * @return The consumer specific user registry
228      **/
229     public UserRegistry getUserRegistry() {
230         return userRegistry;
231     }
232 
233     /**
234      * Set the user registry of the consumer.
235      * 
236      * @param userRegistry The consumer specific user registry
237      **/
238     public void setUserRegistry(UserRegistry userRegistry) {
239         this.userRegistry = userRegistry;
240     }
241 
242     /**
243      * Get the producer registry of the consumer.
244      * 
245      * @return The consumer specific producer registry
246      **/
247     public ProducerRegistry getProducerRegistry() {
248         return producerRegistry;
249     }
250 
251     /**
252      * Set the producer registry of the consumer.
253      * 
254      * @param producerRegistry The consumer specific producer registry
255      **/
256     public void setProducerRegistry(ProducerRegistry producerRegistry) {
257         this.producerRegistry = producerRegistry;
258     }
259 
260     /**
261      * Get the portlet registry of the consumer.
262      * 
263      * @return Interface to the consumer specific portlet registry
264      **/
265     public PortletRegistry getPortletRegistry() {
266         return portletRegistry;
267     }
268 
269     /**
270      * Set the portlet registry of the consumer.
271      * 
272      * @param portletRegistry The consumer specific portlet registry
273      **/
274     public void setPortletRegistry(PortletRegistry portletRegistry) {
275         this.portletRegistry = portletRegistry;
276     }
277 
278     /**
279      * Get the portlet driver registry of the consumer.
280      * 
281      * @return Interface to the consumer specific portlet driver registry
282      **/
283     public PortletDriverRegistry getPortletDriverRegistry() {
284         return portletDriverRegistry;
285     }
286 
287     /**
288      * Set the portlet driver registry of the consumer.
289      * 
290      * @param portletDriverRegistry The consumer specific portlet driver registry
291      **/
292     public void setPortletDriverRegistry(
293             PortletDriverRegistry portletDriverRegistry) {
294         this.portletDriverRegistry = portletDriverRegistry;
295     }
296 
297     /**
298      * Get the session handler of the consumer.
299      * 
300      * @return Interface to the consumer specific session handler
301      **/
302     public SessionHandler getSessionHandler() {
303         return sessionHandler;
304     }
305 
306     /**
307      * Set the session handler of the consumer.
308      * 
309      * @param sessionHandler The consumer specific session handler
310      **/
311     public void setSessionHandler(SessionHandler sessionHandler) {
312         this.sessionHandler = sessionHandler;
313     }
314 
315     /**
316      * Get the url template composer for template proccessing
317      * 
318      * @return Interface to the consumer specific template composer
319      **/
320     public URLTemplateComposer getTemplateComposer() {
321         return templateComposer;
322     }
323 
324     /**
325      * Set the url template composer for template proccessing
326      * 
327      * @param templateComposer The consumer specific template composer
328      **/
329     public void setTemplateComposer(URLTemplateComposer templateComposer) {
330         this.templateComposer = templateComposer;
331     }
332 
333     /**
334      * Get the url rewriter for consumer url-rewriting
335      * 
336      * @return The consumer specific url rewriter
337      **/
338     public URLRewriter getURLRewriter() {
339         return urlRewriter;
340     }
341 
342     /**
343      * Set the url rewriter for consumer url-rewriting
344      * 
345      * @param urlRewriter The consumer specific url rewriter
346      **/
347     public void setURLRewriter(URLRewriter urlRewriter) {
348         this.urlRewriter = urlRewriter;
349     }
350 
351 }