1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portal.service.permission;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.model.Portlet;
20  import com.liferay.portal.security.permission.PermissionChecker;
21  
22  /**
23   * <a href="PortletPermissionUtil.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Brian Wing Shun Chan
26   */
27  public class PortletPermissionUtil {
28  
29      public static void check(
30              PermissionChecker permissionChecker, String portletId,
31              String actionId)
32          throws PortalException, SystemException {
33  
34          getPortletPermission().check(permissionChecker, portletId, actionId);
35      }
36  
37      public static void check(
38              PermissionChecker permissionChecker, long plid, String portletId,
39              String actionId)
40          throws PortalException, SystemException {
41  
42          getPortletPermission().check(
43              permissionChecker, plid, portletId, actionId);
44      }
45  
46      public static void check(
47              PermissionChecker permissionChecker, long plid, String portletId,
48              String actionId, boolean strict)
49          throws PortalException, SystemException {
50  
51          getPortletPermission().check(
52              permissionChecker, plid, portletId, actionId, strict);
53      }
54  
55      public static boolean contains(
56              PermissionChecker permissionChecker, String portletId,
57              String actionId)
58          throws PortalException, SystemException {
59  
60          return getPortletPermission().contains(
61              permissionChecker, portletId, actionId);
62      }
63  
64      public static boolean contains(
65              PermissionChecker permissionChecker, long plid, String portletId,
66              String actionId)
67          throws PortalException, SystemException {
68  
69          return getPortletPermission().contains(
70              permissionChecker, plid, portletId, actionId);
71      }
72  
73      public static boolean contains(
74              PermissionChecker permissionChecker, long plid, String portletId,
75              String actionId, boolean strict)
76          throws PortalException, SystemException {
77  
78          return getPortletPermission().contains(
79              permissionChecker, plid, portletId, actionId, strict);
80      }
81  
82      public static boolean contains(
83              PermissionChecker permissionChecker, long plid, Portlet portlet,
84              String actionId)
85          throws PortalException, SystemException {
86  
87          return getPortletPermission().contains(
88              permissionChecker, plid, portlet, actionId);
89      }
90  
91      public static boolean contains(
92              PermissionChecker permissionChecker, long plid, Portlet portlet,
93              String actionId, boolean strict)
94          throws PortalException, SystemException {
95  
96          return getPortletPermission().contains(
97              permissionChecker, plid, portlet, actionId, strict);
98      }
99  
100     public static PortletPermission getPortletPermission() {
101         return _portletPermission;
102     }
103 
104     public static String getPrimaryKey(long plid, String portletId) {
105         return getPortletPermission().getPrimaryKey(plid, portletId);
106     }
107 
108     public static boolean hasLayoutManagerPermission(
109         String portletId, String actionId) {
110 
111         return getPortletPermission().hasLayoutManagerPermission(
112             portletId, actionId);
113     }
114 
115     public void setPortletPermission(PortletPermission portletPermission) {
116         _portletPermission = portletPermission;
117     }
118 
119     private static PortletPermission _portletPermission;
120 
121 }