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