1
22
23 package com.liferay.portlet;
24
25 import com.liferay.portal.kernel.job.Scheduler;
26 import com.liferay.portal.kernel.pop.MessageListener;
27 import com.liferay.portal.kernel.portlet.ConfigurationAction;
28 import com.liferay.portal.kernel.portlet.FriendlyURLMapper;
29 import com.liferay.portal.kernel.portlet.PortletBag;
30 import com.liferay.portal.kernel.portlet.PortletLayoutListener;
31 import com.liferay.portal.kernel.search.Indexer;
32 import com.liferay.portal.kernel.search.OpenSearch;
33 import com.liferay.portal.kernel.servlet.URLEncoder;
34 import com.liferay.portal.kernel.util.LocaleUtil;
35 import com.liferay.portal.lar.PortletDataHandler;
36 import com.liferay.portal.webdav.WebDAVStorage;
37 import com.liferay.portlet.social.model.SocialActivityInterpreter;
38 import com.liferay.portlet.social.model.SocialRequestInterpreter;
39
40 import java.util.Locale;
41 import java.util.Map;
42 import java.util.ResourceBundle;
43
44 import javax.portlet.Portlet;
45 import javax.portlet.PreferencesValidator;
46
47 import javax.servlet.ServletContext;
48
49
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 MessageListener popMessageListenerInstance,
68 SocialActivityInterpreter socialActivityInterpreterInstance,
69 SocialRequestInterpreter socialRequestInterpreterInstance,
70 WebDAVStorage webDAVStorageInstance,
71 ControlPanelEntry controlPanelEntryInstance,
72 PreferencesValidator preferencesValidatorInstance,
73 Map<String, ResourceBundle> resourceBundles) {
74
75 _portletName = portletName;
76 _servletContext = servletContext;
77 _portletInstance = portletInstance;
78 _configurationActionInstance = configurationActionInstance;
79 _indexerInstance = indexerInstance;
80 _openSearchInstance = openSearchInstance;
81 _schedulerInstance = schedulerInstance;
82 _friendlyURLMapperInstance = friendlyURLMapperInstance;
83 _urlEncoderInstance = urlEncoderInstance;
84 _portletDataHandlerInstance = portletDataHandlerInstance;
85 _portletLayoutListenerInstance = portletLayoutListenerInstance;
86 _popMessageListenerInstance = popMessageListenerInstance;
87 _socialActivityInterpreterInstance = socialActivityInterpreterInstance;
88 _socialRequestInterpreterInstance = socialRequestInterpreterInstance;
89 _webDAVStorageInstance = webDAVStorageInstance;
90 _controlPanelEntryInstance = controlPanelEntryInstance;
91 _preferencesValidatorInstance = preferencesValidatorInstance;
92 _resourceBundles = resourceBundles;
93 }
94
95 public String getPortletName() {
96 return _portletName;
97 }
98
99 public ServletContext getServletContext() {
100 return _servletContext;
101 }
102
103 public Portlet getPortletInstance() {
104 return _portletInstance;
105 }
106
107 public void removePortletInstance() {
108 _portletInstance = null;
109 }
110
111 public ConfigurationAction getConfigurationActionInstance() {
112 return _configurationActionInstance;
113 }
114
115 public Indexer getIndexerInstance() {
116 return _indexerInstance;
117 }
118
119 public OpenSearch getOpenSearchInstance() {
120 return _openSearchInstance;
121 }
122
123 public Scheduler getSchedulerInstance() {
124 return _schedulerInstance;
125 }
126
127 public FriendlyURLMapper getFriendlyURLMapperInstance() {
128 return _friendlyURLMapperInstance;
129 }
130
131 public URLEncoder getURLEncoderInstance() {
132 return _urlEncoderInstance;
133 }
134
135 public PortletDataHandler getPortletDataHandlerInstance() {
136 return _portletDataHandlerInstance;
137 }
138
139 public PortletLayoutListener getPortletLayoutListenerInstance() {
140 return _portletLayoutListenerInstance;
141 }
142
143 public MessageListener getPopMessageListenerInstance() {
144 return _popMessageListenerInstance;
145 }
146
147 public SocialActivityInterpreter getSocialActivityInterpreterInstance() {
148 return _socialActivityInterpreterInstance;
149 }
150
151 public SocialRequestInterpreter getSocialRequestInterpreterInstance() {
152 return _socialRequestInterpreterInstance;
153 }
154
155 public WebDAVStorage getWebDAVStorageInstance() {
156 return _webDAVStorageInstance;
157 }
158
159 public ControlPanelEntry getControlPanelEntryInstance() {
160 return _controlPanelEntryInstance;
161 }
162
163 public PreferencesValidator getPreferencesValidatorInstance() {
164 return _preferencesValidatorInstance;
165 }
166
167 public ResourceBundle getResourceBundle(Locale locale) {
168 ResourceBundle resourceBundle = _resourceBundles.get(
169 LocaleUtil.toLanguageId(locale));
170
171 if (resourceBundle == null) {
172 resourceBundle = _resourceBundles.get(locale.getLanguage());
173
174 if (resourceBundle == null) {
175 resourceBundle = _resourceBundles.get(
176 LocaleUtil.toLanguageId(LocaleUtil.getDefault()));
177 }
178 }
179
180 return resourceBundle;
181 }
182
183 private String _portletName;
184 private ServletContext _servletContext;
185 private Portlet _portletInstance;
186 private ConfigurationAction _configurationActionInstance;
187 private Indexer _indexerInstance;
188 private OpenSearch _openSearchInstance;
189 private Scheduler _schedulerInstance;
190 private FriendlyURLMapper _friendlyURLMapperInstance;
191 private URLEncoder _urlEncoderInstance;
192 private PortletDataHandler _portletDataHandlerInstance;
193 private PortletLayoutListener _portletLayoutListenerInstance;
194 private MessageListener _popMessageListenerInstance;
195 private SocialActivityInterpreter _socialActivityInterpreterInstance;
196 private SocialRequestInterpreter _socialRequestInterpreterInstance;
197 private WebDAVStorage _webDAVStorageInstance;
198 private ControlPanelEntry _controlPanelEntryInstance;
199 private PreferencesValidator _preferencesValidatorInstance;
200 private Map<String, ResourceBundle> _resourceBundles;
201
202 }