001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.permission;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.model.Portlet;
020    import com.liferay.portal.security.permission.PermissionChecker;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class PortletPermissionUtil {
026    
027            public static void check(
028                            PermissionChecker permissionChecker, String portletId,
029                            String actionId)
030                    throws PortalException, SystemException {
031    
032                    getPortletPermission().check(permissionChecker, portletId, actionId);
033            }
034    
035            public static void check(
036                            PermissionChecker permissionChecker, long plid, String portletId,
037                            String actionId)
038                    throws PortalException, SystemException {
039    
040                    getPortletPermission().check(
041                            permissionChecker, plid, portletId, actionId);
042            }
043    
044            public static void check(
045                            PermissionChecker permissionChecker, long plid, String portletId,
046                            String actionId, boolean strict)
047                    throws PortalException, SystemException {
048    
049                    getPortletPermission().check(
050                            permissionChecker, plid, portletId, actionId, strict);
051            }
052    
053            public static boolean contains(
054                            PermissionChecker permissionChecker, String portletId,
055                            String actionId)
056                    throws PortalException, SystemException {
057    
058                    return getPortletPermission().contains(
059                            permissionChecker, portletId, actionId);
060            }
061    
062            public static boolean contains(
063                            PermissionChecker permissionChecker, long plid, String portletId,
064                            String actionId)
065                    throws PortalException, SystemException {
066    
067                    return getPortletPermission().contains(
068                            permissionChecker, plid, portletId, actionId);
069            }
070    
071            public static boolean contains(
072                            PermissionChecker permissionChecker, long plid, String portletId,
073                            String actionId, boolean strict)
074                    throws PortalException, SystemException {
075    
076                    return getPortletPermission().contains(
077                            permissionChecker, plid, portletId, actionId, strict);
078            }
079    
080            public static boolean contains(
081                            PermissionChecker permissionChecker, long plid, Portlet portlet,
082                            String actionId)
083                    throws PortalException, SystemException {
084    
085                    return getPortletPermission().contains(
086                            permissionChecker, plid, portlet, actionId);
087            }
088    
089            public static boolean contains(
090                            PermissionChecker permissionChecker, long plid, Portlet portlet,
091                            String actionId, boolean strict)
092                    throws PortalException, SystemException {
093    
094                    return getPortletPermission().contains(
095                            permissionChecker, plid, portlet, actionId, strict);
096            }
097    
098            public static PortletPermission getPortletPermission() {
099                    return _portletPermission;
100            }
101    
102            public static String getPrimaryKey(long plid, String portletId) {
103                    return getPortletPermission().getPrimaryKey(plid, portletId);
104            }
105    
106            public static boolean hasLayoutManagerPermission(
107                    String portletId, String actionId) {
108    
109                    return getPortletPermission().hasLayoutManagerPermission(
110                            portletId, actionId);
111            }
112    
113            public void setPortletPermission(PortletPermission portletPermission) {
114                    _portletPermission = portletPermission;
115            }
116    
117            private static PortletPermission _portletPermission;
118    
119    }