1
19
20 package com.liferay.portal.security.permission;
21
22 import com.liferay.portal.SystemException;
23 import com.liferay.portal.kernel.language.LanguageUtil;
24 import com.liferay.portal.kernel.log.Log;
25 import com.liferay.portal.kernel.log.LogFactoryUtil;
26 import com.liferay.portal.kernel.util.ListUtil;
27 import com.liferay.portal.kernel.util.StringPool;
28 import com.liferay.portal.kernel.util.StringUtil;
29 import com.liferay.portal.kernel.util.Validator;
30 import com.liferay.portal.kernel.xml.Document;
31 import com.liferay.portal.kernel.xml.Element;
32 import com.liferay.portal.kernel.xml.SAXReaderUtil;
33 import com.liferay.portal.model.Group;
34 import com.liferay.portal.model.Organization;
35 import com.liferay.portal.model.PasswordPolicy;
36 import com.liferay.portal.model.Permission;
37 import com.liferay.portal.model.Portlet;
38 import com.liferay.portal.model.PortletConstants;
39 import com.liferay.portal.model.Role;
40 import com.liferay.portal.model.RoleConstants;
41 import com.liferay.portal.model.User;
42 import com.liferay.portal.model.UserGroup;
43 import com.liferay.portal.service.PortletLocalServiceUtil;
44 import com.liferay.portal.service.RoleLocalServiceUtil;
45 import com.liferay.portal.util.PortalUtil;
46 import com.liferay.portal.util.PortletKeys;
47 import com.liferay.portal.util.PropsKeys;
48 import com.liferay.portal.util.PropsUtil;
49 import com.liferay.portlet.PortletResourceBundles;
50 import com.liferay.portlet.expando.model.ExpandoColumn;
51 import com.liferay.util.UniqueList;
52
53 import java.util.ArrayList;
54 import java.util.Collections;
55 import java.util.HashMap;
56 import java.util.HashSet;
57 import java.util.Iterator;
58 import java.util.List;
59 import java.util.Locale;
60 import java.util.Map;
61 import java.util.Set;
62
63 import javax.servlet.jsp.PageContext;
64
65
71 public class ResourceActionsUtil {
72
73 public static final String ACTION_NAME_PREFIX = "action.";
74
75 public static final String MODEL_RESOURCE_NAME_PREFIX = "model.resource.";
76
77 public static final String[] ORGANIZATION_MODEL_RESOURCES = {
78 Organization.class.getName(), PasswordPolicy.class.getName(),
79 User.class.getName()
80 };
81
82 public static final String[] PORTAL_MODEL_RESOURCES = {
83 ExpandoColumn.class.getName(), Organization.class.getName(),
84 PasswordPolicy.class.getName(), Role.class.getName(),
85 User.class.getName(), UserGroup.class.getName()
86 };
87
88 public static String getAction(
89 long companyId, Locale locale, String action) {
90
91 String key = ACTION_NAME_PREFIX + action;
92
93 String value = LanguageUtil.get(companyId, locale, key, null);
94
95 if ((value == null) || (value.equals(key))) {
96 value = PortletResourceBundles.getString(locale, key);
97 }
98
99 if (value == null) {
100 value = key;
101 }
102
103 return value;
104 }
105
106 public static String getAction(PageContext pageContext, String action) {
107 String key = ACTION_NAME_PREFIX + action;
108
109 String value = LanguageUtil.get(pageContext, key, null);
110
111 if ((value == null) || (value.equals(key))) {
112 value = PortletResourceBundles.getString(pageContext, key);
113 }
114
115 if (value == null) {
116 value = key;
117 }
118
119 return value;
120 }
121
122 public static List<String> getActions(List<Permission> permissions) {
123 List<String> actions = new UniqueList<String>();
124
125 for (Permission permission : permissions) {
126 actions.add(permission.getActionId());
127 }
128
129 return actions;
130 }
131
132 public static List<String> getActionsNames(
133 PageContext pageContext, List<String> actions) {
134
135 List<String> uniqueList = new UniqueList<String>();
136
137 for (String action : actions) {
138 uniqueList.add(getAction(pageContext, action));
139 }
140
141 List<String> list = new ArrayList<String>();
142
143 list.addAll(uniqueList);
144
145 return list;
146 }
147
148 public static List<String> getModelNames() {
149 return _instance._getModelNames();
150 }
151
152 public static List<String> getModelPortletResources(String name) {
153 return _instance._getModelPortletResources(name);
154 }
155
156 public static String getModelResource(
157 long companyId, Locale locale, String name) {
158
159 String key = MODEL_RESOURCE_NAME_PREFIX + name;
160
161 String value = LanguageUtil.get(companyId, locale, key, null);
162
163 if ((value == null) || (value.equals(key))) {
164 value = PortletResourceBundles.getString(locale, key);
165 }
166
167 if (value == null) {
168 value = key;
169 }
170
171 return value;
172 }
173
174 public static String getModelResource(
175 PageContext pageContext, String name) {
176
177 String key = MODEL_RESOURCE_NAME_PREFIX + name;
178
179 String value = LanguageUtil.get(pageContext, key, null);
180
181 if ((value == null) || (value.equals(key))) {
182 value = PortletResourceBundles.getString(pageContext, key);
183 }
184
185 if (value == null) {
186 value = key;
187 }
188
189 return value;
190 }
191
192 public static List<String> getModelResourceActions(String name) {
193 return _instance._getModelResourceActions(name);
194 }
195
196 public static List<String> getModelResourceCommunityDefaultActions(
197 String name) {
198
199 return _instance._getModelResourceCommunityDefaultActions(name);
200 }
201
202 public static List<String> getModelResourceGuestDefaultActions(
203 String name) {
204
205 return _instance._getModelResourceGuestDefaultActions(name);
206 }
207
208 public static List<String> getModelResourceGuestUnsupportedActions(
209 String name) {
210
211 return _instance._getModelResourceGuestUnsupportedActions(name);
212 }
213
214 public static List<String> getPortletModelResources(String portletName) {
215 return _instance._getPortletModelResources(portletName);
216 }
217
218 public static List<String> getPortletNames() {
219 return _instance._getPortletNames();
220 }
221
222 public static List<String> getPortletResourceActions(String name) {
223 return _instance._getPortletResourceActions(name);
224 }
225
226 public static List<String> getPortletResourceCommunityDefaultActions(
227 String name) {
228
229 return _instance._getPortletResourceCommunityDefaultActions(name);
230 }
231
232 public static List<String> getPortletResourceGuestDefaultActions(
233 String name) {
234
235 return _instance._getPortletResourceGuestDefaultActions(name);
236 }
237
238 public static List<String> getPortletResourceGuestUnsupportedActions(
239 String name) {
240
241 return _instance._getPortletResourceGuestUnsupportedActions(name);
242 }
243
244 public static List<String> getPortletResourceLayoutManagerActions(
245 String name) {
246
247 return _instance._getPortletResourceLayoutManagerActions(name);
248 }
249
250 public static List<String> getResourceActions(String name) {
251 if (name.contains(StringPool.PERIOD)) {
252 return getModelResourceActions(name);
253 }
254 else {
255 return getPortletResourceActions(name);
256 }
257 }
258
259 public static List<String> getResourceActions(
260 String portletResource, String modelResource) {
261
262 List<String> actions = null;
263
264 if (Validator.isNull(modelResource)) {
265 actions = getPortletResourceActions(portletResource);
266 }
267 else {
268 actions = getModelResourceActions(modelResource);
269 }
270
271 return actions;
272 }
273
274 public static List<String> getResourceCommunityDefaultActions(String name) {
275 if (name.contains(StringPool.PERIOD)) {
276 return getModelResourceCommunityDefaultActions(name);
277 }
278 else {
279 return getPortletResourceCommunityDefaultActions(name);
280 }
281 }
282
283 public static List<String> getResourceGuestUnsupportedActions(
284 String portletResource, String modelResource) {
285
286 List<String> actions = null;
287
288 if (Validator.isNull(modelResource)) {
289 actions =
290 getPortletResourceGuestUnsupportedActions(portletResource);
291 }
292 else {
293 actions = getModelResourceGuestUnsupportedActions(modelResource);
294 }
295
296 return actions;
297 }
298
299 public static List<Role> getRoles(Group group, String modelResource)
300 throws SystemException {
301
302 List<Role> allRoles = RoleLocalServiceUtil.getRoles(
303 group.getCompanyId());
304
305 int[] types = new int[] {
306 RoleConstants.TYPE_REGULAR, RoleConstants.TYPE_COMMUNITY
307 };
308
309 if (isPortalModelResource(modelResource)) {
310 if (modelResource.equals(Organization.class.getName()) ||
311 modelResource.equals(User.class.getName())) {
312
313 types = new int[] {
314 RoleConstants.TYPE_REGULAR,
315 RoleConstants.TYPE_ORGANIZATION
316 };
317 }
318 else {
319 types = new int[] {RoleConstants.TYPE_REGULAR};
320 }
321 }
322 else {
323 if (group.isOrganization()) {
324 types = new int[] {
325 RoleConstants.TYPE_REGULAR,
326 RoleConstants.TYPE_ORGANIZATION
327 };
328 }
329 else if (group.isUser()) {
330 types = new int[] {RoleConstants.TYPE_REGULAR};
331 }
332 }
333
334 List<Role> roles = new ArrayList<Role>();
335
336 for (int type : types) {
337 for (Role role : allRoles) {
338 if (role.getType() == type) {
339 roles.add(role);
340 }
341 }
342 }
343
344 return roles;
345 }
346
347 public static void init() {
348 _instance._init();
349 }
350
351 public static boolean isOrganizationModelResource(String modelResource) {
352 return _instance._isOrganizationModelResource(modelResource);
353 }
354
355 public static boolean isPortalModelResource(String modelResource) {
356 return _instance._isPortalModelResource(modelResource);
357 }
358
359 public static void read(
360 String servletContextName, ClassLoader classLoader, String source)
361 throws Exception {
362
363 _instance._read(servletContextName, classLoader, source);
364 }
365
366 private ResourceActionsUtil() {
367 _organizationModelResources = new HashSet<String>();
368
369 for (int i = 0; i < ORGANIZATION_MODEL_RESOURCES.length; i++) {
370 _organizationModelResources.add(ORGANIZATION_MODEL_RESOURCES[i]);
371 }
372
373 _portalModelResources = new HashSet<String>();
374
375 for (int i = 0; i < PORTAL_MODEL_RESOURCES.length; i++) {
376 _portalModelResources.add(PORTAL_MODEL_RESOURCES[i]);
377 }
378
379 _portletModelResources = new HashMap<String, Set<String>>();
380 _portletResourceActions = new HashMap<String, List<String>>();
381 _portletResourceCommunityDefaultActions =
382 new HashMap<String, List<String>>();
383 _portletResourceGuestDefaultActions =
384 new HashMap<String, List<String>>();
385 _portletResourceGuestUnsupportedActions =
386 new HashMap<String, List<String>>();
387 _portletResourceLayoutManagerActions =
388 new HashMap<String, List<String>>();
389 _modelPortletResources = new HashMap<String, Set<String>>();
390 _modelResourceActions = new HashMap<String, List<String>>();
391 _modelResourceCommunityDefaultActions =
392 new HashMap<String, List<String>>();
393 _modelResourceGuestDefaultActions =
394 new HashMap<String, List<String>>();
395 _modelResourceGuestUnsupportedActions =
396 new HashMap<String, List<String>>();
397
398 try {
399 ClassLoader classLoader = getClass().getClassLoader();
400
401 String[] configs = StringUtil.split(
402 PropsUtil.get(PropsKeys.RESOURCE_ACTIONS_CONFIGS));
403
404 for (int i = 0; i < configs.length; i++) {
405 _read(null, classLoader, configs[i]);
406 }
407 }
408 catch (Exception e) {
409 _log.error(e, e);
410 }
411 }
412
413 private void _checkGuestUnsupportedActions(
414 List<String> guestUnsupportedActions,
415 List<String> guestDefaultActions) {
416
417
419 Iterator<String> itr = guestDefaultActions.iterator();
420
421 while (itr.hasNext()) {
422 String actionId = itr.next();
423
424 if (guestUnsupportedActions.contains(actionId)) {
425 itr.remove();
426 }
427 }
428 }
429
430 private void _checkPortletActions(List<String> actions) {
431 if (!actions.contains("CONFIGURATION")) {
432 actions.add("CONFIGURATION");
433 }
434
435 if (!actions.contains("VIEW")) {
436 actions.add("VIEW");
437 }
438 }
439
440 private void _checkPortletCommunityDefaultActions(List<String> actions) {
441 if (actions.size() == 0) {
442 actions.add("VIEW");
443 }
444 }
445
446 private void _checkPortletGuestDefaultActions(List<String> actions) {
447 if (actions.size() == 0) {
448 actions.add("VIEW");
449 }
450 }
451
452 private void _checkPortletLayoutManagerActions(List<String> actions) {
453 if (!actions.contains("CONFIGURATION")) {
454 actions.add("CONFIGURATION");
455 }
456
457 if (!actions.contains("PREFERENCES")) {
458 actions.add("PREFERENCES");
459 }
460
461 if (!actions.contains("VIEW")) {
462 actions.add("VIEW");
463 }
464 }
465
466 private List<String> _getActions(
467 Map<String, List<String>> map, String name) {
468
469 List<String> actions = map.get(name);
470
471 if (actions == null) {
472 actions = new UniqueList<String>();
473
474 map.put(name, actions);
475 }
476
477 return actions;
478 }
479
480 private List<String> _getModelNames() {
481 return ListUtil.fromCollection(_modelPortletResources.keySet());
482 }
483
484 private List<String> _getModelPortletResources(String name) {
485 Set<String> resources = _modelPortletResources.get(name);
486
487 if (resources == null) {
488 return new UniqueList<String>();
489 }
490 else {
491 return Collections.list(Collections.enumeration(resources));
492 }
493 }
494
495 private List<String> _getModelResourceActions(String name) {
496 return _getActions(_modelResourceActions, name);
497 }
498
499 private List<String> _getModelResourceCommunityDefaultActions(
500 String name) {
501
502 return _getActions(_modelResourceCommunityDefaultActions, name);
503 }
504
505 private List<String> _getModelResourceGuestDefaultActions(String name) {
506 return _getActions(_modelResourceGuestDefaultActions, name);
507 }
508
509 private List<String> _getModelResourceGuestUnsupportedActions(String name) {
510 return _getActions(_modelResourceGuestUnsupportedActions, name);
511 }
512
513 private List<String> _getPortletModelResources(String portletName) {
514 portletName = PortletConstants.getRootPortletId(portletName);
515
516 Set<String> resources = _portletModelResources.get(portletName);
517
518 if (resources == null) {
519 return new UniqueList<String>();
520 }
521 else {
522 return Collections.list(Collections.enumeration(resources));
523 }
524 }
525
526 private List<String> _getPortletNames() {
527 return ListUtil.fromCollection(_portletModelResources.keySet());
528 }
529
530 private List<String> _getPortletResourceActions(String name) {
531 name = PortletConstants.getRootPortletId(name);
532
533 List<String> actions = _getActions(_portletResourceActions, name);
534
535 if (actions.size() == 0) {
536 synchronized (this) {
537 Portlet portlet = PortletLocalServiceUtil.getPortletById(name);
538
539 if (portlet != null) {
540 Map<String, Set<String>> portletModes =
541 portlet.getPortletModes();
542
543 Set<String> mimeTypeModes = portletModes.get("text/html");
544
545 if (mimeTypeModes != null) {
546 for (String actionId : mimeTypeModes) {
547 if (actionId.equalsIgnoreCase("edit")) {
548 actions.add(ActionKeys.PREFERENCES);
549 }
550 else if (actionId.equalsIgnoreCase("edit_guest")) {
551 actions.add(ActionKeys.GUEST_PREFERENCES);
552 }
553 else {
554 actions.add(actionId.toUpperCase());
555 }
556 }
557 }
558 }
559 else {
560 if (_log.isWarnEnabled()) {
561 _log.warn(
562 "Unable to obtain resource actions for unknown " +
563 "portlet " + name);
564 }
565 }
566
567 _checkPortletActions(actions);
568
569 List<String> communityDefaultActions =
570 _portletResourceCommunityDefaultActions.get(name);
571
572 if (communityDefaultActions == null) {
573 communityDefaultActions = new UniqueList<String>();
574
575 _portletResourceCommunityDefaultActions.put(
576 name, communityDefaultActions);
577
578 _checkPortletCommunityDefaultActions(
579 communityDefaultActions);
580 }
581
582 List<String> guestDefaultActions =
583 _portletResourceGuestDefaultActions.get(name);
584
585 if (guestDefaultActions == null) {
586 guestDefaultActions = new UniqueList<String>();
587
588 _portletResourceGuestDefaultActions.put(
589 name, guestDefaultActions);
590
591 _checkPortletGuestDefaultActions(guestDefaultActions);
592 }
593
594 List<String> layoutManagerActions =
595 _portletResourceLayoutManagerActions.get(name);
596
597 if (layoutManagerActions == null) {
598 layoutManagerActions = new UniqueList<String>();
599
600 _portletResourceLayoutManagerActions.put(
601 name, layoutManagerActions);
602
603 _checkPortletLayoutManagerActions(layoutManagerActions);
604 }
605 }
606 }
607
608 return actions;
609 }
610
611 private List<String> _getPortletResourceCommunityDefaultActions(
612 String name) {
613
614
621 name = PortletConstants.getRootPortletId(name);
622
623 return _getActions(_portletResourceCommunityDefaultActions, name);
624 }
625
626 private List<String> _getPortletResourceGuestDefaultActions(String name) {
627 name = PortletConstants.getRootPortletId(name);
628
629 return _getActions(_portletResourceGuestDefaultActions, name);
630 }
631
632 private List<String> _getPortletResourceGuestUnsupportedActions(
633 String name) {
634
635 name = PortletConstants.getRootPortletId(name);
636
637 return _getActions(_portletResourceGuestUnsupportedActions, name);
638 }
639
640 private List<String> _getPortletResourceLayoutManagerActions(String name) {
641 name = PortletConstants.getRootPortletId(name);
642
643 List<String> actions = _getActions(
644 _portletResourceLayoutManagerActions, name);
645
646
651 if (actions.size() < 1) {
652 actions.add("CONFIGURATION");
653 actions.add("PREFERENCES");
654 actions.add("VIEW");
655 }
656
657 return actions;
658 }
659
660 private void _init() {
661 }
662
663 private boolean _isOrganizationModelResource(String modelResource) {
664 if (_organizationModelResources.contains(modelResource)) {
665 return true;
666 }
667 else {
668 return false;
669 }
670 }
671
672 private boolean _isPortalModelResource(String modelResource) {
673 if (_portalModelResources.contains(modelResource)) {
674 return true;
675 }
676 else {
677 return false;
678 }
679 }
680
681 private void _read(
682 String servletContextName, ClassLoader classLoader, String source)
683 throws Exception {
684
685 String xml = null;
686
687 try {
688 xml = StringUtil.read(classLoader, source);
689 }
690 catch (Exception e) {
691 _log.warn("Cannot load " + source);
692 }
693
694 if (xml == null) {
695 return;
696 }
697
698 if (_log.isDebugEnabled()) {
699 _log.debug("Loading " + source);
700 }
701
702 Document doc = SAXReaderUtil.read(xml);
703
704 Element root = doc.getRootElement();
705
706 Iterator<Element> itr1 = root.elements("resource").iterator();
707
708 while (itr1.hasNext()) {
709 Element resource = itr1.next();
710
711 String file = resource.attributeValue("file");
712
713 _read(servletContextName, classLoader, file);
714 }
715
716 itr1 = root.elements("portlet-resource").iterator();
717
718 while (itr1.hasNext()) {
719 Element resource = itr1.next();
720
721 String name = resource.elementText("portlet-name");
722
723 if (servletContextName != null) {
724 name =
725 name + PortletConstants.WAR_SEPARATOR + servletContextName;
726 }
727
728 name = PortalUtil.getJsSafePortletId(name);
729
730
732 List<String> actions = _getActions(_portletResourceActions, name);
733
734 Element supports = resource.element("supports");
735
736 Iterator<Element> itr2 = supports.elements("action-key").iterator();
737
738 while (itr2.hasNext()) {
739 Element actionKey = itr2.next();
740
741 String actionKeyText = actionKey.getText();
742
743 if (Validator.isNotNull(actionKeyText)) {
744 actions.add(actionKeyText);
745 }
746 }
747
748 if (!name.equals(PortletKeys.PORTAL)) {
749 _checkPortletActions(actions);
750 }
751
752
754 List<String> communityDefaultActions =
755 _getActions(_portletResourceCommunityDefaultActions, name);
756
757 Element communityDefaults = resource.element("community-defaults");
758
759 itr2 = communityDefaults.elements("action-key").iterator();
760
761 while (itr2.hasNext()) {
762 Element actionKey = itr2.next();
763
764 String actionKeyText = actionKey.getText();
765
766 if (Validator.isNotNull(actionKeyText)) {
767 communityDefaultActions.add(actionKeyText);
768 }
769 }
770
771
773 List<String> guestDefaultActions =
774 _getActions(_portletResourceGuestDefaultActions, name);
775
776 Element guestDefaults = resource.element("guest-defaults");
777
778 itr2 = guestDefaults.elements("action-key").iterator();
779
780 while (itr2.hasNext()) {
781 Element actionKey = itr2.next();
782
783 String actionKeyText = actionKey.getText();
784
785 if (Validator.isNotNull(actionKeyText)) {
786 guestDefaultActions.add(actionKeyText);
787 }
788 }
789
790
792 List<String> guestUnsupportedActions =
793 _getActions(_portletResourceGuestUnsupportedActions, name);
794
795 Element guestUnsupported = resource.element("guest-unsupported");
796
797 itr2 = guestUnsupported.elements("action-key").iterator();
798
799 while (itr2.hasNext()) {
800 Element actionKey = itr2.next();
801
802 String actionKeyText = actionKey.getText();
803
804 if (Validator.isNotNull(actionKeyText)) {
805 guestUnsupportedActions.add(actionKeyText);
806 }
807 }
808
809 _checkGuestUnsupportedActions(
810 guestUnsupportedActions, guestDefaultActions);
811
812
814 List<String> layoutManagerActions = _getActions(
815 _portletResourceLayoutManagerActions, name);
816
817 Element layoutManager = resource.element("layout-manager");
818
819 if (layoutManager != null) {
820 itr2 = layoutManager.elements("action-key").iterator();
821
822 while (itr2.hasNext()) {
823 Element actionKey = itr2.next();
824
825 String actionKeyText = actionKey.getText();
826
827 if (Validator.isNotNull(actionKeyText)) {
828 layoutManagerActions.add(actionKeyText);
829 }
830 }
831 }
832 else {
833
834
837 layoutManagerActions.addAll(actions);
838 }
839 }
840
841 itr1 = root.elements("model-resource").iterator();
842
843 while (itr1.hasNext()) {
844 Element resource = itr1.next();
845
846 String name = resource.elementText("model-name");
847
848 Element portletRef = resource.element("portlet-ref");
849
850 Iterator<Element> itr2 = portletRef.elements(
851 "portlet-name").iterator();
852
853 while (itr2.hasNext()) {
854 Element portletName = itr2.next();
855
856 String portletNameString = portletName.getText();
857
858 if (servletContextName != null) {
859 portletNameString =
860 portletNameString + PortletConstants.WAR_SEPARATOR +
861 servletContextName;
862 }
863
864 portletNameString = PortalUtil.getJsSafePortletId(
865 portletNameString);
866
867
869 Set<String> modelResources = _portletModelResources.get(
870 portletNameString);
871
872 if (modelResources == null) {
873 modelResources = new HashSet<String>();
874
875 _portletModelResources.put(
876 portletNameString, modelResources);
877 }
878
879 modelResources.add(name);
880
881
883 Set<String> portletResources = _modelPortletResources.get(name);
884
885 if (portletResources == null) {
886 portletResources = new HashSet<String>();
887
888 _modelPortletResources.put(name, portletResources);
889 }
890
891 portletResources.add(portletNameString);
892 }
893
894
896 List<String> actions = _getActions(_modelResourceActions, name);
897
898 Element supports = resource.element("supports");
899
900 itr2 = supports.elements("action-key").iterator();
901
902 while (itr2.hasNext()) {
903 Element actionKey = itr2.next();
904
905 String actionKeyText = actionKey.getText();
906
907 if (Validator.isNotNull(actionKeyText)) {
908 actions.add(actionKeyText);
909 }
910 }
911
912
914 List<String> communityDefaultActions =
915 _getActions(_modelResourceCommunityDefaultActions, name);
916
917 Element communityDefaults = resource.element("community-defaults");
918
919 itr2 = communityDefaults.elements("action-key").iterator();
920
921 while (itr2.hasNext()) {
922 Element actionKey = itr2.next();
923
924 String actionKeyText = actionKey.getText();
925
926 if (Validator.isNotNull(actionKeyText)) {
927 communityDefaultActions.add(actionKeyText);
928 }
929 }
930
931
933 List<String> guestDefaultActions =
934 _getActions(_modelResourceGuestDefaultActions, name);
935
936 Element guestDefaults = resource.element("guest-defaults");
937
938 itr2 = guestDefaults.elements("action-key").iterator();
939
940 while (itr2.hasNext()) {
941 Element actionKey = itr2.next();
942
943 String actionKeyText = actionKey.getText();
944
945 if (Validator.isNotNull(actionKeyText)) {
946 guestDefaultActions.add(actionKeyText);
947 }
948 }
949
950
952 List<String> guestUnsupportedActions =
953 _getActions(_modelResourceGuestUnsupportedActions, name);
954
955 Element guestUnsupported = resource.element("guest-unsupported");
956
957 itr2 = guestUnsupported.elements("action-key").iterator();
958
959 while (itr2.hasNext()) {
960 Element actionKey = itr2.next();
961
962 String actionKeyText = actionKey.getText();
963
964 if (Validator.isNotNull(actionKeyText)) {
965 guestUnsupportedActions.add(actionKeyText);
966 }
967 }
968
969 _checkGuestUnsupportedActions(
970 guestUnsupportedActions, guestDefaultActions);
971 }
972 }
973
974 private static Log _log = LogFactoryUtil.getLog(ResourceActionsUtil.class);
975
976 private static ResourceActionsUtil _instance = new ResourceActionsUtil();
977
978 private Set<String> _organizationModelResources;
979 private Set<String> _portalModelResources;
980 private Map<String, Set<String>> _portletModelResources;
981 private Map<String, List<String>> _portletResourceActions;
982 private Map<String, List<String>> _portletResourceCommunityDefaultActions;
983 private Map<String, List<String>> _portletResourceGuestDefaultActions;
984 private Map<String, List<String>> _portletResourceGuestUnsupportedActions;
985 private Map<String, List<String>> _portletResourceLayoutManagerActions;
986 private Map<String, Set<String>> _modelPortletResources;
987 private Map<String, List<String>> _modelResourceActions;
988 private Map<String, List<String>> _modelResourceCommunityDefaultActions;
989 private Map<String, List<String>> _modelResourceGuestDefaultActions;
990 private Map<String, List<String>> _modelResourceGuestUnsupportedActions;
991
992 }