1
22
23 package com.liferay.portal.model.impl;
24
25 import com.liferay.portal.kernel.job.Scheduler;
26 import com.liferay.portal.kernel.plugin.PluginPackage;
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.PortletBagPool;
32 import com.liferay.portal.kernel.portlet.PortletLayoutListener;
33 import com.liferay.portal.kernel.search.Indexer;
34 import com.liferay.portal.kernel.servlet.URLEncoder;
35 import com.liferay.portal.kernel.util.ContentTypes;
36 import com.liferay.portal.kernel.util.InstancePool;
37 import com.liferay.portal.kernel.util.StringPool;
38 import com.liferay.portal.kernel.util.StringUtil;
39 import com.liferay.portal.kernel.util.Validator;
40 import com.liferay.portal.lar.PortletDataHandler;
41 import com.liferay.portal.model.Plugin;
42 import com.liferay.portal.model.PluginSetting;
43 import com.liferay.portal.model.Portlet;
44 import com.liferay.portal.model.PortletApp;
45 import com.liferay.portal.model.PortletConstants;
46 import com.liferay.portal.model.PortletFilter;
47 import com.liferay.portal.model.PortletInfo;
48 import com.liferay.portal.model.PublicRenderParameter;
49 import com.liferay.portal.model.RoleConstants;
50 import com.liferay.portal.model.User;
51 import com.liferay.portal.service.RoleLocalServiceUtil;
52 import com.liferay.portal.service.UserLocalServiceUtil;
53 import com.liferay.portal.util.PortalUtil;
54 import com.liferay.portal.util.PropsValues;
55 import com.liferay.portal.util.QNameUtil;
56 import com.liferay.portlet.PortletBagImpl;
57 import com.liferay.portlet.social.model.SocialActivityInterpreter;
58 import com.liferay.portlet.social.model.SocialRequestInterpreter;
59
60 import java.util.ArrayList;
61 import java.util.Collections;
62 import java.util.HashMap;
63 import java.util.HashSet;
64 import java.util.Hashtable;
65 import java.util.Iterator;
66 import java.util.LinkedHashMap;
67 import java.util.List;
68 import java.util.Map;
69 import java.util.Set;
70 import java.util.TreeSet;
71
72 import javax.portlet.PortletMode;
73
74 import javax.xml.namespace.QName;
75
76 import org.apache.commons.logging.Log;
77 import org.apache.commons.logging.LogFactory;
78
79
85 public class PortletImpl extends PortletModelImpl implements Portlet {
86
87
90 public PortletImpl() {
91 }
92
93
96 public PortletImpl(long companyId, String portletId) {
97 setCompanyId(companyId);
98 setPortletId(portletId);
99 setStrutsPath(portletId);
100 setActive(true);
101 _headerPortalCss = new ArrayList<String>();
102 _headerPortletCss = new ArrayList<String>();
103 _headerPortalJavaScript = new ArrayList<String>();
104 _headerPortletJavaScript = new ArrayList<String>();
105 _footerPortalCss = new ArrayList<String>();
106 _footerPortletCss = new ArrayList<String>();
107 _footerPortalJavaScript = new ArrayList<String>();
108 _footerPortletJavaScript = new ArrayList<String>();
109 _unlinkedRoles = new HashSet<String>();
110 _roleMappers = new LinkedHashMap<String, String>();
111 _initParams = new HashMap<String, String>();
112 _portletModes = new HashMap<String, Set<String>>();
113 _supportedLocales = new HashSet<String>();
114 _portletFilters = new LinkedHashMap<String, PortletFilter>();
115 _processingEvents = new HashSet<QName>();
116 _publishingEvents = new HashSet<QName>();
117 _publicRenderParameters = new HashSet<PublicRenderParameter>();
118 }
119
120
123 public PortletImpl(
124 String portletId, PluginPackage pluginPackage,
125 PluginSetting pluginSetting, long companyId, long timestamp,
126 String icon, String virtualPath, String strutsPath, String portletName,
127 String displayName, String portletClass,
128 String configurationActionClass, String indexerClass,
129 String openSearchClass, String schedulerClass, String portletURLClass,
130 String friendlyURLMapperClass, String urlEncoderClass,
131 String portletDataHandlerClass, String portletLayoutListenerClass,
132 String popMessageListenerClass, String socialActivityInterpreterClass,
133 String socialRequestInterpreterClass, String defaultPreferences,
134 String prefsValidator, boolean prefsCompanyWide,
135 boolean prefsUniquePerLayout, boolean prefsOwnedByGroup,
136 boolean useDefaultTemplate, boolean showPortletAccessDenied,
137 boolean showPortletInactive, boolean actionURLRedirect,
138 boolean restoreCurrentView, boolean maximizeEdit, boolean maximizeHelp,
139 boolean popUpPrint, boolean layoutCacheable, boolean instanceable,
140 String userPrincipalStrategy, boolean privateRequestAttributes,
141 boolean privateSessionAttributes, int renderWeight, boolean ajaxable,
142 List<String> headerPortalCss, List<String> headerPortletCss,
143 List<String> headerPortalJavaScript,
144 List<String> headerPortletJavaScript, List<String> footerPortalCss,
145 List<String> footerPortletCss, List<String> footerPortalJavaScript,
146 List<String> footerPortletJavaScript,
147 String cssClassWrapper, String facebookIntegration,
148 boolean addDefaultResource, String roles, Set<String> unlinkedRoles,
149 Map<String, String> roleMappers, boolean system, boolean active,
150 boolean include, Map<String, String> initParams, Integer expCache,
151 Map<String, Set<String>> portletModes, Set<String> supportedLocales,
152 String resourceBundle, PortletInfo portletInfo,
153 Map<String, PortletFilter> portletFilters, Set<QName> processingEvents,
154 Set<QName> publishingEvents,
155 Set<PublicRenderParameter> publicRenderParameters,
156 PortletApp portletApp) {
157
158 setPortletId(portletId);
159 _pluginPackage = pluginPackage;
160 _defaultPluginSetting = pluginSetting;
161 setCompanyId(companyId);
162 _timestamp = timestamp;
163 _icon = icon;
164 _virtualPath = virtualPath;
165 _strutsPath = strutsPath;
166 _portletName = portletName;
167 _displayName = displayName;
168 _portletClass = portletClass;
169 _configurationActionClass = configurationActionClass;
170 _indexerClass = indexerClass;
171 _openSearchClass = openSearchClass;
172 _schedulerClass = schedulerClass;
173 _portletURLClass = portletURLClass;
174 _friendlyURLMapperClass = friendlyURLMapperClass;
175 _urlEncoderClass = urlEncoderClass;
176 _portletDataHandlerClass = portletDataHandlerClass;
177 _portletLayoutListenerClass = portletLayoutListenerClass;
178 _popMessageListenerClass = popMessageListenerClass;
179 _socialActivityInterpreterClass = socialActivityInterpreterClass;
180 _socialRequestInterpreterClass = socialRequestInterpreterClass;
181 _defaultPreferences = defaultPreferences;
182 _prefsValidator = prefsValidator;
183 _prefsCompanyWide = prefsCompanyWide;
184 _prefsUniquePerLayout = prefsUniquePerLayout;
185 _prefsOwnedByGroup = prefsOwnedByGroup;
186 _useDefaultTemplate = useDefaultTemplate;
187 _showPortletAccessDenied = showPortletAccessDenied;
188 _showPortletInactive = showPortletInactive;
189 _actionURLRedirect = actionURLRedirect;
190 _restoreCurrentView = restoreCurrentView;
191 _maximizeEdit = maximizeEdit;
192 _maximizeHelp = maximizeHelp;
193 _popUpPrint = popUpPrint;
194 _layoutCacheable = layoutCacheable;
195 _instanceable = instanceable;
196 _userPrincipalStrategy = userPrincipalStrategy;
197 _privateRequestAttributes = privateRequestAttributes;
198 _privateSessionAttributes = privateSessionAttributes;
199 _renderWeight = renderWeight;
200 _ajaxable = ajaxable;
201 _headerPortalCss = headerPortalCss;
202 _headerPortletCss = headerPortletCss;
203 _headerPortalJavaScript = headerPortalJavaScript;
204 _headerPortletJavaScript = headerPortletJavaScript;
205 _footerPortalCss = footerPortalCss;
206 _footerPortletCss = footerPortletCss;
207 _footerPortalJavaScript = footerPortalJavaScript;
208 _footerPortletJavaScript = footerPortletJavaScript;
209 _cssClassWrapper = cssClassWrapper;
210 _facebookIntegration = facebookIntegration;
211 _addDefaultResource = addDefaultResource;
212 setRoles(roles);
213 _unlinkedRoles = unlinkedRoles;
214 _roleMappers = roleMappers;
215 _system = system;
216 setActive(active);
217 _include = include;
218 _initParams = initParams;
219 _expCache = expCache;
220 _portletModes = portletModes;
221 _supportedLocales = supportedLocales;
222 _resourceBundle = resourceBundle;
223 _portletInfo = portletInfo;
224 _portletFilters = portletFilters;
225 setProcessingEvents(processingEvents);
226 setPublishingEvents(publishingEvents);
227 setPublicRenderParameters(publicRenderParameters);
228 _portletApp = portletApp;
229
230 if (_instanceable) {
231 _clonedInstances = new Hashtable<String, Portlet>();
232 }
233 }
234
235
240 public String getRootPortletId() {
241 return PortletConstants.getRootPortletId(getPortletId());
242 }
243
244
249 public String getInstanceId() {
250 return PortletConstants.getInstanceId(getPortletId());
251 }
252
253
258 public String getPluginId() {
259 return getRootPortletId();
260 }
261
262
267 public String getPluginType() {
268 return Plugin.TYPE_PORTLET;
269 }
270
271
276 public PluginPackage getPluginPackage() {
277 return _pluginPackage;
278 }
279
280
285 public void setPluginPackage(PluginPackage pluginPackage) {
286 _pluginPackage = pluginPackage;
287 }
288
289
294 public PluginSetting getDefaultPluginSetting() {
295 return _defaultPluginSetting;
296 }
297
298
303 public void setDefaultPluginSetting(PluginSetting pluginSetting) {
304 _defaultPluginSetting = pluginSetting;
305 }
306
307
312 public long getTimestamp() {
313 return _timestamp;
314 }
315
316
321 public void setTimestamp(long timestamp) {
322 _timestamp = timestamp;
323 }
324
325
330 public String getIcon() {
331 return _icon;
332 }
333
334
339 public void setIcon(String icon) {
340 _icon = icon;
341 }
342
343
348 public String getVirtualPath() {
349 return _virtualPath;
350 }
351
352
357 public void setVirtualPath(String virtualPath) {
358 if (_portletApp.isWARFile() && Validator.isNull(virtualPath)) {
359 virtualPath = PropsValues.PORTLET_VIRTUAL_PATH;
360 }
361
362 _virtualPath = virtualPath;
363 }
364
365
370 public String getStrutsPath() {
371 return _strutsPath;
372 }
373
374
379 public void setStrutsPath(String strutsPath) {
380 _strutsPath = strutsPath;
381 }
382
383
388 public String getPortletName() {
389 return _portletName;
390 }
391
392
397 public void setPortletName(String portletName) {
398 _portletName = portletName;
399 }
400
401
406 public String getDisplayName() {
407 return _displayName;
408 }
409
410
415 public void setDisplayName(String displayName) {
416 _displayName = displayName;
417 }
418
419
424 public String getPortletClass() {
425 return _portletClass;
426 }
427
428
433 public void setPortletClass(String portletClass) {
434 _portletClass = portletClass;
435 }
436
437
442 public String getConfigurationActionClass() {
443 return _configurationActionClass;
444 }
445
446
452 public void setConfigurationActionClass(String configurationActionClass) {
453 _configurationActionClass = configurationActionClass;
454 }
455
456
461 public ConfigurationAction getConfigurationActionInstance() {
462 if (Validator.isNotNull(getConfigurationActionClass())) {
463 if (_portletApp.isWARFile()) {
464 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
465
466 return portletBag.getConfigurationActionInstance();
467 }
468 else {
469 return (ConfigurationAction)InstancePool.get(
470 getConfigurationActionClass());
471 }
472 }
473
474 return null;
475 }
476
477
482 public String getIndexerClass() {
483 return _indexerClass;
484 }
485
486
491 public void setIndexerClass(String indexerClass) {
492 _indexerClass = indexerClass;
493 }
494
495
500 public Indexer getIndexerInstance() {
501 if (Validator.isNotNull(getIndexerClass())) {
502 if (_portletApp.isWARFile()) {
503 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
504
505 return portletBag.getIndexerInstance();
506 }
507 else {
508 return (Indexer)InstancePool.get(getIndexerClass());
509 }
510 }
511
512 return null;
513 }
514
515
520 public String getOpenSearchClass() {
521 return _openSearchClass;
522 }
523
524
530 public void setOpenSearchClass(String openSearchClass) {
531 _openSearchClass = openSearchClass;
532 }
533
534
539 public String getSchedulerClass() {
540 return _schedulerClass;
541 }
542
543
549 public void setSchedulerClass(String schedulerClass) {
550 _schedulerClass = schedulerClass;
551 }
552
553
558 public Scheduler getSchedulerInstance() {
559 if (Validator.isNotNull(getSchedulerClass())) {
560 if (_portletApp.isWARFile()) {
561 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
562
563 return portletBag.getSchedulerInstance();
564 }
565 else {
566 return (Scheduler)InstancePool.get(getSchedulerClass());
567 }
568 }
569
570 return null;
571 }
572
573
578 public String getPortletURLClass() {
579 return _portletURLClass;
580 }
581
582
588 public void setPortletURLClass(String portletURLClass) {
589 _portletURLClass = portletURLClass;
590 }
591
592
597 public String getFriendlyURLMapperClass() {
598 return _friendlyURLMapperClass;
599 }
600
601
607 public void setFriendlyURLMapperClass(String friendlyURLMapperClass) {
608 _friendlyURLMapperClass = friendlyURLMapperClass;
609 }
610
611
616 public FriendlyURLMapper getFriendlyURLMapperInstance() {
617 if (Validator.isNotNull(getFriendlyURLMapperClass())) {
618 if (_portletApp.isWARFile()) {
619 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
620
621 return portletBag.getFriendlyURLMapperInstance();
622 }
623 else {
624 return (FriendlyURLMapper)InstancePool.get(
625 getFriendlyURLMapperClass());
626 }
627 }
628
629 return null;
630 }
631
632
637 public String getURLEncoderClass() {
638 return _urlEncoderClass;
639 }
640
641
647 public void setURLEncoderClass(String urlEncoderClass) {
648 _urlEncoderClass = urlEncoderClass;
649 }
650
651
656 public URLEncoder getURLEncoderInstance() {
657 if (Validator.isNotNull(getURLEncoderClass())) {
658 if (_portletApp.isWARFile()) {
659 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
660
661 return portletBag.getURLEncoderInstance();
662 }
663 else {
664 return (URLEncoder)InstancePool.get(getURLEncoderClass());
665 }
666 }
667
668 return null;
669 }
670
671
676 public String getPortletDataHandlerClass() {
677 return _portletDataHandlerClass;
678 }
679
680
686 public void setPortletDataHandlerClass(String portletDataHandlerClass) {
687 _portletDataHandlerClass = portletDataHandlerClass;
688 }
689
690
695 public PortletDataHandler getPortletDataHandlerInstance() {
696 if (Validator.isNotNull(getPortletDataHandlerClass())) {
697 if (_portletApp.isWARFile()) {
698 PortletBagImpl portletBagImpl =
699 (PortletBagImpl)PortletBagPool.get(getRootPortletId());
700
701 return portletBagImpl.getPortletDataHandlerInstance();
702 }
703 else {
704 return (PortletDataHandler)InstancePool.get(
705 getPortletDataHandlerClass());
706 }
707 }
708
709 return null;
710 }
711
712
717 public PortletLayoutListener getPortletLayoutListener() {
718 if (Validator.isNull(getPortletLayoutListenerClass())) {
719 return null;
720 }
721
722 return (PortletLayoutListener)InstancePool.get(
723 getPortletLayoutListenerClass());
724 }
725
726
731 public String getPortletLayoutListenerClass() {
732 return _portletLayoutListenerClass;
733 }
734
735
741 public void setPortletLayoutListenerClass(
742 String portletLayoutListenerClass) {
743
744 _portletLayoutListenerClass = portletLayoutListenerClass;
745 }
746
747
752 public String getPopMessageListenerClass() {
753 return _popMessageListenerClass;
754 }
755
756
762 public void setPopMessageListenerClass(String popMessageListenerClass) {
763 _popMessageListenerClass = popMessageListenerClass;
764 }
765
766
771 public MessageListener getPopMessageListenerInstance() {
772 if (Validator.isNotNull(getPopMessageListenerClass())) {
773 if (_portletApp.isWARFile()) {
774 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
775
776 return portletBag.getPopMessageListenerInstance();
777 }
778 else {
779 return (MessageListener)InstancePool.get(
780 getPopMessageListenerClass());
781 }
782 }
783
784 return null;
785 }
786
787
793 public String getSocialActivityInterpreterClass() {
794 return _socialActivityInterpreterClass;
795 }
796
797
803 public void setSocialActivityInterpreterClass(
804 String socialActivityInterpreterClass) {
805
806 _socialActivityInterpreterClass = socialActivityInterpreterClass;
807 }
808
809
814 public SocialActivityInterpreter getSocialActivityInterpreterInstance() {
815 if (Validator.isNotNull(getSocialActivityInterpreterClass())) {
816 if (_portletApp.isWARFile()) {
817 PortletBagImpl portletBagImpl =
818 (PortletBagImpl)PortletBagPool.get(getRootPortletId());
819
820 return portletBagImpl.getSocialActivityInterpreterInstance();
821 }
822 else {
823 return (SocialActivityInterpreter)InstancePool.get(
824 getSocialActivityInterpreterClass());
825 }
826 }
827
828 return null;
829 }
830
831
837 public String getSocialRequestInterpreterClass() {
838 return _socialRequestInterpreterClass;
839 }
840
841
847 public void setSocialRequestInterpreterClass(
848 String socialRequestInterpreterClass) {
849
850 _socialRequestInterpreterClass = socialRequestInterpreterClass;
851 }
852
853
858 public SocialRequestInterpreter getSocialRequestInterpreterInstance() {
859 if (Validator.isNotNull(getSocialRequestInterpreterClass())) {
860 if (_portletApp.isWARFile()) {
861 PortletBagImpl portletBag =
862 (PortletBagImpl)PortletBagPool.get(getRootPortletId());
863
864 return portletBag.getSocialRequestInterpreterInstance();
865 }
866 else {
867 return (SocialRequestInterpreter)InstancePool.get(
868 getSocialRequestInterpreterClass());
869 }
870 }
871
872 return null;
873 }
874
875
880 public String getDefaultPreferences() {
881 if (Validator.isNull(_defaultPreferences)) {
882 return PortletConstants.DEFAULT_PREFERENCES;
883 }
884 else {
885 return _defaultPreferences;
886 }
887 }
888
889
894 public void setDefaultPreferences(String defaultPreferences) {
895 _defaultPreferences = defaultPreferences;
896 }
897
898
903 public String getPreferencesValidator() {
904 return _prefsValidator;
905 }
906
907
913 public void setPreferencesValidator(String prefsValidator) {
914 if (prefsValidator != null) {
915
916
919 _prefsValidator = prefsValidator.trim();
920 }
921 else {
922 _prefsValidator = null;
923 }
924 }
925
926
931 public boolean getPreferencesCompanyWide() {
932 return _prefsCompanyWide;
933 }
934
935
940 public boolean isPreferencesCompanyWide() {
941 return _prefsCompanyWide;
942 }
943
944
950 public void setPreferencesCompanyWide(boolean prefsCompanyWide) {
951 _prefsCompanyWide = prefsCompanyWide;
952 }
953
954
959 public boolean getPreferencesUniquePerLayout() {
960 return _prefsUniquePerLayout;
961 }
962
963
968 public boolean isPreferencesUniquePerLayout() {
969 return _prefsUniquePerLayout;
970 }
971
972
978 public void setPreferencesUniquePerLayout(boolean prefsUniquePerLayout) {
979 _prefsUniquePerLayout = prefsUniquePerLayout;
980 }
981
982
991 public boolean getPreferencesOwnedByGroup() {
992 return _prefsOwnedByGroup;
993 }
994
995
1004 public boolean isPreferencesOwnedByGroup() {
1005 return _prefsOwnedByGroup;
1006 }
1007
1008
1017 public void setPreferencesOwnedByGroup(boolean prefsOwnedByGroup) {
1018 _prefsOwnedByGroup = prefsOwnedByGroup;
1019 }
1020
1021
1026 public boolean getUseDefaultTemplate() {
1027 return _useDefaultTemplate;
1028 }
1029
1030
1035 public boolean isUseDefaultTemplate() {
1036 return _useDefaultTemplate;
1037 }
1038
1039
1045 public void setUseDefaultTemplate(boolean useDefaultTemplate) {
1046 _useDefaultTemplate = useDefaultTemplate;
1047 }
1048
1049
1056 public boolean getShowPortletAccessDenied() {
1057 return _showPortletAccessDenied;
1058 }
1059
1060
1067 public boolean isShowPortletAccessDenied() {
1068 return _showPortletAccessDenied;
1069 }
1070
1071
1078 public void setShowPortletAccessDenied(boolean showPortletAccessDenied) {
1079 _showPortletAccessDenied = showPortletAccessDenied;
1080 }
1081
1082
1087 public boolean getShowPortletInactive() {
1088 return _showPortletInactive;
1089 }
1090
1091
1096 public boolean isShowPortletInactive() {
1097 return _showPortletInactive;
1098 }
1099
1100
1106 public void setShowPortletInactive(boolean showPortletInactive) {
1107 _showPortletInactive = showPortletInactive;
1108 }
1109
1110
1117 public boolean getActionURLRedirect() {
1118 return _actionURLRedirect;
1119 }
1120
1121
1128 public boolean isActionURLRedirect() {
1129 return _actionURLRedirect;
1130 }
1131
1132
1139 public void setActionURLRedirect(boolean actionURLRedirect) {
1140 _actionURLRedirect = actionURLRedirect;
1141 }
1142
1143
1150 public boolean getRestoreCurrentView() {
1151 return _restoreCurrentView;
1152 }
1153
1154
1161 public boolean isRestoreCurrentView() {
1162 return _restoreCurrentView;
1163 }
1164
1165
1172 public void setRestoreCurrentView(boolean restoreCurrentView) {
1173 _restoreCurrentView = restoreCurrentView;
1174 }
1175
1176
1183 public boolean getMaximizeEdit() {
1184 return _maximizeEdit;
1185 }
1186
1187
1194 public boolean isMaximizeEdit() {
1195 return _maximizeEdit;
1196 }
1197
1198
1205 public void setMaximizeEdit(boolean maximizeEdit) {
1206 _maximizeEdit = maximizeEdit;
1207 }
1208
1209
1216 public boolean getMaximizeHelp() {
1217 return _maximizeHelp;
1218 }
1219
1220
1227 public boolean isMaximizeHelp() {
1228 return _maximizeHelp;
1229 }
1230
1231
1238 public void setMaximizeHelp(boolean maximizeHelp) {
1239 _maximizeHelp = maximizeHelp;
1240 }
1241
1242
1249 public boolean getPopUpPrint() {
1250 return _popUpPrint;
1251 }
1252
1253
1260 public boolean isPopUpPrint() {
1261 return _popUpPrint;
1262 }
1263
1264
1271 public void setPopUpPrint(boolean popUpPrint) {
1272 _popUpPrint = popUpPrint;
1273 }
1274
1275
1280 public boolean getLayoutCacheable() {
1281 return _layoutCacheable;
1282 }
1283
1284
1289 public boolean isLayoutCacheable() {
1290 return _layoutCacheable;
1291 }
1292
1293
1299 public void setLayoutCacheable(boolean layoutCacheable) {
1300 _layoutCacheable = layoutCacheable;
1301 }
1302
1303
1308 public boolean getInstanceable() {
1309 return _instanceable;
1310 }
1311
1312
1317 public boolean isInstanceable() {
1318 return _instanceable;
1319 }
1320
1321
1327 public void setInstanceable(boolean instanceable) {
1328 _instanceable = instanceable;
1329 }
1330
1331
1336 public String getUserPrincipalStrategy() {
1337 return _userPrincipalStrategy;
1338 }
1339
1340
1346 public void setUserPrincipalStrategy(String userPrincipalStrategy) {
1347 if (Validator.isNotNull(userPrincipalStrategy)) {
1348 _userPrincipalStrategy = userPrincipalStrategy;
1349 }
1350 }
1351
1352
1359 public boolean getPrivateRequestAttributes() {
1360 return _privateRequestAttributes;
1361 }
1362
1363
1370 public boolean isPrivateRequestAttributes() {
1371 return _privateRequestAttributes;
1372 }
1373
1374
1382 public void setPrivateRequestAttributes(boolean privateRequestAttributes) {
1383 _privateRequestAttributes = privateRequestAttributes;
1384 }
1385
1386
1393 public boolean getPrivateSessionAttributes() {
1394 return _privateSessionAttributes;
1395 }
1396
1397
1404 public boolean isPrivateSessionAttributes() {
1405 return _privateSessionAttributes;
1406 }
1407
1408
1415 public void setPrivateSessionAttributes(boolean privateSessionAttributes) {
1416 _privateSessionAttributes = privateSessionAttributes;
1417 }
1418
1419
1424 public int getRenderWeight() {
1425 return _renderWeight;
1426 }
1427
1428
1433 public void setRenderWeight(int renderWeight) {
1434 _renderWeight = renderWeight;
1435 }
1436
1437
1442 public boolean getAjaxable() {
1443 return _ajaxable;
1444 }
1445
1446
1451 public boolean isAjaxable() {
1452 return _ajaxable;
1453 }
1454
1455
1461 public void setAjaxable(boolean ajaxable) {
1462 _ajaxable = ajaxable;
1463 }
1464
1465
1472 public List<String> getHeaderPortalCss() {
1473 return _headerPortalCss;
1474 }
1475
1476
1483 public void setHeaderPortalCss(List<String> headerPortalCss) {
1484 _headerPortalCss = headerPortalCss;
1485 }
1486
1487
1494 public List<String> getHeaderPortletCss() {
1495 return _headerPortletCss;
1496 }
1497
1498
1506 public void setHeaderPortletCss(List<String> headerPortletCss) {
1507 _headerPortletCss = headerPortletCss;
1508 }
1509
1510
1517 public List<String> getHeaderPortalJavaScript() {
1518 return _headerPortalJavaScript;
1519 }
1520
1521
1529 public void setHeaderPortalJavaScript(List<String> headerPortalJavaScript) {
1530 _headerPortalJavaScript = headerPortalJavaScript;
1531 }
1532
1533
1540 public List<String> getHeaderPortletJavaScript() {
1541 return _headerPortletJavaScript;
1542 }
1543
1544
1552 public void setHeaderPortletJavaScript(
1553 List<String> headerPortletJavaScript) {
1554
1555 _headerPortletJavaScript = headerPortletJavaScript;
1556 }
1557
1558
1565 public List<String> getFooterPortalCss() {
1566 return _footerPortalCss;
1567 }
1568
1569
1576 public void setFooterPortalCss(List<String> footerPortalCss) {
1577 _footerPortalCss = footerPortalCss;
1578 }
1579
1580
1587 public List<String> getFooterPortletCss() {
1588 return _footerPortletCss;
1589 }
1590
1591
1599 public void setFooterPortletCss(List<String> footerPortletCss) {
1600 _footerPortletCss = footerPortletCss;
1601 }
1602
1603
1610 public List<String> getFooterPortalJavaScript() {
1611 return _footerPortalJavaScript;
1612 }
1613
1614
1622 public void setFooterPortalJavaScript(List<String> footerPortalJavaScript) {
1623 _footerPortalJavaScript = footerPortalJavaScript;
1624 }
1625
1626
1633 public List<String> getFooterPortletJavaScript() {
1634 return _footerPortletJavaScript;
1635 }
1636
1637
1645 public void setFooterPortletJavaScript(
1646 List<String> footerPortletJavaScript) {
1647
1648 _footerPortletJavaScript = footerPortletJavaScript;
1649 }
1650
1651
1658 public String getCssClassWrapper() {
1659 return _cssClassWrapper;
1660 }
1661
1662
1669 public void setCssClassWrapper(String cssClassWrapper) {
1670 _cssClassWrapper = cssClassWrapper;
1671 }
1672
1673
1678 public String getFacebookIntegration() {
1679 return _facebookIntegration;
1680 }
1681
1682
1688 public void setFacebookIntegration(String facebookIntegration) {
1689 if (Validator.isNotNull(facebookIntegration)) {
1690 _facebookIntegration = facebookIntegration;
1691 }
1692 }
1693
1694
1700 public boolean getAddDefaultResource() {
1701 return _addDefaultResource;
1702 }
1703
1704
1710 public boolean isAddDefaultResource() {
1711 return _addDefaultResource;
1712 }
1713
1714
1720 public void setAddDefaultResource(boolean addDefaultResource) {
1721 _addDefaultResource = addDefaultResource;
1722 }
1723
1724
1729 public void setRoles(String roles) {
1730 _rolesArray = StringUtil.split(roles);
1731
1732 super.setRoles(roles);
1733 }
1734
1735
1740 public String[] getRolesArray() {
1741 return _rolesArray;
1742 }
1743
1744
1749 public void setRolesArray(String[] rolesArray) {
1750 _rolesArray = rolesArray;
1751
1752 super.setRoles(StringUtil.merge(rolesArray));
1753 }
1754
1755
1760 public Set<String> getUnlinkedRoles() {
1761 return _unlinkedRoles;
1762 }
1763
1764
1769 public void setUnlinkedRoles(Set<String> unlinkedRoles) {
1770 _unlinkedRoles = unlinkedRoles;
1771 }
1772
1773
1778 public Map<String, String> getRoleMappers() {
1779 return _roleMappers;
1780 }
1781
1782
1787 public void setRoleMappers(Map<String, String> roleMappers) {
1788 _roleMappers = roleMappers;
1789 }
1790
1791
1795 public void linkRoles() {
1796 List<String> linkedRoles = new ArrayList<String>();
1797
1798 Iterator<String> itr = _unlinkedRoles.iterator();
1799
1800 while (itr.hasNext()) {
1801 String unlinkedRole = itr.next();
1802
1803 String roleLink = _roleMappers.get(unlinkedRole);
1804
1805 if (Validator.isNotNull(roleLink)) {
1806 if (_log.isDebugEnabled()) {
1807 _log.debug(
1808 "Linking role for portlet [" + getPortletId() +
1809 "] with role-name [" + unlinkedRole +
1810 "] to role-link [" + roleLink + "]");
1811 }
1812
1813 linkedRoles.add(roleLink);
1814 }
1815 else {
1816 _log.error(
1817 "Unable to link role for portlet [" + getPortletId() +
1818 "] with role-name [" + unlinkedRole +
1819 "] because role-link is null");
1820 }
1821 }
1822
1823 Collections.sort(linkedRoles);
1824
1825 setRolesArray(linkedRoles.toArray(new String[linkedRoles.size()]));
1826 }
1827
1828
1833 public boolean hasRoleWithName(String roleName) {
1834 for (int i = 0; i < _rolesArray.length; i++) {
1835 if (_rolesArray[i].equalsIgnoreCase(roleName)) {
1836 return true;
1837 }
1838 }
1839
1840 return false;
1841 }
1842
1843
1850 public boolean hasAddPortletPermission(long userId) {
1851 try {
1852 if (_rolesArray.length == 0) {
1853 return true;
1854 }
1855 else if (RoleLocalServiceUtil.hasUserRoles(
1856 userId, getCompanyId(), _rolesArray, true)) {
1857
1858 return true;
1859 }
1860 else if (RoleLocalServiceUtil.hasUserRole(
1861 userId, getCompanyId(), RoleConstants.ADMINISTRATOR,
1862 true)) {
1863
1864 return true;
1865 }
1866 else {
1867 User user = UserLocalServiceUtil.getUserById(userId);
1868
1869 if (user.isDefaultUser() &&
1870 hasRoleWithName(RoleConstants.GUEST)) {
1871
1872 return true;
1873 }
1874 }
1875 }
1876 catch (Exception e) {
1877 _log.error(e);
1878 }
1879
1880 return false;
1881 }
1882
1883
1890 public boolean getSystem() {
1891 return _system;
1892 }
1893
1894
1901 public boolean isSystem() {
1902 return _system;
1903 }
1904
1905
1912 public void setSystem(boolean system) {
1913 _system = system;
1914 }
1915
1916
1923 public boolean getInclude() {
1924 return _include;
1925 }
1926
1927
1934 public boolean isInclude() {
1935 return _include;
1936 }
1937
1938
1945 public void setInclude(boolean include) {
1946 _include = include;
1947 }
1948
1949
1954 public Map<String, String> getInitParams() {
1955 return _initParams;
1956 }
1957
1958
1963 public void setInitParams(Map<String, String> initParams) {
1964 _initParams = initParams;
1965 }
1966
1967
1972 public Integer getExpCache() {
1973 return _expCache;
1974 }
1975
1976
1981 public void setExpCache(Integer expCache) {
1982 _expCache = expCache;
1983 }
1984
1985
1990 public Map<String, Set<String>> getPortletModes() {
1991 return _portletModes;
1992 }
1993
1994
1999 public void setPortletModes(Map<String, Set<String>> portletModes) {
2000 _portletModes = portletModes;
2001 }
2002
2003
2010 public boolean hasPortletMode(String mimeType, PortletMode portletMode) {
2011 if (mimeType == null) {
2012 mimeType = ContentTypes.TEXT_HTML;
2013 }
2014
2015 Set<String> mimeTypeModes = _portletModes.get(mimeType);
2016
2017 if (mimeTypeModes == null) {
2018 return false;
2019 }
2020
2021 if (mimeTypeModes.contains(portletMode.toString())) {
2022 return true;
2023 }
2024 else {
2025 return false;
2026 }
2027 }
2028
2029
2034 public Set<String> getAllPortletModes() {
2035 Set<String> allPortletModes = new TreeSet<String>();
2036
2037 Iterator<Map.Entry <String, Set<String>>> itr1 =
2038 _portletModes.entrySet().iterator();
2039
2040 while (itr1.hasNext()) {
2041 Map.Entry<String, Set<String>> entry = itr1.next();
2042
2043 Set<String> mimeTypeModes = entry.getValue();
2044
2045 Iterator<String> itr2 = mimeTypeModes.iterator();
2046
2047 while (itr2.hasNext()) {
2048 String portletMode = itr2.next();
2049
2050 allPortletModes.add(portletMode);
2051 }
2052 }
2053
2054 return allPortletModes;
2055 }
2056
2057
2062 public boolean hasMultipleMimeTypes() {
2063 if (_portletModes.size() > 1) {
2064 return true;
2065 }
2066 else {
2067 return false;
2068 }
2069 }
2070
2071
2076 public Set<String> getSupportedLocales() {
2077 return _supportedLocales;
2078 }
2079
2080
2085 public void setSupportedLocales(Set<String> supportedLocales) {
2086 _supportedLocales = supportedLocales;
2087 }
2088
2089
2094 public String getResourceBundle() {
2095 return _resourceBundle;
2096 }
2097
2098
2103 public void setResourceBundle(String resourceBundle) {
2104 _resourceBundle = resourceBundle;
2105 }
2106
2107
2112 public PortletInfo getPortletInfo() {
2113 return _portletInfo;
2114 }
2115
2116
2121 public void setPortletInfo(PortletInfo portletInfo) {
2122 _portletInfo = portletInfo;
2123 }
2124
2125
2130 public Map<String, PortletFilter> getPortletFilters() {
2131 return _portletFilters;
2132 }
2133
2134
2139 public void setPortletFilters(Map<String, PortletFilter> portletFilters) {
2140 _portletFilters = portletFilters;
2141 }
2142
2143
2148 public void addProcessingEvent(QName processingEvent) {
2149 _processingEvents.add(processingEvent);
2150 _processingEventsByQName.put(
2151 QNameUtil.getKey(processingEvent), processingEvent);
2152 }
2153
2154
2161 public QName getProcessingEvent(String uri, String localPart) {
2162 return _processingEventsByQName.get(
2163 QNameUtil.getKey(uri, localPart));
2164 }
2165
2166
2171 public Set<QName> getProcessingEvents() {
2172 return _processingEvents;
2173 }
2174
2175
2181 public void setProcessingEvents(Set<QName> processingEvents) {
2182 for (QName processingEvent : processingEvents) {
2183 addProcessingEvent(processingEvent);
2184 }
2185 }
2186
2187
2192 public void addPublishingEvent(QName publishingEvent) {
2193 _publishingEvents.add(publishingEvent);
2194 }
2195
2196
2201 public Set<QName> getPublishingEvents() {
2202 return _publishingEvents;
2203 }
2204
2205
2211 public void setPublishingEvents(Set<QName> publishingEvents) {
2212 for (QName publishingEvent : publishingEvents) {
2213 addPublishingEvent(publishingEvent);
2214 }
2215 }
2216
2217
2222 public void addPublicRenderParameter(
2223 PublicRenderParameter publicRenderParameter) {
2224
2225 _publicRenderParameters.add(publicRenderParameter);
2226 _publicRenderParametersByIdentifier.put(
2227 publicRenderParameter.getIdentifier(), publicRenderParameter);
2228 _publicRenderParametersByQName.put(
2229 QNameUtil.getKey(publicRenderParameter.getQName()),
2230 publicRenderParameter);
2231 }
2232
2233
2238 public PublicRenderParameter getPublicRenderParameter(String identifier) {
2239 return _publicRenderParametersByIdentifier.get(identifier);
2240 }
2241
2242
2249 public PublicRenderParameter getPublicRenderParameter(
2250 String uri, String localPart) {
2251
2252 return _publicRenderParametersByQName.get(
2253 QNameUtil.getKey(uri, localPart));
2254 }
2255
2256
2261 public Set<PublicRenderParameter> getPublicRenderParameters() {
2262 return _publicRenderParameters;
2263 }
2264
2265
2271 public void setPublicRenderParameters(
2272 Set<PublicRenderParameter> publicRenderParameters) {
2273
2274 for (PublicRenderParameter publicRenderParameter :
2275 publicRenderParameters) {
2276
2277 addPublicRenderParameter(publicRenderParameter);
2278 }
2279 }
2280
2281
2286 public String getContextPath() {
2287 String virtualPath = getVirtualPath();
2288
2289 if (Validator.isNotNull(virtualPath)) {
2290 return virtualPath;
2291 }
2292
2293 if (_portletApp.isWARFile()) {
2294 StringBuilder sb = new StringBuilder();
2295
2296 sb.append(StringPool.SLASH);
2297 sb.append(_portletApp.getServletContextName());
2298
2299 return sb.toString();
2300 }
2301 else {
2302 return PortalUtil.getPathContext();
2303 }
2304 }
2305
2306
2311 public PortletApp getPortletApp() {
2312 return _portletApp;
2313 }
2314
2315
2320 public void setPortletApp(PortletApp portletApp) {
2321 _portletApp = portletApp;
2322 }
2323
2324
2330 public Portlet getClonedInstance(String portletId) {
2331 if (_clonedInstances == null) {
2332
2333
2335 return null;
2336 }
2337
2338 Portlet clonedInstance = _clonedInstances.get(portletId);
2339
2340 if (clonedInstance == null) {
2341 clonedInstance = (Portlet)clone();
2342
2343 clonedInstance.setPortletId(portletId);
2344
2345
2352 }
2354
2355 return clonedInstance;
2356 }
2357
2358
2364 public boolean getStatic() {
2365 return _staticPortlet;
2366 }
2367
2368
2374 public boolean isStatic() {
2375 return _staticPortlet;
2376 }
2377
2378
2384 public void setStatic(boolean staticPortlet) {
2385 _staticPortlet = staticPortlet;
2386 }
2387
2388
2395 public boolean getStaticStart() {
2396 return _staticPortletStart;
2397 }
2398
2399
2406 public boolean isStaticStart() {
2407 return _staticPortletStart;
2408 }
2409
2410
2417 public void setStaticStart(boolean staticPortletStart) {
2418 _staticPortletStart = staticPortletStart;
2419 }
2420
2421
2428 public boolean getStaticEnd() {
2429 return !_staticPortletStart;
2430 }
2431
2432
2439 public boolean isStaticEnd() {
2440 return !_staticPortletStart;
2441 }
2442
2443
2448 public Object clone() {
2449 return new PortletImpl(
2450 getPortletId(), getPluginPackage(), getDefaultPluginSetting(),
2451 getCompanyId(), getTimestamp(), getIcon(), getVirtualPath(),
2452 getStrutsPath(), getPortletName(), getDisplayName(),
2453 getPortletClass(), getConfigurationActionClass(), getIndexerClass(),
2454 getOpenSearchClass(), getSchedulerClass(), getPortletURLClass(),
2455 getFriendlyURLMapperClass(), getURLEncoderClass(),
2456 getPortletDataHandlerClass(), getPortletLayoutListenerClass(),
2457 getPopMessageListenerClass(), getSocialActivityInterpreterClass(),
2458 getSocialRequestInterpreterClass(), getDefaultPreferences(),
2459 getPreferencesValidator(), isPreferencesCompanyWide(),
2460 isPreferencesUniquePerLayout(), isPreferencesOwnedByGroup(),
2461 isUseDefaultTemplate(), isShowPortletAccessDenied(),
2462 isShowPortletInactive(), isActionURLRedirect(),
2463 isRestoreCurrentView(), isMaximizeEdit(), isMaximizeHelp(),
2464 isPopUpPrint(), isLayoutCacheable(), isInstanceable(),
2465 getUserPrincipalStrategy(), isPrivateRequestAttributes(),
2466 isPrivateSessionAttributes(), getRenderWeight(), isAjaxable(),
2467 getHeaderPortalCss(), getHeaderPortletCss(),
2468 getHeaderPortalJavaScript(), getHeaderPortletJavaScript(),
2469 getFooterPortalCss(), getFooterPortletCss(),
2470 getFooterPortalJavaScript(), getFooterPortletJavaScript(),
2471 getCssClassWrapper(), getFacebookIntegration(),
2472 isAddDefaultResource(), getRoles(), getUnlinkedRoles(),
2473 getRoleMappers(), isSystem(), isActive(), isInclude(),
2474 getInitParams(), getExpCache(), getPortletModes(),
2475 getSupportedLocales(), getResourceBundle(), getPortletInfo(),
2476 getPortletFilters(), getProcessingEvents(), getPublishingEvents(),
2477 getPublicRenderParameters(), getPortletApp());
2478 }
2479
2480
2489 public int compareTo(Object obj) {
2490 Portlet portlet = (Portlet)obj;
2491
2492 return getPortletId().compareTo(portlet.getPortletId());
2493 }
2494
2495
2501 public boolean equals(Object obj) {
2502 Portlet portlet = (Portlet)obj;
2503
2504 return getPortletId().equals(portlet.getPortletId());
2505 }
2506
2507
2510 private static Log _log = LogFactory.getLog(PortletImpl.class);
2511
2512
2515 private PluginPackage _pluginPackage;
2516
2517
2520 private PluginSetting _defaultPluginSetting;
2521
2522
2525 private long _timestamp;
2526
2527
2530 private String _icon;
2531
2532
2535 private String _virtualPath;
2536
2537
2540 private String _strutsPath;
2541
2542
2545 private String _portletName;
2546
2547
2550 private String _displayName;
2551
2552
2555 private String _portletClass;
2556
2557
2560 private String _configurationActionClass;
2561
2562
2565 private String _indexerClass;
2566
2567
2570 private String _openSearchClass;
2571
2572
2575 private String _schedulerClass;
2576
2577
2580 private String _portletURLClass;
2581
2582
2585 private String _friendlyURLMapperClass;
2586
2587
2590 private String _urlEncoderClass;
2591
2592
2595 private String _portletDataHandlerClass;
2596
2597
2600 private String _portletLayoutListenerClass;
2601
2602
2605 private String _popMessageListenerClass;
2606
2607
2610 private String _socialActivityInterpreterClass;
2611
2612
2615 private String _socialRequestInterpreterClass;
2616
2617
2620 private String _defaultPreferences;
2621
2622
2625 private String _prefsValidator;
2626
2627
2630 private boolean _prefsCompanyWide;
2631
2632
2635 private boolean _prefsUniquePerLayout = true;
2636
2637
2641 private boolean _prefsOwnedByGroup = true;
2642
2643
2646 private boolean _useDefaultTemplate = true;
2647
2648
2651 private boolean _showPortletAccessDenied =
2652 PropsValues.LAYOUT_SHOW_PORTLET_ACCESS_DENIED;
2653
2654
2657 private boolean _showPortletInactive =
2658 PropsValues.LAYOUT_SHOW_PORTLET_INACTIVE;
2659
2660
2663 private boolean _actionURLRedirect;
2664
2665
2669 private boolean _restoreCurrentView = true;
2670
2671
2675 private boolean _maximizeEdit;
2676
2677
2681 private boolean _maximizeHelp;
2682
2683
2687 private boolean _popUpPrint = true;
2688
2689
2692 private boolean _layoutCacheable;
2693
2694
2697 private boolean _instanceable;
2698
2699
2702 private String _userPrincipalStrategy =
2703 PortletConstants.USER_PRINCIPAL_STRATEGY_USER_ID;
2704
2705
2709 private boolean _privateRequestAttributes = true;
2710
2711
2714 private boolean _privateSessionAttributes = true;
2715
2716
2719 private int _renderWeight = 1;
2720
2721
2724 private boolean _ajaxable = true;
2725
2726
2730 private List<String> _headerPortalCss;
2731
2732
2736 private List<String> _headerPortletCss;
2737
2738
2742 private List<String> _headerPortalJavaScript;
2743
2744
2748 private List<String> _headerPortletJavaScript;
2749
2750
2754 private List<String> _footerPortalCss;
2755
2756
2760 private List<String> _footerPortletCss;
2761
2762
2766 private List<String> _footerPortalJavaScript;
2767
2768
2772 private List<String> _footerPortletJavaScript;
2773
2774
2778 private String _cssClassWrapper = StringPool.BLANK;
2779
2780
2783 private String _facebookIntegration =
2784 PortletConstants.FACEBOOK_INTEGRATION_IFRAME;
2785
2786
2789 private boolean _addDefaultResource;
2790
2791
2794 private String[] _rolesArray;
2795
2796
2799 private Set<String> _unlinkedRoles;
2800
2801
2804 private Map<String, String> _roleMappers;
2805
2806
2810 private boolean _system;
2811
2812
2815 private boolean _include = true;
2816
2817
2820 private Map<String, String> _initParams;
2821
2822
2825 private Integer _expCache;
2826
2827
2830 private Map<String, Set<String>> _portletModes;
2831
2832
2835 private Set<String> _supportedLocales;
2836
2837
2840 private String _resourceBundle;
2841
2842
2845 private PortletInfo _portletInfo;
2846
2847
2850 private Map<String, PortletFilter> _portletFilters;
2851
2852
2855 private Set<QName> _processingEvents = new HashSet<QName>();
2856
2857
2860 private Map<String, QName> _processingEventsByQName =
2861 new HashMap<String, QName>();
2862
2863
2866 private Set<QName> _publishingEvents = new HashSet<QName>();
2867
2868
2871 private Set<PublicRenderParameter> _publicRenderParameters =
2872 new HashSet<PublicRenderParameter>();
2873
2874
2878 private Map<String, PublicRenderParameter>
2879 _publicRenderParametersByIdentifier =
2880 new HashMap<String, PublicRenderParameter>();
2881
2882
2886 private Map<String, PublicRenderParameter>
2887 _publicRenderParametersByQName =
2888 new HashMap<String, PublicRenderParameter>();
2889
2890
2893 private PortletApp _portletApp;
2894
2895
2898 private Map<String, Portlet> _clonedInstances;
2899
2900
2903 private boolean _staticPortlet;
2904
2905
2909 private boolean _staticPortletStart;
2910
2911}