1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service.impl;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.security.auth.PrincipalException;
20  import com.liferay.portal.security.permission.PermissionChecker;
21  import com.liferay.portal.service.base.UserGroupGroupRoleServiceBaseImpl;
22  
23  /**
24   * <a href="UserGroupGroupRoleServiceImpl.java.html"><b><i>View Source</i></b>
25   * </a>
26   *
27   * @author Brett Swaim
28   */
29  public class UserGroupGroupRoleServiceImpl
30      extends UserGroupGroupRoleServiceBaseImpl {
31  
32      public void addUserGroupGroupRoles(
33              long userGroupId, long groupId, long[] roleIds)
34          throws PortalException, SystemException {
35  
36          PermissionChecker permissionChecker = getPermissionChecker();
37  
38          if (!permissionChecker.isCommunityOwner(groupId)) {
39              throw new PrincipalException();
40          }
41  
42          userGroupGroupRoleLocalService.addUserGroupGroupRoles(
43              userGroupId, groupId, roleIds);
44      }
45  
46      public void addUserGroupGroupRoles(
47              long[] userGroupIds, long groupId, long roleId)
48          throws PortalException, SystemException {
49  
50          PermissionChecker permissionChecker = getPermissionChecker();
51  
52          if (!permissionChecker.isCommunityOwner(groupId)) {
53              throw new PrincipalException();
54          }
55  
56          userGroupGroupRoleLocalService.addUserGroupGroupRoles(
57              userGroupIds, groupId, roleId);
58      }
59  
60      public void deleteUserGroupGroupRoles(
61              long userGroupId, long groupId, long[] roleIds)
62          throws PortalException, SystemException {
63  
64          PermissionChecker permissionChecker = getPermissionChecker();
65  
66          if (!permissionChecker.isCommunityOwner(groupId)) {
67              throw new PrincipalException();
68          }
69  
70          userGroupGroupRoleLocalService.deleteUserGroupGroupRoles(
71              userGroupId, groupId, roleIds);
72      }
73  
74      public void deleteUserGroupGroupRoles(
75              long[] userGroupIds, long groupId, long roleId)
76          throws PortalException, SystemException {
77  
78          PermissionChecker permissionChecker = getPermissionChecker();
79  
80          if (!permissionChecker.isCommunityOwner(groupId)) {
81              throw new PrincipalException();
82          }
83  
84          userGroupGroupRoleLocalService.deleteUserGroupGroupRoles(
85              userGroupIds, groupId, roleId);
86      }
87  
88  }