1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portlet;
16  
17  import com.liferay.portal.kernel.job.Scheduler;
18  import com.liferay.portal.kernel.poller.PollerProcessor;
19  import com.liferay.portal.kernel.pop.MessageListener;
20  import com.liferay.portal.kernel.portlet.ConfigurationAction;
21  import com.liferay.portal.kernel.portlet.FriendlyURLMapper;
22  import com.liferay.portal.kernel.portlet.PortletBag;
23  import com.liferay.portal.kernel.portlet.PortletLayoutListener;
24  import com.liferay.portal.kernel.search.Indexer;
25  import com.liferay.portal.kernel.search.OpenSearch;
26  import com.liferay.portal.kernel.servlet.URLEncoder;
27  import com.liferay.portal.kernel.util.LocaleUtil;
28  import com.liferay.portal.lar.PortletDataHandler;
29  import com.liferay.portlet.social.model.SocialActivityInterpreter;
30  import com.liferay.portlet.social.model.SocialRequestInterpreter;
31  
32  import java.util.Locale;
33  import java.util.Map;
34  import java.util.ResourceBundle;
35  
36  import javax.portlet.Portlet;
37  import javax.portlet.PreferencesValidator;
38  
39  import javax.servlet.ServletContext;
40  
41  /**
42   * <a href="PortletBagImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * @author Brian Wing Shun Chan
45   */
46  public class PortletBagImpl implements PortletBag {
47  
48      public PortletBagImpl(
49          String portletName, ServletContext servletContext,
50          Portlet portletInstance,
51          ConfigurationAction configurationActionInstance,
52          Indexer indexerInstance, OpenSearch openSearchInstance,
53          Scheduler schedulerInstance,
54          FriendlyURLMapper friendlyURLMapperInstance,
55          URLEncoder urlEncoderInstance,
56          PortletDataHandler portletDataHandlerInstance,
57          PortletLayoutListener portletLayoutListenerInstance,
58          PollerProcessor pollerProcessorInstance,
59          MessageListener popMessageListenerInstance,
60          SocialActivityInterpreter socialActivityInterpreterInstance,
61          SocialRequestInterpreter socialRequestInterpreterInstance,
62          PreferencesValidator prefsValidatorInstance,
63          Map<String, ResourceBundle> resourceBundles) {
64  
65          _portletName = portletName;
66          _servletContext = servletContext;
67          _portletInstance = portletInstance;
68          _configurationActionInstance = configurationActionInstance;
69          _indexerInstance = indexerInstance;
70          _openSearchInstance = openSearchInstance;
71          _schedulerInstance = schedulerInstance;
72          _friendlyURLMapperInstance = friendlyURLMapperInstance;
73          _urlEncoderInstance = urlEncoderInstance;
74          _portletDataHandlerInstance = portletDataHandlerInstance;
75          _portletLayoutListenerInstance = portletLayoutListenerInstance;
76          _pollerProcessorInstance = pollerProcessorInstance;
77          _popMessageListenerInstance = popMessageListenerInstance;
78          _socialActivityInterpreterInstance = socialActivityInterpreterInstance;
79          _socialRequestInterpreterInstance = socialRequestInterpreterInstance;
80          _prefsValidatorInstance = prefsValidatorInstance;
81          _resourceBundles = resourceBundles;
82      }
83  
84      public Object clone() {
85          return new PortletBagImpl(
86              getPortletName(), getServletContext(), getPortletInstance(),
87              getConfigurationActionInstance(), getIndexerInstance(),
88              getOpenSearchInstance(), getSchedulerInstance(),
89              getFriendlyURLMapperInstance(), getURLEncoderInstance(),
90              getPortletDataHandlerInstance(), getPortletLayoutListenerInstance(),
91              getPollerProcessorInstance(), getPopMessageListenerInstance(),
92              getSocialActivityInterpreterInstance(),
93              getSocialRequestInterpreterInstance(),
94              getPreferencesValidatorInstance(), getResourceBundles());
95      }
96  
97      public ConfigurationAction getConfigurationActionInstance() {
98          return _configurationActionInstance;
99      }
100 
101     public FriendlyURLMapper getFriendlyURLMapperInstance() {
102         return _friendlyURLMapperInstance;
103     }
104 
105     public Indexer getIndexerInstance() {
106         return _indexerInstance;
107     }
108 
109     public OpenSearch getOpenSearchInstance() {
110         return _openSearchInstance;
111     }
112 
113     public PollerProcessor getPollerProcessorInstance() {
114         return _pollerProcessorInstance;
115     }
116 
117     public MessageListener getPopMessageListenerInstance() {
118         return _popMessageListenerInstance;
119     }
120 
121     public PortletDataHandler getPortletDataHandlerInstance() {
122         return _portletDataHandlerInstance;
123     }
124 
125     public Portlet getPortletInstance() {
126         return _portletInstance;
127     }
128 
129     public PortletLayoutListener getPortletLayoutListenerInstance() {
130         return _portletLayoutListenerInstance;
131     }
132 
133     public String getPortletName() {
134         return _portletName;
135     }
136 
137     public PreferencesValidator getPreferencesValidatorInstance() {
138         return _prefsValidatorInstance;
139     }
140 
141     public ResourceBundle getResourceBundle(Locale locale) {
142         ResourceBundle resourceBundle = _resourceBundles.get(
143             LocaleUtil.toLanguageId(locale));
144 
145         if (resourceBundle == null) {
146             resourceBundle = _resourceBundles.get(locale.getLanguage());
147 
148             if (resourceBundle == null) {
149                 resourceBundle = _resourceBundles.get(
150                     LocaleUtil.toLanguageId(LocaleUtil.getDefault()));
151             }
152         }
153 
154         return resourceBundle;
155     }
156 
157     public Map<String, ResourceBundle> getResourceBundles() {
158         return _resourceBundles;
159     }
160 
161     public Scheduler getSchedulerInstance() {
162         return _schedulerInstance;
163     }
164 
165     public ServletContext getServletContext() {
166         return _servletContext;
167     }
168 
169     public SocialActivityInterpreter getSocialActivityInterpreterInstance() {
170         return _socialActivityInterpreterInstance;
171     }
172 
173     public SocialRequestInterpreter getSocialRequestInterpreterInstance() {
174         return _socialRequestInterpreterInstance;
175     }
176 
177     public URLEncoder getURLEncoderInstance() {
178         return _urlEncoderInstance;
179     }
180 
181     public void setPortletInstance(Portlet portletInstance) {
182         _portletInstance = portletInstance;
183     }
184 
185     public void setPortletName(String portletName) {
186         _portletName = portletName;
187     }
188 
189     private ConfigurationAction _configurationActionInstance;
190     private FriendlyURLMapper _friendlyURLMapperInstance;
191     private Indexer _indexerInstance;
192     private OpenSearch _openSearchInstance;
193     private PollerProcessor _pollerProcessorInstance;
194     private MessageListener _popMessageListenerInstance;
195     private PortletDataHandler _portletDataHandlerInstance;
196     private Portlet _portletInstance;
197     private PortletLayoutListener _portletLayoutListenerInstance;
198     private String _portletName;
199     private PreferencesValidator _prefsValidatorInstance;
200     private Map<String, ResourceBundle> _resourceBundles;
201     private Scheduler _schedulerInstance;
202     private ServletContext _servletContext;
203     private SocialActivityInterpreter _socialActivityInterpreterInstance;
204     private SocialRequestInterpreter _socialRequestInterpreterInstance;
205     private URLEncoder _urlEncoderInstance;
206 
207 }