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.portal.webdav.WebDAVStorage;
30  import com.liferay.portlet.social.model.SocialActivityInterpreter;
31  import com.liferay.portlet.social.model.SocialRequestInterpreter;
32  
33  import java.util.Locale;
34  import java.util.Map;
35  import java.util.ResourceBundle;
36  
37  import javax.portlet.Portlet;
38  import javax.portlet.PreferencesValidator;
39  
40  import javax.servlet.ServletContext;
41  
42  /**
43   * <a href="PortletBagImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * @author Brian Wing Shun Chan
46   */
47  public class PortletBagImpl implements PortletBag {
48  
49      public PortletBagImpl(
50          String portletName, ServletContext servletContext,
51          Portlet portletInstance,
52          ConfigurationAction configurationActionInstance,
53          Indexer indexerInstance, OpenSearch openSearchInstance,
54          Scheduler schedulerInstance,
55          FriendlyURLMapper friendlyURLMapperInstance,
56          URLEncoder urlEncoderInstance,
57          PortletDataHandler portletDataHandlerInstance,
58          PortletLayoutListener portletLayoutListenerInstance,
59          PollerProcessor pollerProcessorInstance,
60          MessageListener popMessageListenerInstance,
61          SocialActivityInterpreter socialActivityInterpreterInstance,
62          SocialRequestInterpreter socialRequestInterpreterInstance,
63          WebDAVStorage webDAVStorageInstance,
64          ControlPanelEntry controlPanelEntryInstance,
65          PreferencesValidator preferencesValidatorInstance,
66          Map<String, ResourceBundle> resourceBundles) {
67  
68          _portletName = portletName;
69          _servletContext = servletContext;
70          _portletInstance = portletInstance;
71          _configurationActionInstance = configurationActionInstance;
72          _indexerInstance = indexerInstance;
73          _openSearchInstance = openSearchInstance;
74          _schedulerInstance = schedulerInstance;
75          _friendlyURLMapperInstance = friendlyURLMapperInstance;
76          _urlEncoderInstance = urlEncoderInstance;
77          _portletDataHandlerInstance = portletDataHandlerInstance;
78          _portletLayoutListenerInstance = portletLayoutListenerInstance;
79          _pollerProcessorInstance = pollerProcessorInstance;
80          _popMessageListenerInstance = popMessageListenerInstance;
81          _socialActivityInterpreterInstance = socialActivityInterpreterInstance;
82          _socialRequestInterpreterInstance = socialRequestInterpreterInstance;
83          _webDAVStorageInstance = webDAVStorageInstance;
84          _controlPanelEntryInstance = controlPanelEntryInstance;
85          _preferencesValidatorInstance = preferencesValidatorInstance;
86          _resourceBundles = resourceBundles;
87      }
88  
89      public Object clone() {
90          return new PortletBagImpl(
91              getPortletName(), getServletContext(), getPortletInstance(),
92              getConfigurationActionInstance(), getIndexerInstance(),
93              getOpenSearchInstance(), getSchedulerInstance(),
94              getFriendlyURLMapperInstance(), getURLEncoderInstance(),
95              getPortletDataHandlerInstance(), getPortletLayoutListenerInstance(),
96              getPollerProcessorInstance(), getPopMessageListenerInstance(),
97              getSocialActivityInterpreterInstance(),
98              getSocialRequestInterpreterInstance(), getWebDAVStorageInstance(),
99              getControlPanelEntryInstance(), getPreferencesValidatorInstance(),
100             getResourceBundles());
101     }
102 
103     public ConfigurationAction getConfigurationActionInstance() {
104         return _configurationActionInstance;
105     }
106 
107     public ControlPanelEntry getControlPanelEntryInstance() {
108         return _controlPanelEntryInstance;
109     }
110 
111     public FriendlyURLMapper getFriendlyURLMapperInstance() {
112         return _friendlyURLMapperInstance;
113     }
114 
115     public Indexer getIndexerInstance() {
116         return _indexerInstance;
117     }
118 
119     public OpenSearch getOpenSearchInstance() {
120         return _openSearchInstance;
121     }
122 
123     public PollerProcessor getPollerProcessorInstance() {
124         return _pollerProcessorInstance;
125     }
126 
127     public MessageListener getPopMessageListenerInstance() {
128         return _popMessageListenerInstance;
129     }
130 
131     public PortletDataHandler getPortletDataHandlerInstance() {
132         return _portletDataHandlerInstance;
133     }
134 
135     public Portlet getPortletInstance() {
136         return _portletInstance;
137     }
138 
139     public PortletLayoutListener getPortletLayoutListenerInstance() {
140         return _portletLayoutListenerInstance;
141     }
142 
143     public String getPortletName() {
144         return _portletName;
145     }
146 
147     public PreferencesValidator getPreferencesValidatorInstance() {
148         return _preferencesValidatorInstance;
149     }
150 
151     public ResourceBundle getResourceBundle(Locale locale) {
152         ResourceBundle resourceBundle = _resourceBundles.get(
153             LocaleUtil.toLanguageId(locale));
154 
155         if (resourceBundle == null) {
156             resourceBundle = _resourceBundles.get(locale.getLanguage());
157 
158             if (resourceBundle == null) {
159                 resourceBundle = _resourceBundles.get(
160                     LocaleUtil.toLanguageId(LocaleUtil.getDefault()));
161             }
162         }
163 
164         return resourceBundle;
165     }
166 
167     public Map<String, ResourceBundle> getResourceBundles() {
168         return _resourceBundles;
169     }
170 
171     public Scheduler getSchedulerInstance() {
172         return _schedulerInstance;
173     }
174 
175     public ServletContext getServletContext() {
176         return _servletContext;
177     }
178 
179     public SocialActivityInterpreter getSocialActivityInterpreterInstance() {
180         return _socialActivityInterpreterInstance;
181     }
182 
183     public SocialRequestInterpreter getSocialRequestInterpreterInstance() {
184         return _socialRequestInterpreterInstance;
185     }
186 
187     public URLEncoder getURLEncoderInstance() {
188         return _urlEncoderInstance;
189     }
190 
191     public WebDAVStorage getWebDAVStorageInstance() {
192         return _webDAVStorageInstance;
193     }
194 
195     public void setPortletInstance(Portlet portletInstance) {
196         _portletInstance = portletInstance;
197     }
198 
199     public void setPortletName(String portletName) {
200         _portletName = portletName;
201     }
202 
203     private ConfigurationAction _configurationActionInstance;
204     private ControlPanelEntry _controlPanelEntryInstance;
205     private FriendlyURLMapper _friendlyURLMapperInstance;
206     private Indexer _indexerInstance;
207     private OpenSearch _openSearchInstance;
208     private PollerProcessor _pollerProcessorInstance;
209     private MessageListener _popMessageListenerInstance;
210     private PortletDataHandler _portletDataHandlerInstance;
211     private Portlet _portletInstance;
212     private PortletLayoutListener _portletLayoutListenerInstance;
213     private String _portletName;
214     private PreferencesValidator _preferencesValidatorInstance;
215     private Map<String, ResourceBundle> _resourceBundles;
216     private Scheduler _schedulerInstance;
217     private ServletContext _servletContext;
218     private SocialActivityInterpreter _socialActivityInterpreterInstance;
219     private SocialRequestInterpreter _socialRequestInterpreterInstance;
220     private URLEncoder _urlEncoderInstance;
221     private WebDAVStorage _webDAVStorageInstance;
222 
223 }