1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.service.permission;
21  
22  import com.liferay.portal.PortalException;
23  import com.liferay.portal.SystemException;
24  import com.liferay.portal.model.Portlet;
25  import com.liferay.portal.security.permission.PermissionChecker;
26  
27  /**
28   * <a href="PortletPermissionUtil.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Brian Wing Shun Chan
31   *
32   */
33  public class PortletPermissionUtil {
34  
35      public static void check(
36              PermissionChecker permissionChecker, String portletId,
37              String actionId)
38          throws PortalException, SystemException {
39  
40          getPortletPermission().check(permissionChecker, portletId, actionId);
41      }
42  
43      public static void check(
44              PermissionChecker permissionChecker, long plid, String portletId,
45              String actionId)
46          throws PortalException, SystemException {
47  
48          getPortletPermission().check(
49              permissionChecker, plid, portletId, actionId);
50      }
51  
52      public static void check(
53              PermissionChecker permissionChecker, long plid, String portletId,
54              String actionId, boolean strict)
55          throws PortalException, SystemException {
56  
57          getPortletPermission().check(
58              permissionChecker, plid, portletId, actionId, strict);
59      }
60  
61      public static boolean contains(
62              PermissionChecker permissionChecker, String portletId,
63              String actionId)
64          throws PortalException, SystemException {
65  
66          return getPortletPermission().contains(
67              permissionChecker, portletId, actionId);
68      }
69  
70      public static boolean contains(
71              PermissionChecker permissionChecker, long plid, String portletId,
72              String actionId)
73          throws PortalException, SystemException {
74  
75          return getPortletPermission().contains(
76              permissionChecker, plid, portletId, actionId);
77      }
78  
79      public static boolean contains(
80              PermissionChecker permissionChecker, long plid, String portletId,
81              String actionId, boolean strict)
82          throws PortalException, SystemException {
83  
84          return getPortletPermission().contains(
85              permissionChecker, plid, portletId, actionId, strict);
86      }
87  
88      public static boolean contains(
89              PermissionChecker permissionChecker, long plid, Portlet portlet,
90              String actionId)
91          throws PortalException, SystemException {
92  
93          return getPortletPermission().contains(
94              permissionChecker, plid, portlet, actionId);
95      }
96  
97      public static boolean contains(
98              PermissionChecker permissionChecker, long plid, Portlet portlet,
99              String actionId, boolean strict)
100         throws PortalException, SystemException {
101 
102         return getPortletPermission().contains(
103             permissionChecker, plid, portlet, actionId, strict);
104     }
105 
106     public static PortletPermission getPortletPermission() {
107         return _portletPermission;
108     }
109 
110     public static String getPrimaryKey(long plid, String portletId) {
111         return getPortletPermission().getPrimaryKey(plid, portletId);
112     }
113 
114     public static boolean hasLayoutManagerPermission(
115         String portletId, String actionId) {
116 
117         return getPortletPermission().hasLayoutManagerPermission(
118             portletId, actionId);
119     }
120 
121     public void setPortletPermission(PortletPermission portletPermission) {
122         _portletPermission = portletPermission;
123     }
124 
125     private static PortletPermission _portletPermission;
126 
127 }