001    /**
002     * Copyright (c) 2000-2012 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.Layout;
020    import com.liferay.portal.model.Portlet;
021    import com.liferay.portal.security.permission.PermissionChecker;
022    
023    import java.util.Collection;
024    
025    import javax.portlet.PortletMode;
026    
027    /**
028     * @author Brian Wing Shun Chan
029     * @author Raymond Augé
030     */
031    public class PortletPermissionUtil {
032    
033            public static void check(
034                            PermissionChecker permissionChecker, Layout layout,
035                            String portletId, String actionId)
036                    throws PortalException, SystemException {
037    
038                    getPortletPermission().check(
039                            permissionChecker, layout, portletId, actionId);
040            }
041    
042            public static void check(
043                            PermissionChecker permissionChecker, Layout layout,
044                            String portletId, String actionId, boolean strict)
045                    throws PortalException, SystemException {
046    
047                    getPortletPermission().check(
048                            permissionChecker, layout, portletId, actionId, strict);
049            }
050    
051            public static void check(
052                            PermissionChecker permissionChecker, long groupId, Layout layout,
053                            String portletId, String actionId)
054                    throws PortalException, SystemException {
055    
056                    getPortletPermission().check(
057                            permissionChecker, groupId, layout, portletId, actionId);
058            }
059    
060            public static void check(
061                            PermissionChecker permissionChecker, long groupId, Layout layout,
062                            String portletId, String actionId, boolean strict)
063                    throws PortalException, SystemException {
064    
065                    getPortletPermission().check(
066                            permissionChecker, groupId, layout, portletId, actionId, strict);
067            }
068    
069            public static void check(
070                            PermissionChecker permissionChecker, long groupId, long plid,
071                            String portletId, String actionId)
072                    throws PortalException, SystemException {
073    
074                    getPortletPermission().check(
075                            permissionChecker, groupId, plid, portletId, actionId);
076            }
077    
078            public static void check(
079                            PermissionChecker permissionChecker, long groupId, long plid,
080                            String portletId, String actionId, boolean strict)
081                    throws PortalException, SystemException {
082    
083                    getPortletPermission().check(
084                            permissionChecker, groupId, plid, portletId, actionId, strict);
085            }
086    
087            public static void check(
088                            PermissionChecker permissionChecker, long plid, String portletId,
089                            String actionId)
090                    throws PortalException, SystemException {
091    
092                    getPortletPermission().check(
093                            permissionChecker, plid, portletId, actionId);
094            }
095    
096            public static void check(
097                            PermissionChecker permissionChecker, long plid, String portletId,
098                            String actionId, boolean strict)
099                    throws PortalException, SystemException {
100    
101                    getPortletPermission().check(
102                            permissionChecker, plid, portletId, actionId, strict);
103            }
104    
105            public static void check(
106                            PermissionChecker permissionChecker, String portletId,
107                            String actionId)
108                    throws PortalException, SystemException {
109    
110                    getPortletPermission().check(permissionChecker, portletId, actionId);
111            }
112    
113            public static boolean contains(
114                            PermissionChecker permissionChecker, Layout layout, Portlet portlet,
115                            String actionId)
116                    throws PortalException, SystemException {
117    
118                    return getPortletPermission().contains(
119                            permissionChecker, layout, portlet, actionId);
120            }
121    
122            public static boolean contains(
123                            PermissionChecker permissionChecker, Layout layout, Portlet portlet,
124                            String actionId, boolean strict)
125                    throws PortalException, SystemException {
126    
127                    return getPortletPermission().contains(
128                            permissionChecker, layout, portlet, actionId, strict);
129            }
130    
131            public static boolean contains(
132                            PermissionChecker permissionChecker, Layout layout,
133                            String portletId, String actionId)
134                    throws PortalException, SystemException {
135    
136                    return getPortletPermission().contains(
137                            permissionChecker, layout, portletId, actionId);
138            }
139    
140            public static boolean contains(
141                            PermissionChecker permissionChecker, Layout layout,
142                            String portletId, String actionId, boolean strict)
143                    throws PortalException, SystemException {
144    
145                    return getPortletPermission().contains(
146                            permissionChecker, layout, portletId, actionId, strict);
147            }
148    
149            public static boolean contains(
150                            PermissionChecker permissionChecker, long groupId, Layout layout,
151                            Portlet portlet, String actionId)
152                    throws PortalException, SystemException {
153    
154                    return getPortletPermission().contains(
155                            permissionChecker, groupId, layout, portlet, actionId);
156            }
157    
158            public static boolean contains(
159                            PermissionChecker permissionChecker, long groupId, Layout layout,
160                            Portlet portlet, String actionId, boolean strict)
161                    throws PortalException, SystemException {
162    
163                    return getPortletPermission().contains(
164                            permissionChecker, groupId, layout, portlet, actionId, strict);
165            }
166    
167            public static boolean contains(
168                            PermissionChecker permissionChecker, long groupId, Layout layout,
169                            String portletId, String actionId)
170                    throws PortalException, SystemException {
171    
172                    return getPortletPermission().contains(
173                            permissionChecker, groupId, layout, portletId, actionId);
174            }
175    
176            public static boolean contains(
177                            PermissionChecker permissionChecker, long groupId, Layout layout,
178                            String portletId, String actionId, boolean strict)
179                    throws PortalException, SystemException {
180    
181                    return getPortletPermission().contains(
182                            permissionChecker, groupId, layout, portletId, actionId, strict);
183            }
184    
185            public static boolean contains(
186                    PermissionChecker permissionChecker, long groupId, long plid,
187                    Collection<Portlet> portlets, String actionId) {
188    
189                    return getPortletPermission().contains(
190                            permissionChecker, groupId, plid, portlets, actionId);
191            }
192    
193            public static boolean contains(
194                            PermissionChecker permissionChecker, long groupId, long plid,
195                            String portletId, String actionId, boolean strict)
196                    throws PortalException, SystemException {
197    
198                    return getPortletPermission().contains(
199                            permissionChecker, groupId, plid, portletId, actionId, strict);
200            }
201    
202            public static boolean contains(
203                            PermissionChecker permissionChecker, long plid, Portlet portlet,
204                            String actionId)
205                    throws PortalException, SystemException {
206    
207                    return getPortletPermission().contains(
208                            permissionChecker, plid, portlet, actionId);
209            }
210    
211            public static boolean contains(
212                            PermissionChecker permissionChecker, long plid, Portlet portlet,
213                            String actionId, boolean strict)
214                    throws PortalException, SystemException {
215    
216                    return getPortletPermission().contains(
217                            permissionChecker, plid, portlet, actionId, strict);
218            }
219    
220            public static boolean contains(
221                            PermissionChecker permissionChecker, long plid, String portletId,
222                            String actionId)
223                    throws PortalException, SystemException {
224    
225                    return getPortletPermission().contains(
226                            permissionChecker, plid, portletId, actionId);
227            }
228    
229            public static boolean contains(
230                            PermissionChecker permissionChecker, long plid, String portletId,
231                            String actionId, boolean strict)
232                    throws PortalException, SystemException {
233    
234                    return getPortletPermission().contains(
235                            permissionChecker, plid, portletId, actionId, strict);
236            }
237    
238            public static boolean contains(
239                            PermissionChecker permissionChecker, String portletId,
240                            String actionId)
241                    throws PortalException, SystemException {
242    
243                    return getPortletPermission().contains(
244                            permissionChecker, portletId, actionId);
245            }
246    
247            public static PortletPermission getPortletPermission() {
248                    return _portletPermission;
249            }
250    
251            public static String getPrimaryKey(long plid, String portletId) {
252                    return getPortletPermission().getPrimaryKey(plid, portletId);
253            }
254    
255            public static boolean hasAccessPermission(
256                            PermissionChecker permissionChecker, long scopeGroupId,
257                            Layout layout, Portlet portlet, PortletMode portletMode)
258                    throws PortalException, SystemException {
259    
260                    return getPortletPermission().hasAccessPermission(
261                            permissionChecker, scopeGroupId, layout, portlet, portletMode);
262            }
263    
264            public static boolean hasLayoutManagerPermission(
265                    String portletId, String actionId) {
266    
267                    return getPortletPermission().hasLayoutManagerPermission(
268                            portletId, actionId);
269            }
270    
271            public void setPortletPermission(PortletPermission portletPermission) {
272                    _portletPermission = portletPermission;
273            }
274    
275            private static PortletPermission _portletPermission;
276    
277    }