1
19
20 package com.liferay.portal.model.impl;
21
22 import com.liferay.portal.kernel.job.Scheduler;
23 import com.liferay.portal.kernel.log.Log;
24 import com.liferay.portal.kernel.log.LogFactoryUtil;
25 import com.liferay.portal.kernel.plugin.PluginPackage;
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.PortletBagPool;
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.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.Arrays;
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
82 public class PortletImpl extends PortletModelImpl implements Portlet {
83
84
87 public PortletImpl() {
88 }
89
90
93 public PortletImpl(long companyId, String portletId) {
94 setCompanyId(companyId);
95 setPortletId(portletId);
96 setStrutsPath(portletId);
97 setActive(true);
98 _headerPortalCss = new ArrayList<String>();
99 _headerPortletCss = new ArrayList<String>();
100 _headerPortalJavaScript = new ArrayList<String>();
101 _headerPortletJavaScript = new ArrayList<String>();
102 _footerPortalCss = new ArrayList<String>();
103 _footerPortletCss = new ArrayList<String>();
104 _footerPortalJavaScript = new ArrayList<String>();
105 _footerPortletJavaScript = new ArrayList<String>();
106 _unlinkedRoles = new HashSet<String>();
107 _roleMappers = new LinkedHashMap<String, String>();
108 _initParams = new HashMap<String, String>();
109 _portletModes = new HashMap<String, Set<String>>();
110 _supportedLocales = new HashSet<String>();
111 _portletFilters = new LinkedHashMap<String, PortletFilter>();
112 _processingEvents = new HashSet<QName>();
113 _publishingEvents = new HashSet<QName>();
114 _publicRenderParameters = new HashSet<PublicRenderParameter>();
115 }
116
117
120 public PortletImpl(
121 String portletId, PluginPackage pluginPackage,
122 PluginSetting pluginSetting, long companyId, long timestamp,
123 String icon, String virtualPath, String strutsPath, String portletName,
124 String displayName, String portletClass,
125 String configurationActionClass, String indexerClass,
126 String openSearchClass, String schedulerClass, String portletURLClass,
127 String friendlyURLMapperClass, String urlEncoderClass,
128 String portletDataHandlerClass, String portletLayoutListenerClass,
129 String popMessageListenerClass, String socialActivityInterpreterClass,
130 String socialRequestInterpreterClass, String defaultPreferences,
131 String prefsValidator, boolean prefsCompanyWide,
132 boolean prefsUniquePerLayout, boolean prefsOwnedByGroup,
133 boolean useDefaultTemplate, boolean showPortletAccessDenied,
134 boolean showPortletInactive, boolean actionURLRedirect,
135 boolean restoreCurrentView, boolean maximizeEdit, boolean maximizeHelp,
136 boolean popUpPrint, boolean layoutCacheable, boolean instanceable,
137 String userPrincipalStrategy, boolean privateRequestAttributes,
138 boolean privateSessionAttributes, int renderWeight, boolean ajaxable,
139 List<String> headerPortalCss, List<String> headerPortletCss,
140 List<String> headerPortalJavaScript,
141 List<String> headerPortletJavaScript, List<String> footerPortalCss,
142 List<String> footerPortletCss, List<String> footerPortalJavaScript,
143 List<String> footerPortletJavaScript,
144 String cssClassWrapper, String facebookIntegration,
145 boolean addDefaultResource, String roles, Set<String> unlinkedRoles,
146 Map<String, String> roleMappers, boolean system, boolean active,
147 boolean include, Map<String, String> initParams, Integer expCache,
148 Map<String, Set<String>> portletModes, Set<String> supportedLocales,
149 String resourceBundle, PortletInfo portletInfo,
150 Map<String, PortletFilter> portletFilters, Set<QName> processingEvents,
151 Set<QName> publishingEvents,
152 Set<PublicRenderParameter> publicRenderParameters,
153 PortletApp portletApp) {
154
155 setPortletId(portletId);
156 _pluginPackage = pluginPackage;
157 _defaultPluginSetting = pluginSetting;
158 setCompanyId(companyId);
159 _timestamp = timestamp;
160 _icon = icon;
161 _virtualPath = virtualPath;
162 _strutsPath = strutsPath;
163 _portletName = portletName;
164 _displayName = displayName;
165 _portletClass = portletClass;
166 _configurationActionClass = configurationActionClass;
167 _indexerClass = indexerClass;
168 _openSearchClass = openSearchClass;
169 _schedulerClass = schedulerClass;
170 _portletURLClass = portletURLClass;
171 _friendlyURLMapperClass = friendlyURLMapperClass;
172 _urlEncoderClass = urlEncoderClass;
173 _portletDataHandlerClass = portletDataHandlerClass;
174 _portletLayoutListenerClass = portletLayoutListenerClass;
175 _popMessageListenerClass = popMessageListenerClass;
176 _socialActivityInterpreterClass = socialActivityInterpreterClass;
177 _socialRequestInterpreterClass = socialRequestInterpreterClass;
178 _defaultPreferences = defaultPreferences;
179 _prefsValidator = prefsValidator;
180 _prefsCompanyWide = prefsCompanyWide;
181 _prefsUniquePerLayout = prefsUniquePerLayout;
182 _prefsOwnedByGroup = prefsOwnedByGroup;
183 _useDefaultTemplate = useDefaultTemplate;
184 _showPortletAccessDenied = showPortletAccessDenied;
185 _showPortletInactive = showPortletInactive;
186 _actionURLRedirect = actionURLRedirect;
187 _restoreCurrentView = restoreCurrentView;
188 _maximizeEdit = maximizeEdit;
189 _maximizeHelp = maximizeHelp;
190 _popUpPrint = popUpPrint;
191 _layoutCacheable = layoutCacheable;
192 _instanceable = instanceable;
193 _userPrincipalStrategy = userPrincipalStrategy;
194 _privateRequestAttributes = privateRequestAttributes;
195 _privateSessionAttributes = privateSessionAttributes;
196 _renderWeight = renderWeight;
197 _ajaxable = ajaxable;
198 _headerPortalCss = headerPortalCss;
199 _headerPortletCss = headerPortletCss;
200 _headerPortalJavaScript = headerPortalJavaScript;
201 _headerPortletJavaScript = headerPortletJavaScript;
202 _footerPortalCss = footerPortalCss;
203 _footerPortletCss = footerPortletCss;
204 _footerPortalJavaScript = footerPortalJavaScript;
205 _footerPortletJavaScript = footerPortletJavaScript;
206 _cssClassWrapper = cssClassWrapper;
207 _facebookIntegration = facebookIntegration;
208 _addDefaultResource = addDefaultResource;
209 setRoles(roles);
210 _unlinkedRoles = unlinkedRoles;
211 _roleMappers = roleMappers;
212 _system = system;
213 setActive(active);
214 _include = include;
215 _initParams = initParams;
216 _expCache = expCache;
217 _portletModes = portletModes;
218 _supportedLocales = supportedLocales;
219 _resourceBundle = resourceBundle;
220 _portletInfo = portletInfo;
221 _portletFilters = portletFilters;
222 setProcessingEvents(processingEvents);
223 setPublishingEvents(publishingEvents);
224 setPublicRenderParameters(publicRenderParameters);
225 _portletApp = portletApp;
226
227 if (_instanceable) {
228 _clonedInstances = new Hashtable<String, Portlet>();
229 }
230 }
231
232
237 public String getRootPortletId() {
238 return PortletConstants.getRootPortletId(getPortletId());
239 }
240
241
246 public String getInstanceId() {
247 return PortletConstants.getInstanceId(getPortletId());
248 }
249
250
255 public String getPluginId() {
256 return getRootPortletId();
257 }
258
259
264 public String getPluginType() {
265 return Plugin.TYPE_PORTLET;
266 }
267
268
273 public PluginPackage getPluginPackage() {
274 return _pluginPackage;
275 }
276
277
282 public void setPluginPackage(PluginPackage pluginPackage) {
283 _pluginPackage = pluginPackage;
284 }
285
286
291 public PluginSetting getDefaultPluginSetting() {
292 return _defaultPluginSetting;
293 }
294
295
300 public void setDefaultPluginSetting(PluginSetting pluginSetting) {
301 _defaultPluginSetting = pluginSetting;
302 }
303
304
309 public long getTimestamp() {
310 return _timestamp;
311 }
312
313
318 public void setTimestamp(long timestamp) {
319 _timestamp = timestamp;
320 }
321
322
327 public String getIcon() {
328 return _icon;
329 }
330
331
336 public void setIcon(String icon) {
337 _icon = icon;
338 }
339
340
345 public String getVirtualPath() {
346 return _virtualPath;
347 }
348
349
354 public void setVirtualPath(String virtualPath) {
355 if (_portletApp.isWARFile() && Validator.isNull(virtualPath)) {
356 virtualPath = PropsValues.PORTLET_VIRTUAL_PATH;
357 }
358
359 _virtualPath = virtualPath;
360 }
361
362
367 public String getStrutsPath() {
368 return _strutsPath;
369 }
370
371
376 public void setStrutsPath(String strutsPath) {
377 _strutsPath = strutsPath;
378 }
379
380
385 public String getPortletName() {
386 return _portletName;
387 }
388
389
394 public void setPortletName(String portletName) {
395 _portletName = portletName;
396 }
397
398
403 public String getDisplayName() {
404 return _displayName;
405 }
406
407
412 public void setDisplayName(String displayName) {
413 _displayName = displayName;
414 }
415
416
421 public String getPortletClass() {
422 return _portletClass;
423 }
424
425
430 public void setPortletClass(String portletClass) {
431 _portletClass = portletClass;
432 }
433
434
439 public String getConfigurationActionClass() {
440 return _configurationActionClass;
441 }
442
443
449 public void setConfigurationActionClass(String configurationActionClass) {
450 _configurationActionClass = configurationActionClass;
451 }
452
453
458 public ConfigurationAction getConfigurationActionInstance() {
459 if (Validator.isNotNull(getConfigurationActionClass())) {
460 if (_portletApp.isWARFile()) {
461 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
462
463 return portletBag.getConfigurationActionInstance();
464 }
465 else {
466 return (ConfigurationAction)InstancePool.get(
467 getConfigurationActionClass());
468 }
469 }
470
471 return null;
472 }
473
474
479 public String getIndexerClass() {
480 return _indexerClass;
481 }
482
483
488 public void setIndexerClass(String indexerClass) {
489 _indexerClass = indexerClass;
490 }
491
492
497 public Indexer getIndexerInstance() {
498 if (Validator.isNotNull(getIndexerClass())) {
499 if (_portletApp.isWARFile()) {
500 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
501
502 return portletBag.getIndexerInstance();
503 }
504 else {
505 return (Indexer)InstancePool.get(getIndexerClass());
506 }
507 }
508
509 return null;
510 }
511
512
517 public String getOpenSearchClass() {
518 return _openSearchClass;
519 }
520
521
527 public void setOpenSearchClass(String openSearchClass) {
528 _openSearchClass = openSearchClass;
529 }
530
531
536 public OpenSearch getOpenSearchInstance() {
537 if (Validator.isNull(getOpenSearchClass())) {
538 return null;
539 }
540
541 if (_portletApp.isWARFile()) {
542 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
543
544 return portletBag.getOpenSearchInstance();
545 }
546
547 return (OpenSearch)InstancePool.get(getOpenSearchClass());
548 }
549
550
555 public String getSchedulerClass() {
556 return _schedulerClass;
557 }
558
559
565 public void setSchedulerClass(String schedulerClass) {
566 _schedulerClass = schedulerClass;
567 }
568
569
574 public Scheduler getSchedulerInstance() {
575 if (Validator.isNotNull(getSchedulerClass())) {
576 if (_portletApp.isWARFile()) {
577 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
578
579 return portletBag.getSchedulerInstance();
580 }
581 else {
582 return (Scheduler)InstancePool.get(getSchedulerClass());
583 }
584 }
585
586 return null;
587 }
588
589
594 public String getPortletURLClass() {
595 return _portletURLClass;
596 }
597
598
604 public void setPortletURLClass(String portletURLClass) {
605 _portletURLClass = portletURLClass;
606 }
607
608
613 public String getFriendlyURLMapperClass() {
614 return _friendlyURLMapperClass;
615 }
616
617
623 public void setFriendlyURLMapperClass(String friendlyURLMapperClass) {
624 _friendlyURLMapperClass = friendlyURLMapperClass;
625 }
626
627
632 public FriendlyURLMapper getFriendlyURLMapperInstance() {
633 if (Validator.isNotNull(getFriendlyURLMapperClass())) {
634 if (_portletApp.isWARFile()) {
635 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
636
637 return portletBag.getFriendlyURLMapperInstance();
638 }
639 else {
640 return (FriendlyURLMapper)InstancePool.get(
641 getFriendlyURLMapperClass());
642 }
643 }
644
645 return null;
646 }
647
648
653 public String getURLEncoderClass() {
654 return _urlEncoderClass;
655 }
656
657
663 public void setURLEncoderClass(String urlEncoderClass) {
664 _urlEncoderClass = urlEncoderClass;
665 }
666
667
672 public URLEncoder getURLEncoderInstance() {
673 if (Validator.isNotNull(getURLEncoderClass())) {
674 if (_portletApp.isWARFile()) {
675 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
676
677 return portletBag.getURLEncoderInstance();
678 }
679 else {
680 return (URLEncoder)InstancePool.get(getURLEncoderClass());
681 }
682 }
683
684 return null;
685 }
686
687
692 public String getPortletDataHandlerClass() {
693 return _portletDataHandlerClass;
694 }
695
696
702 public void setPortletDataHandlerClass(String portletDataHandlerClass) {
703 _portletDataHandlerClass = portletDataHandlerClass;
704 }
705
706
711 public PortletDataHandler getPortletDataHandlerInstance() {
712 if (Validator.isNotNull(getPortletDataHandlerClass())) {
713 if (_portletApp.isWARFile()) {
714 PortletBagImpl portletBagImpl =
715 (PortletBagImpl)PortletBagPool.get(getRootPortletId());
716
717 return portletBagImpl.getPortletDataHandlerInstance();
718 }
719 else {
720 return (PortletDataHandler)InstancePool.get(
721 getPortletDataHandlerClass());
722 }
723 }
724
725 return null;
726 }
727
728
733 public PortletLayoutListener getPortletLayoutListener() {
734 if (Validator.isNull(getPortletLayoutListenerClass())) {
735 return null;
736 }
737
738 return (PortletLayoutListener)InstancePool.get(
739 getPortletLayoutListenerClass());
740 }
741
742
747 public String getPortletLayoutListenerClass() {
748 return _portletLayoutListenerClass;
749 }
750
751
757 public void setPortletLayoutListenerClass(
758 String portletLayoutListenerClass) {
759
760 _portletLayoutListenerClass = portletLayoutListenerClass;
761 }
762
763
768 public String getPopMessageListenerClass() {
769 return _popMessageListenerClass;
770 }
771
772
778 public void setPopMessageListenerClass(String popMessageListenerClass) {
779 _popMessageListenerClass = popMessageListenerClass;
780 }
781
782
787 public MessageListener getPopMessageListenerInstance() {
788 if (Validator.isNotNull(getPopMessageListenerClass())) {
789 if (_portletApp.isWARFile()) {
790 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
791
792 return portletBag.getPopMessageListenerInstance();
793 }
794 else {
795 return (MessageListener)InstancePool.get(
796 getPopMessageListenerClass());
797 }
798 }
799
800 return null;
801 }
802
803
809 public String getSocialActivityInterpreterClass() {
810 return _socialActivityInterpreterClass;
811 }
812
813
819 public void setSocialActivityInterpreterClass(
820 String socialActivityInterpreterClass) {
821
822 _socialActivityInterpreterClass = socialActivityInterpreterClass;
823 }
824
825
831 public SocialActivityInterpreter getSocialActivityInterpreterInstance() {
832 if (Validator.isNotNull(getSocialActivityInterpreterClass())) {
833 if (_portletApp.isWARFile()) {
834 PortletBagImpl portletBagImpl =
835 (PortletBagImpl)PortletBagPool.get(getRootPortletId());
836
837 return portletBagImpl.getSocialActivityInterpreterInstance();
838 }
839 else {
840 return (SocialActivityInterpreter)InstancePool.get(
841 getSocialActivityInterpreterClass());
842 }
843 }
844
845 return null;
846 }
847
848
854 public String getSocialRequestInterpreterClass() {
855 return _socialRequestInterpreterClass;
856 }
857
858
864 public void setSocialRequestInterpreterClass(
865 String socialRequestInterpreterClass) {
866
867 _socialRequestInterpreterClass = socialRequestInterpreterClass;
868 }
869
870
876 public SocialRequestInterpreter getSocialRequestInterpreterInstance() {
877 if (Validator.isNotNull(getSocialRequestInterpreterClass())) {
878 if (_portletApp.isWARFile()) {
879 PortletBagImpl portletBag =
880 (PortletBagImpl)PortletBagPool.get(getRootPortletId());
881
882 return portletBag.getSocialRequestInterpreterInstance();
883 }
884 else {
885 return (SocialRequestInterpreter)InstancePool.get(
886 getSocialRequestInterpreterClass());
887 }
888 }
889
890 return null;
891 }
892
893
898 public String getDefaultPreferences() {
899 if (Validator.isNull(_defaultPreferences)) {
900 return PortletConstants.DEFAULT_PREFERENCES;
901 }
902 else {
903 return _defaultPreferences;
904 }
905 }
906
907
912 public void setDefaultPreferences(String defaultPreferences) {
913 _defaultPreferences = defaultPreferences;
914 }
915
916
921 public String getPreferencesValidator() {
922 return _prefsValidator;
923 }
924
925
931 public void setPreferencesValidator(String prefsValidator) {
932 if (prefsValidator != null) {
933
934
937 _prefsValidator = prefsValidator.trim();
938 }
939 else {
940 _prefsValidator = null;
941 }
942 }
943
944
949 public boolean getPreferencesCompanyWide() {
950 return _prefsCompanyWide;
951 }
952
953
958 public boolean isPreferencesCompanyWide() {
959 return _prefsCompanyWide;
960 }
961
962
968 public void setPreferencesCompanyWide(boolean prefsCompanyWide) {
969 _prefsCompanyWide = prefsCompanyWide;
970 }
971
972
977 public boolean getPreferencesUniquePerLayout() {
978 return _prefsUniquePerLayout;
979 }
980
981
986 public boolean isPreferencesUniquePerLayout() {
987 return _prefsUniquePerLayout;
988 }
989
990
996 public void setPreferencesUniquePerLayout(boolean prefsUniquePerLayout) {
997 _prefsUniquePerLayout = prefsUniquePerLayout;
998 }
999
1000
1009 public boolean getPreferencesOwnedByGroup() {
1010 return _prefsOwnedByGroup;
1011 }
1012
1013
1022 public boolean isPreferencesOwnedByGroup() {
1023 return _prefsOwnedByGroup;
1024 }
1025
1026
1035 public void setPreferencesOwnedByGroup(boolean prefsOwnedByGroup) {
1036 _prefsOwnedByGroup = prefsOwnedByGroup;
1037 }
1038
1039
1044 public boolean getUseDefaultTemplate() {
1045 return _useDefaultTemplate;
1046 }
1047
1048
1053 public boolean isUseDefaultTemplate() {
1054 return _useDefaultTemplate;
1055 }
1056
1057
1063 public void setUseDefaultTemplate(boolean useDefaultTemplate) {
1064 _useDefaultTemplate = useDefaultTemplate;
1065 }
1066
1067
1074 public boolean getShowPortletAccessDenied() {
1075 return _showPortletAccessDenied;
1076 }
1077
1078
1085 public boolean isShowPortletAccessDenied() {
1086 return _showPortletAccessDenied;
1087 }
1088
1089
1096 public void setShowPortletAccessDenied(boolean showPortletAccessDenied) {
1097 _showPortletAccessDenied = showPortletAccessDenied;
1098 }
1099
1100
1105 public boolean getShowPortletInactive() {
1106 return _showPortletInactive;
1107 }
1108
1109
1114 public boolean isShowPortletInactive() {
1115 return _showPortletInactive;
1116 }
1117
1118
1124 public void setShowPortletInactive(boolean showPortletInactive) {
1125 _showPortletInactive = showPortletInactive;
1126 }
1127
1128
1135 public boolean getActionURLRedirect() {
1136 return _actionURLRedirect;
1137 }
1138
1139
1146 public boolean isActionURLRedirect() {
1147 return _actionURLRedirect;
1148 }
1149
1150
1157 public void setActionURLRedirect(boolean actionURLRedirect) {
1158 _actionURLRedirect = actionURLRedirect;
1159 }
1160
1161
1168 public boolean getRestoreCurrentView() {
1169 return _restoreCurrentView;
1170 }
1171
1172
1179 public boolean isRestoreCurrentView() {
1180 return _restoreCurrentView;
1181 }
1182
1183
1190 public void setRestoreCurrentView(boolean restoreCurrentView) {
1191 _restoreCurrentView = restoreCurrentView;
1192 }
1193
1194
1201 public boolean getMaximizeEdit() {
1202 return _maximizeEdit;
1203 }
1204
1205
1212 public boolean isMaximizeEdit() {
1213 return _maximizeEdit;
1214 }
1215
1216
1223 public void setMaximizeEdit(boolean maximizeEdit) {
1224 _maximizeEdit = maximizeEdit;
1225 }
1226
1227
1234 public boolean getMaximizeHelp() {
1235 return _maximizeHelp;
1236 }
1237
1238
1245 public boolean isMaximizeHelp() {
1246 return _maximizeHelp;
1247 }
1248
1249
1256 public void setMaximizeHelp(boolean maximizeHelp) {
1257 _maximizeHelp = maximizeHelp;
1258 }
1259
1260
1267 public boolean getPopUpPrint() {
1268 return _popUpPrint;
1269 }
1270
1271
1278 public boolean isPopUpPrint() {
1279 return _popUpPrint;
1280 }
1281
1282
1289 public void setPopUpPrint(boolean popUpPrint) {
1290 _popUpPrint = popUpPrint;
1291 }
1292
1293
1298 public boolean getLayoutCacheable() {
1299 return _layoutCacheable;
1300 }
1301
1302
1307 public boolean isLayoutCacheable() {
1308 return _layoutCacheable;
1309 }
1310
1311
1317 public void setLayoutCacheable(boolean layoutCacheable) {
1318 _layoutCacheable = layoutCacheable;
1319 }
1320
1321
1326 public boolean getInstanceable() {
1327 return _instanceable;
1328 }
1329
1330
1335 public boolean isInstanceable() {
1336 return _instanceable;
1337 }
1338
1339
1345 public void setInstanceable(boolean instanceable) {
1346 _instanceable = instanceable;
1347 }
1348
1349
1354 public String getUserPrincipalStrategy() {
1355 return _userPrincipalStrategy;
1356 }
1357
1358
1364 public void setUserPrincipalStrategy(String userPrincipalStrategy) {
1365 if (Validator.isNotNull(userPrincipalStrategy)) {
1366 _userPrincipalStrategy = userPrincipalStrategy;
1367 }
1368 }
1369
1370
1377 public boolean getPrivateRequestAttributes() {
1378 return _privateRequestAttributes;
1379 }
1380
1381
1388 public boolean isPrivateRequestAttributes() {
1389 return _privateRequestAttributes;
1390 }
1391
1392
1400 public void setPrivateRequestAttributes(boolean privateRequestAttributes) {
1401 _privateRequestAttributes = privateRequestAttributes;
1402 }
1403
1404
1411 public boolean getPrivateSessionAttributes() {
1412 return _privateSessionAttributes;
1413 }
1414
1415
1422 public boolean isPrivateSessionAttributes() {
1423 return _privateSessionAttributes;
1424 }
1425
1426
1433 public void setPrivateSessionAttributes(boolean privateSessionAttributes) {
1434 _privateSessionAttributes = privateSessionAttributes;
1435 }
1436
1437
1442 public int getRenderWeight() {
1443 return _renderWeight;
1444 }
1445
1446
1451 public void setRenderWeight(int renderWeight) {
1452 _renderWeight = renderWeight;
1453 }
1454
1455
1460 public boolean getAjaxable() {
1461 return _ajaxable;
1462 }
1463
1464
1469 public boolean isAjaxable() {
1470 return _ajaxable;
1471 }
1472
1473
1479 public void setAjaxable(boolean ajaxable) {
1480 _ajaxable = ajaxable;
1481 }
1482
1483
1490 public List<String> getHeaderPortalCss() {
1491 return _headerPortalCss;
1492 }
1493
1494
1501 public void setHeaderPortalCss(List<String> headerPortalCss) {
1502 _headerPortalCss = headerPortalCss;
1503 }
1504
1505
1512 public List<String> getHeaderPortletCss() {
1513 return _headerPortletCss;
1514 }
1515
1516
1524 public void setHeaderPortletCss(List<String> headerPortletCss) {
1525 _headerPortletCss = headerPortletCss;
1526 }
1527
1528
1535 public List<String> getHeaderPortalJavaScript() {
1536 return _headerPortalJavaScript;
1537 }
1538
1539
1547 public void setHeaderPortalJavaScript(List<String> headerPortalJavaScript) {
1548 _headerPortalJavaScript = headerPortalJavaScript;
1549 }
1550
1551
1558 public List<String> getHeaderPortletJavaScript() {
1559 return _headerPortletJavaScript;
1560 }
1561
1562
1570 public void setHeaderPortletJavaScript(
1571 List<String> headerPortletJavaScript) {
1572
1573 _headerPortletJavaScript = headerPortletJavaScript;
1574 }
1575
1576
1583 public List<String> getFooterPortalCss() {
1584 return _footerPortalCss;
1585 }
1586
1587
1594 public void setFooterPortalCss(List<String> footerPortalCss) {
1595 _footerPortalCss = footerPortalCss;
1596 }
1597
1598
1605 public List<String> getFooterPortletCss() {
1606 return _footerPortletCss;
1607 }
1608
1609
1617 public void setFooterPortletCss(List<String> footerPortletCss) {
1618 _footerPortletCss = footerPortletCss;
1619 }
1620
1621
1628 public List<String> getFooterPortalJavaScript() {
1629 return _footerPortalJavaScript;
1630 }
1631
1632
1640 public void setFooterPortalJavaScript(List<String> footerPortalJavaScript) {
1641 _footerPortalJavaScript = footerPortalJavaScript;
1642 }
1643
1644
1651 public List<String> getFooterPortletJavaScript() {
1652 return _footerPortletJavaScript;
1653 }
1654
1655
1663 public void setFooterPortletJavaScript(
1664 List<String> footerPortletJavaScript) {
1665
1666 _footerPortletJavaScript = footerPortletJavaScript;
1667 }
1668
1669
1676 public String getCssClassWrapper() {
1677 return _cssClassWrapper;
1678 }
1679
1680
1687 public void setCssClassWrapper(String cssClassWrapper) {
1688 _cssClassWrapper = cssClassWrapper;
1689 }
1690
1691
1696 public String getFacebookIntegration() {
1697 return _facebookIntegration;
1698 }
1699
1700
1706 public void setFacebookIntegration(String facebookIntegration) {
1707 if (Validator.isNotNull(facebookIntegration)) {
1708 _facebookIntegration = facebookIntegration;
1709 }
1710 }
1711
1712
1718 public boolean getAddDefaultResource() {
1719 return _addDefaultResource;
1720 }
1721
1722
1728 public boolean isAddDefaultResource() {
1729 return _addDefaultResource;
1730 }
1731
1732
1738 public void setAddDefaultResource(boolean addDefaultResource) {
1739 _addDefaultResource = addDefaultResource;
1740 }
1741
1742
1747 public void setRoles(String roles) {
1748 _rolesArray = StringUtil.split(roles);
1749
1750 super.setRoles(roles);
1751 }
1752
1753
1758 public String[] getRolesArray() {
1759 return _rolesArray;
1760 }
1761
1762
1767 public void setRolesArray(String[] rolesArray) {
1768 _rolesArray = rolesArray;
1769
1770 super.setRoles(StringUtil.merge(rolesArray));
1771 }
1772
1773
1778 public Set<String> getUnlinkedRoles() {
1779 return _unlinkedRoles;
1780 }
1781
1782
1787 public void setUnlinkedRoles(Set<String> unlinkedRoles) {
1788 _unlinkedRoles = unlinkedRoles;
1789 }
1790
1791
1796 public Map<String, String> getRoleMappers() {
1797 return _roleMappers;
1798 }
1799
1800
1805 public void setRoleMappers(Map<String, String> roleMappers) {
1806 _roleMappers = roleMappers;
1807 }
1808
1809
1813 public void linkRoles() {
1814 List<String> linkedRoles = new ArrayList<String>();
1815
1816 Iterator<String> itr = _unlinkedRoles.iterator();
1817
1818 while (itr.hasNext()) {
1819 String unlinkedRole = itr.next();
1820
1821 String roleLink = _roleMappers.get(unlinkedRole);
1822
1823 if (Validator.isNotNull(roleLink)) {
1824 if (_log.isDebugEnabled()) {
1825 _log.debug(
1826 "Linking role for portlet [" + getPortletId() +
1827 "] with role-name [" + unlinkedRole +
1828 "] to role-link [" + roleLink + "]");
1829 }
1830
1831 linkedRoles.add(roleLink);
1832 }
1833 else {
1834 _log.error(
1835 "Unable to link role for portlet [" + getPortletId() +
1836 "] with role-name [" + unlinkedRole +
1837 "] because role-link is null");
1838 }
1839 }
1840
1841 String[] array = linkedRoles.toArray(new String[linkedRoles.size()]);
1842
1843 Arrays.sort(array);
1844
1845 setRolesArray(array);
1846 }
1847
1848
1853 public boolean hasRoleWithName(String roleName) {
1854 if ((_rolesArray == null) || (_rolesArray.length == 0)) {
1855 return false;
1856 }
1857
1858 for (int i = 0; i < _rolesArray.length; i++) {
1859 if (_rolesArray[i].equalsIgnoreCase(roleName)) {
1860 return true;
1861 }
1862 }
1863
1864 return false;
1865 }
1866
1867
1874 public boolean hasAddPortletPermission(long userId) {
1875 try {
1876 if ((_rolesArray == null) || (_rolesArray.length == 0)) {
1877 return true;
1878 }
1879 else if (RoleLocalServiceUtil.hasUserRoles(
1880 userId, getCompanyId(), _rolesArray, true)) {
1881
1882 return true;
1883 }
1884 else if (RoleLocalServiceUtil.hasUserRole(
1885 userId, getCompanyId(), RoleConstants.ADMINISTRATOR,
1886 true)) {
1887
1888 return true;
1889 }
1890 else {
1891 User user = UserLocalServiceUtil.getUserById(userId);
1892
1893 if (user.isDefaultUser() &&
1894 hasRoleWithName(RoleConstants.GUEST)) {
1895
1896 return true;
1897 }
1898 }
1899 }
1900 catch (Exception e) {
1901 _log.error(e);
1902 }
1903
1904 return false;
1905 }
1906
1907
1914 public boolean getSystem() {
1915 return _system;
1916 }
1917
1918
1925 public boolean isSystem() {
1926 return _system;
1927 }
1928
1929
1936 public void setSystem(boolean system) {
1937 _system = system;
1938 }
1939
1940
1947 public boolean getInclude() {
1948 return _include;
1949 }
1950
1951
1958 public boolean isInclude() {
1959 return _include;
1960 }
1961
1962
1969 public void setInclude(boolean include) {
1970 _include = include;
1971 }
1972
1973
1978 public Map<String, String> getInitParams() {
1979 return _initParams;
1980 }
1981
1982
1987 public void setInitParams(Map<String, String> initParams) {
1988 _initParams = initParams;
1989 }
1990
1991
1996 public Integer getExpCache() {
1997 return _expCache;
1998 }
1999
2000
2005 public void setExpCache(Integer expCache) {
2006 _expCache = expCache;
2007 }
2008
2009
2014 public Map<String, Set<String>> getPortletModes() {
2015 return _portletModes;
2016 }
2017
2018
2023 public void setPortletModes(Map<String, Set<String>> portletModes) {
2024 _portletModes = portletModes;
2025 }
2026
2027
2034 public boolean hasPortletMode(String mimeType, PortletMode portletMode) {
2035 if (mimeType == null) {
2036 mimeType = ContentTypes.TEXT_HTML;
2037 }
2038
2039 Set<String> mimeTypeModes = _portletModes.get(mimeType);
2040
2041 if (mimeTypeModes == null) {
2042 return false;
2043 }
2044
2045 if (mimeTypeModes.contains(portletMode.toString())) {
2046 return true;
2047 }
2048 else {
2049 return false;
2050 }
2051 }
2052
2053
2058 public Set<String> getAllPortletModes() {
2059 Set<String> allPortletModes = new TreeSet<String>();
2060
2061 Iterator<Map.Entry <String, Set<String>>> itr1 =
2062 _portletModes.entrySet().iterator();
2063
2064 while (itr1.hasNext()) {
2065 Map.Entry<String, Set<String>> entry = itr1.next();
2066
2067 Set<String> mimeTypeModes = entry.getValue();
2068
2069 Iterator<String> itr2 = mimeTypeModes.iterator();
2070
2071 while (itr2.hasNext()) {
2072 String portletMode = itr2.next();
2073
2074 allPortletModes.add(portletMode);
2075 }
2076 }
2077
2078 return allPortletModes;
2079 }
2080
2081
2086 public boolean hasMultipleMimeTypes() {
2087 if (_portletModes.size() > 1) {
2088 return true;
2089 }
2090 else {
2091 return false;
2092 }
2093 }
2094
2095
2100 public Set<String> getSupportedLocales() {
2101 return _supportedLocales;
2102 }
2103
2104
2109 public void setSupportedLocales(Set<String> supportedLocales) {
2110 _supportedLocales = supportedLocales;
2111 }
2112
2113
2118 public String getResourceBundle() {
2119 return _resourceBundle;
2120 }
2121
2122
2127 public void setResourceBundle(String resourceBundle) {
2128 _resourceBundle = resourceBundle;
2129 }
2130
2131
2136 public PortletInfo getPortletInfo() {
2137 return _portletInfo;
2138 }
2139
2140
2145 public void setPortletInfo(PortletInfo portletInfo) {
2146 _portletInfo = portletInfo;
2147 }
2148
2149
2154 public Map<String, PortletFilter> getPortletFilters() {
2155 return _portletFilters;
2156 }
2157
2158
2163 public void setPortletFilters(Map<String, PortletFilter> portletFilters) {
2164 _portletFilters = portletFilters;
2165 }
2166
2167
2172 public void addProcessingEvent(QName processingEvent) {
2173 _processingEvents.add(processingEvent);
2174 _processingEventsByQName.put(
2175 QNameUtil.getKey(processingEvent), processingEvent);
2176 }
2177
2178
2185 public QName getProcessingEvent(String uri, String localPart) {
2186 return _processingEventsByQName.get(
2187 QNameUtil.getKey(uri, localPart));
2188 }
2189
2190
2195 public Set<QName> getProcessingEvents() {
2196 return _processingEvents;
2197 }
2198
2199
2205 public void setProcessingEvents(Set<QName> processingEvents) {
2206 for (QName processingEvent : processingEvents) {
2207 addProcessingEvent(processingEvent);
2208 }
2209 }
2210
2211
2216 public void addPublishingEvent(QName publishingEvent) {
2217 _publishingEvents.add(publishingEvent);
2218 }
2219
2220
2225 public Set<QName> getPublishingEvents() {
2226 return _publishingEvents;
2227 }
2228
2229
2235 public void setPublishingEvents(Set<QName> publishingEvents) {
2236 for (QName publishingEvent : publishingEvents) {
2237 addPublishingEvent(publishingEvent);
2238 }
2239 }
2240
2241
2246 public void addPublicRenderParameter(
2247 PublicRenderParameter publicRenderParameter) {
2248
2249 _publicRenderParameters.add(publicRenderParameter);
2250 _publicRenderParametersByIdentifier.put(
2251 publicRenderParameter.getIdentifier(), publicRenderParameter);
2252 _publicRenderParametersByQName.put(
2253 QNameUtil.getKey(publicRenderParameter.getQName()),
2254 publicRenderParameter);
2255 }
2256
2257
2262 public PublicRenderParameter getPublicRenderParameter(String identifier) {
2263 return _publicRenderParametersByIdentifier.get(identifier);
2264 }
2265
2266
2273 public PublicRenderParameter getPublicRenderParameter(
2274 String uri, String localPart) {
2275
2276 return _publicRenderParametersByQName.get(
2277 QNameUtil.getKey(uri, localPart));
2278 }
2279
2280
2285 public Set<PublicRenderParameter> getPublicRenderParameters() {
2286 return _publicRenderParameters;
2287 }
2288
2289
2295 public void setPublicRenderParameters(
2296 Set<PublicRenderParameter> publicRenderParameters) {
2297
2298 for (PublicRenderParameter publicRenderParameter :
2299 publicRenderParameters) {
2300
2301 addPublicRenderParameter(publicRenderParameter);
2302 }
2303 }
2304
2305
2310 public String getContextPath() {
2311 String virtualPath = getVirtualPath();
2312
2313 if (Validator.isNotNull(virtualPath)) {
2314 return virtualPath;
2315 }
2316
2317 if (_portletApp.isWARFile()) {
2318 StringBuilder sb = new StringBuilder();
2319
2320 sb.append(StringPool.SLASH);
2321 sb.append(_portletApp.getServletContextName());
2322
2323 return sb.toString();
2324 }
2325 else {
2326 return PortalUtil.getPathContext();
2327 }
2328 }
2329
2330
2335 public PortletApp getPortletApp() {
2336 return _portletApp;
2337 }
2338
2339
2344 public void setPortletApp(PortletApp portletApp) {
2345 _portletApp = portletApp;
2346 }
2347
2348
2354 public Portlet getClonedInstance(String portletId) {
2355 if (_clonedInstances == null) {
2356
2357
2359 return null;
2360 }
2361
2362 Portlet clonedInstance = _clonedInstances.get(portletId);
2363
2364 if (clonedInstance == null) {
2365 clonedInstance = (Portlet)clone();
2366
2367 clonedInstance.setPortletId(portletId);
2368
2369
2376 }
2378
2379 return clonedInstance;
2380 }
2381
2382
2388 public boolean getStatic() {
2389 return _staticPortlet;
2390 }
2391
2392
2398 public boolean isStatic() {
2399 return _staticPortlet;
2400 }
2401
2402
2408 public void setStatic(boolean staticPortlet) {
2409 _staticPortlet = staticPortlet;
2410 }
2411
2412
2419 public boolean getStaticStart() {
2420 return _staticPortletStart;
2421 }
2422
2423
2430 public boolean isStaticStart() {
2431 return _staticPortletStart;
2432 }
2433
2434
2441 public void setStaticStart(boolean staticPortletStart) {
2442 _staticPortletStart = staticPortletStart;
2443 }
2444
2445
2452 public boolean getStaticEnd() {
2453 return !_staticPortletStart;
2454 }
2455
2456
2463 public boolean isStaticEnd() {
2464 return !_staticPortletStart;
2465 }
2466
2467
2472 public Object clone() {
2473 return new PortletImpl(
2474 getPortletId(), getPluginPackage(), getDefaultPluginSetting(),
2475 getCompanyId(), getTimestamp(), getIcon(), getVirtualPath(),
2476 getStrutsPath(), getPortletName(), getDisplayName(),
2477 getPortletClass(), getConfigurationActionClass(), getIndexerClass(),
2478 getOpenSearchClass(), getSchedulerClass(), getPortletURLClass(),
2479 getFriendlyURLMapperClass(), getURLEncoderClass(),
2480 getPortletDataHandlerClass(), getPortletLayoutListenerClass(),
2481 getPopMessageListenerClass(), getSocialActivityInterpreterClass(),
2482 getSocialRequestInterpreterClass(), getDefaultPreferences(),
2483 getPreferencesValidator(), isPreferencesCompanyWide(),
2484 isPreferencesUniquePerLayout(), isPreferencesOwnedByGroup(),
2485 isUseDefaultTemplate(), isShowPortletAccessDenied(),
2486 isShowPortletInactive(), isActionURLRedirect(),
2487 isRestoreCurrentView(), isMaximizeEdit(), isMaximizeHelp(),
2488 isPopUpPrint(), isLayoutCacheable(), isInstanceable(),
2489 getUserPrincipalStrategy(), isPrivateRequestAttributes(),
2490 isPrivateSessionAttributes(), getRenderWeight(), isAjaxable(),
2491 getHeaderPortalCss(), getHeaderPortletCss(),
2492 getHeaderPortalJavaScript(), getHeaderPortletJavaScript(),
2493 getFooterPortalCss(), getFooterPortletCss(),
2494 getFooterPortalJavaScript(), getFooterPortletJavaScript(),
2495 getCssClassWrapper(), getFacebookIntegration(),
2496 isAddDefaultResource(), getRoles(), getUnlinkedRoles(),
2497 getRoleMappers(), isSystem(), isActive(), isInclude(),
2498 getInitParams(), getExpCache(), getPortletModes(),
2499 getSupportedLocales(), getResourceBundle(), getPortletInfo(),
2500 getPortletFilters(), getProcessingEvents(), getPublishingEvents(),
2501 getPublicRenderParameters(), getPortletApp());
2502 }
2503
2504
2513 public int compareTo(Object obj) {
2514 Portlet portlet = (Portlet)obj;
2515
2516 return getPortletId().compareTo(portlet.getPortletId());
2517 }
2518
2519
2525 public boolean equals(Object obj) {
2526 Portlet portlet = (Portlet)obj;
2527
2528 return getPortletId().equals(portlet.getPortletId());
2529 }
2530
2531
2534 private static Log _log = LogFactoryUtil.getLog(PortletImpl.class);
2535
2536
2539 private PluginPackage _pluginPackage;
2540
2541
2544 private PluginSetting _defaultPluginSetting;
2545
2546
2549 private long _timestamp;
2550
2551
2554 private String _icon;
2555
2556
2559 private String _virtualPath;
2560
2561
2564 private String _strutsPath;
2565
2566
2569 private String _portletName;
2570
2571
2574 private String _displayName;
2575
2576
2579 private String _portletClass;
2580
2581
2584 private String _configurationActionClass;
2585
2586
2589 private String _indexerClass;
2590
2591
2594 private String _openSearchClass;
2595
2596
2599 private String _schedulerClass;
2600
2601
2604 private String _portletURLClass;
2605
2606
2609 private String _friendlyURLMapperClass;
2610
2611
2614 private String _urlEncoderClass;
2615
2616
2619 private String _portletDataHandlerClass;
2620
2621
2624 private String _portletLayoutListenerClass;
2625
2626
2629 private String _popMessageListenerClass;
2630
2631
2634 private String _socialActivityInterpreterClass;
2635
2636
2639 private String _socialRequestInterpreterClass;
2640
2641
2644 private String _defaultPreferences;
2645
2646
2649 private String _prefsValidator;
2650
2651
2654 private boolean _prefsCompanyWide;
2655
2656
2659 private boolean _prefsUniquePerLayout = true;
2660
2661
2665 private boolean _prefsOwnedByGroup = true;
2666
2667
2670 private boolean _useDefaultTemplate = true;
2671
2672
2675 private boolean _showPortletAccessDenied =
2676 PropsValues.LAYOUT_SHOW_PORTLET_ACCESS_DENIED;
2677
2678
2681 private boolean _showPortletInactive =
2682 PropsValues.LAYOUT_SHOW_PORTLET_INACTIVE;
2683
2684
2687 private boolean _actionURLRedirect;
2688
2689
2693 private boolean _restoreCurrentView = true;
2694
2695
2699 private boolean _maximizeEdit;
2700
2701
2705 private boolean _maximizeHelp;
2706
2707
2711 private boolean _popUpPrint = true;
2712
2713
2716 private boolean _layoutCacheable;
2717
2718
2721 private boolean _instanceable;
2722
2723
2726 private String _userPrincipalStrategy =
2727 PortletConstants.USER_PRINCIPAL_STRATEGY_USER_ID;
2728
2729
2733 private boolean _privateRequestAttributes = true;
2734
2735
2738 private boolean _privateSessionAttributes = true;
2739
2740
2743 private int _renderWeight = 1;
2744
2745
2748 private boolean _ajaxable = true;
2749
2750
2754 private List<String> _headerPortalCss;
2755
2756
2760 private List<String> _headerPortletCss;
2761
2762
2766 private List<String> _headerPortalJavaScript;
2767
2768
2772 private List<String> _headerPortletJavaScript;
2773
2774
2778 private List<String> _footerPortalCss;
2779
2780
2784 private List<String> _footerPortletCss;
2785
2786
2790 private List<String> _footerPortalJavaScript;
2791
2792
2796 private List<String> _footerPortletJavaScript;
2797
2798
2802 private String _cssClassWrapper = StringPool.BLANK;
2803
2804
2807 private String _facebookIntegration =
2808 PortletConstants.FACEBOOK_INTEGRATION_IFRAME;
2809
2810
2813 private boolean _addDefaultResource;
2814
2815
2818 private String[] _rolesArray;
2819
2820
2823 private Set<String> _unlinkedRoles;
2824
2825
2828 private Map<String, String> _roleMappers;
2829
2830
2834 private boolean _system;
2835
2836
2839 private boolean _include = true;
2840
2841
2844 private Map<String, String> _initParams;
2845
2846
2849 private Integer _expCache;
2850
2851
2854 private Map<String, Set<String>> _portletModes;
2855
2856
2859 private Set<String> _supportedLocales;
2860
2861
2864 private String _resourceBundle;
2865
2866
2869 private PortletInfo _portletInfo;
2870
2871
2874 private Map<String, PortletFilter> _portletFilters;
2875
2876
2879 private Set<QName> _processingEvents = new HashSet<QName>();
2880
2881
2884 private Map<String, QName> _processingEventsByQName =
2885 new HashMap<String, QName>();
2886
2887
2890 private Set<QName> _publishingEvents = new HashSet<QName>();
2891
2892
2895 private Set<PublicRenderParameter> _publicRenderParameters =
2896 new HashSet<PublicRenderParameter>();
2897
2898
2902 private Map<String, PublicRenderParameter>
2903 _publicRenderParametersByIdentifier =
2904 new HashMap<String, PublicRenderParameter>();
2905
2906
2910 private Map<String, PublicRenderParameter>
2911 _publicRenderParametersByQName =
2912 new HashMap<String, PublicRenderParameter>();
2913
2914
2917 private PortletApp _portletApp;
2918
2919
2922 private Map<String, Portlet> _clonedInstances;
2923
2924
2927 private boolean _staticPortlet;
2928
2929
2933 private boolean _staticPortletStart;
2934
2935}