1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service.permission;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.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 }