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