| ConsumerEnvironmentImpl.java |
1 /**
2 * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 package com.liferay.portlet.wsrp;
24
25 import oasis.names.tc.wsrp.v1.types.StateChange;
26
27 import org.apache.wsrp4j.consumer.driver.GenericConsumerEnvironment;
28 import org.apache.wsrp4j.consumer.driver.PortletDriverRegistryImpl;
29 import org.apache.wsrp4j.consumer.driver.URLRewriterImpl;
30 import org.apache.wsrp4j.consumer.util.ConsumerConstants;
31 import org.apache.wsrp4j.util.Constants;
32 import org.apache.wsrp4j.util.Modes;
33 import org.apache.wsrp4j.util.WindowStates;
34
35 /**
36 * <a href="ConsumerEnvironmentImpl.java.html"><b><i>View Source</i></b></a>
37 *
38 * @author Michael Young
39 *
40 */
41 public class ConsumerEnvironmentImpl extends GenericConsumerEnvironment {
42
43 public ConsumerEnvironmentImpl() {
44
45 // set the name of the consumer agent
46 setConsumerAgent(CONSUMER_AGENT);
47
48 // define the locales the consumer supports
49 String[] supportedLocales = new String[2];
50 supportedLocales[0] = Constants.LOCALE_EN_US;
51 supportedLocales[1] = Constants.LOCALE_DE_DE;
52 setSupportedLocales(supportedLocales);
53
54 // define the modes the consumer supports
55 String[] supportedModes = new String[3];
56 supportedModes[0] = Modes._view;
57 supportedModes[1] = Modes._help;
58 supportedModes[2] = Modes._edit;
59 setSupportedModes(supportedModes);
60
61 // define the window states the consumer supports
62 String[] supportedWindowStates = new String[3];
63 supportedWindowStates[0] = WindowStates._normal;
64 supportedWindowStates[1] = WindowStates._maximized;
65 supportedWindowStates[2] = WindowStates._minimized;
66 setSupportedWindowStates(supportedWindowStates);
67
68 // define portlet state change behaviour
69 setPortletStateChange(StateChange.readWrite);
70
71 // define the mime types the consumer supports
72 setMimeTypes(new String[] { Constants.MIME_TYPE_HTML });
73
74 // define the character sets the consumer supports
75 setCharacterEncodingSet(new String[] { Constants.UTF_8 });
76
77 // set the authentication method the consumer uses
78 setUserAuthentication(ConsumerConstants.NONE);
79
80 // set consumer components
81 setUserRegistry(UserRegistryImpl.getInstance());
82 setSessionHandler(SessionHandlerImpl.getInstance(this));
83
84 setPortletRegistry(PortletRegistryImpl.getInstance());
85 setTemplateComposer(URLTemplateComposerImpl.getInstance());
86 setURLRewriter(URLRewriterImpl.getInstance());
87 setPortletDriverRegistry(PortletDriverRegistryImpl.getInstance(this));
88 setProducerRegistry(ProducerRegistryImpl.getInstance());
89 }
90
91 private static final String CONSUMER_AGENT = "Liferay WSRP Consumer";
92
93 }