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