1   /**
2    * Copyright (c) 2000-2010 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   *
12   * 
13   */
14  
15  package com.liferay.portal.service.impl;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.security.auth.PrincipalException;
20  import com.liferay.portal.security.permission.PermissionChecker;
21  import com.liferay.portal.service.base.UserGroupRoleServiceBaseImpl;
22  
23  /**
24   * <a href="UserGroupRoleServiceImpl.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Brian Wing Shun Chan
27   */
28  public class UserGroupRoleServiceImpl extends UserGroupRoleServiceBaseImpl {
29  
30      public void addUserGroupRoles(long userId, long groupId, long[] roleIds)
31          throws PortalException, SystemException {
32  
33          PermissionChecker permissionChecker = getPermissionChecker();
34  
35          if (!permissionChecker.isCommunityOwner(groupId)) {
36              throw new PrincipalException();
37          }
38  
39          userGroupRoleLocalService.addUserGroupRoles(userId, groupId, roleIds);
40      }
41  
42      public void addUserGroupRoles(long[] userIds, long groupId, long roleId)
43          throws PortalException, SystemException {
44  
45          PermissionChecker permissionChecker = getPermissionChecker();
46  
47          if (!permissionChecker.isCommunityOwner(groupId)) {
48              throw new PrincipalException();
49          }
50  
51          userGroupRoleLocalService.addUserGroupRoles(userIds, groupId, roleId);
52      }
53  
54      public void deleteUserGroupRoles(long userId, long groupId, long[] roleIds)
55          throws PortalException, SystemException {
56  
57          PermissionChecker permissionChecker = getPermissionChecker();
58  
59          if (!permissionChecker.isCommunityOwner(groupId)) {
60              throw new PrincipalException();
61          }
62  
63          userGroupRoleLocalService.deleteUserGroupRoles(
64              userId, groupId, roleIds);
65      }
66  
67      public void deleteUserGroupRoles(long[] userIds, long groupId, long roleId)
68          throws PortalException, SystemException {
69  
70          PermissionChecker permissionChecker = getPermissionChecker();
71  
72          if (!permissionChecker.isCommunityOwner(groupId)) {
73              throw new PrincipalException();
74          }
75  
76          userGroupRoleLocalService.deleteUserGroupRoles(
77              userIds, groupId, roleId);
78      }
79  
80  }