01: /**
02: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
03: *
04: * Permission is hereby granted, free of charge, to any person obtaining a copy
05: * of this software and associated documentation files (the "Software"), to deal
06: * in the Software without restriction, including without limitation the rights
07: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
08: * copies of the Software, and to permit persons to whom the Software is
09: * 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: */package com.liferay.portlet.wsrp;
22:
23: import oasis.names.tc.wsrp.v1.types.StateChange;
24:
25: import org.apache.wsrp4j.consumer.driver.GenericConsumerEnvironment;
26: import org.apache.wsrp4j.consumer.driver.PortletDriverRegistryImpl;
27: import org.apache.wsrp4j.consumer.driver.URLRewriterImpl;
28: import org.apache.wsrp4j.consumer.util.ConsumerConstants;
29: import org.apache.wsrp4j.util.Constants;
30: import org.apache.wsrp4j.util.Modes;
31: import org.apache.wsrp4j.util.WindowStates;
32:
33: /**
34: * <a href="ConsumerEnvironmentImpl.java.html"><b><i>View Source</i></b></a>
35: *
36: * @author Michael Young
37: *
38: */
39: public class ConsumerEnvironmentImpl extends GenericConsumerEnvironment {
40:
41: public ConsumerEnvironmentImpl() {
42:
43: // set the name of the consumer agent
44: setConsumerAgent(CONSUMER_AGENT);
45:
46: // define the locales the consumer supports
47: String[] supportedLocales = new String[2];
48: supportedLocales[0] = Constants.LOCALE_EN_US;
49: supportedLocales[1] = Constants.LOCALE_DE_DE;
50: setSupportedLocales(supportedLocales);
51:
52: // define the modes the consumer supports
53: String[] supportedModes = new String[3];
54: supportedModes[0] = Modes._view;
55: supportedModes[1] = Modes._help;
56: supportedModes[2] = Modes._edit;
57: setSupportedModes(supportedModes);
58:
59: // define the window states the consumer supports
60: String[] supportedWindowStates = new String[3];
61: supportedWindowStates[0] = WindowStates._normal;
62: supportedWindowStates[1] = WindowStates._maximized;
63: supportedWindowStates[2] = WindowStates._minimized;
64: setSupportedWindowStates(supportedWindowStates);
65:
66: // define portlet state change behaviour
67: setPortletStateChange(StateChange.readWrite);
68:
69: // define the mime types the consumer supports
70: setMimeTypes(new String[] { Constants.MIME_TYPE_HTML });
71:
72: // define the character sets the consumer supports
73: setCharacterEncodingSet(new String[] { Constants.UTF_8 });
74:
75: // set the authentication method the consumer uses
76: setUserAuthentication(ConsumerConstants.NONE);
77:
78: // set consumer components
79: setUserRegistry(UserRegistryImpl.getInstance());
80: setSessionHandler(SessionHandlerImpl.getInstance(this ));
81:
82: setPortletRegistry(PortletRegistryImpl.getInstance());
83: setTemplateComposer(URLTemplateComposerImpl.getInstance());
84: setURLRewriter(URLRewriterImpl.getInstance());
85: setPortletDriverRegistry(PortletDriverRegistryImpl
86: .getInstance(this ));
87: setProducerRegistry(ProducerRegistryImpl.getInstance());
88: }
89:
90: private static final String CONSUMER_AGENT = "Liferay WSRP Consumer";
91:
92: }
|