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.security.auth.PrincipalException;
23  import com.liferay.portal.security.permission.PermissionChecker;
24  
25  /**
26   * <a href="UserPermissionUtil.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   *
30   */
31  public class UserPermissionUtil {
32  
33      public static void check(
34              PermissionChecker permissionChecker, long userId, String actionId)
35          throws PrincipalException {
36  
37          getUserPermission().check(permissionChecker, userId, actionId);
38      }
39  
40      /**
41       * @deprecated
42       */
43      public static void check(
44              PermissionChecker permissionChecker, long userId,
45              long organizationId, long locationId, String actionId)
46          throws PrincipalException {
47  
48          check(
49              permissionChecker, userId, new long[] {organizationId, locationId},
50              actionId);
51      }
52  
53      public static void check(
54              PermissionChecker permissionChecker, long userId,
55              long[] organizationIds, String actionId)
56          throws PrincipalException {
57  
58          getUserPermission().check(
59              permissionChecker, userId, organizationIds, actionId);
60      }
61  
62      public static boolean contains(
63          PermissionChecker permissionChecker, long userId, String actionId) {
64  
65          return getUserPermission().contains(
66              permissionChecker, userId, actionId);
67      }
68  
69      /**
70       * @deprecated
71       */
72      public static boolean contains(
73          PermissionChecker permissionChecker, long userId, long organizationId,
74          long locationId, String actionId) {
75  
76          return contains(
77              permissionChecker, userId, new long[] {organizationId, locationId},
78              actionId);
79      }
80  
81      public static boolean contains(
82          PermissionChecker permissionChecker, long userId,
83          long[] organizationIds, String actionId) {
84  
85          return getUserPermission().contains(
86              permissionChecker, userId, organizationIds, actionId);
87      }
88  
89      public static UserPermission getUserPermission() {
90          return _userPermission;
91      }
92  
93      public void setUserPermission(UserPermission userPermission) {
94          _userPermission = userPermission;
95      }
96  
97      private static UserPermission _userPermission;
98  
99  }