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.security.auth.PrincipalException;
018    import com.liferay.portal.security.permission.PermissionChecker;
019    
020    /**
021     * @author Brian Wing Shun Chan
022     */
023    public class UserPermissionUtil {
024    
025            /**
026             * @deprecated
027             */
028            public static void check(
029                            PermissionChecker permissionChecker, long userId,
030                            long organizationId, long locationId, String actionId)
031                    throws PrincipalException {
032    
033                    check(
034                            permissionChecker, userId, new long[] {organizationId, locationId},
035                            actionId);
036            }
037    
038            public static void check(
039                            PermissionChecker permissionChecker, long userId,
040                            long[] organizationIds, String actionId)
041                    throws PrincipalException {
042    
043                    getUserPermission().check(
044                            permissionChecker, userId, organizationIds, actionId);
045            }
046    
047            public static void check(
048                            PermissionChecker permissionChecker, long userId, String actionId)
049                    throws PrincipalException {
050    
051                    getUserPermission().check(permissionChecker, userId, actionId);
052            }
053    
054            /**
055             * @deprecated
056             */
057            public static boolean contains(
058                    PermissionChecker permissionChecker, long userId, long organizationId,
059                    long locationId, String actionId) {
060    
061                    return contains(
062                            permissionChecker, userId, new long[] {organizationId, locationId},
063                            actionId);
064            }
065    
066            public static boolean contains(
067                    PermissionChecker permissionChecker, long userId,
068                    long[] organizationIds, String actionId) {
069    
070                    return getUserPermission().contains(
071                            permissionChecker, userId, organizationIds, actionId);
072            }
073    
074            public static boolean contains(
075                    PermissionChecker permissionChecker, long userId, String actionId) {
076    
077                    return getUserPermission().contains(
078                            permissionChecker, userId, actionId);
079            }
080    
081            public static UserPermission getUserPermission() {
082                    return _userPermission;
083            }
084    
085            public void setUserPermission(UserPermission userPermission) {
086                    _userPermission = userPermission;
087            }
088    
089            private static UserPermission _userPermission;
090    
091    }