001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.security.auth.PrincipalException;
020    import com.liferay.portal.security.permission.PermissionChecker;
021    import com.liferay.portal.service.base.UserGroupGroupRoleServiceBaseImpl;
022    
023    /**
024     * @author Brett Swaim
025     */
026    public class UserGroupGroupRoleServiceImpl
027            extends UserGroupGroupRoleServiceBaseImpl {
028    
029            public void addUserGroupGroupRoles(
030                            long userGroupId, long groupId, long[] roleIds)
031                    throws PortalException, SystemException {
032    
033                    PermissionChecker permissionChecker = getPermissionChecker();
034    
035                    if (!permissionChecker.isCommunityOwner(groupId)) {
036                            throw new PrincipalException();
037                    }
038    
039                    userGroupGroupRoleLocalService.addUserGroupGroupRoles(
040                            userGroupId, groupId, roleIds);
041            }
042    
043            public void addUserGroupGroupRoles(
044                            long[] userGroupIds, long groupId, long roleId)
045                    throws PortalException, SystemException {
046    
047                    PermissionChecker permissionChecker = getPermissionChecker();
048    
049                    if (!permissionChecker.isCommunityOwner(groupId)) {
050                            throw new PrincipalException();
051                    }
052    
053                    userGroupGroupRoleLocalService.addUserGroupGroupRoles(
054                            userGroupIds, groupId, roleId);
055            }
056    
057            public void deleteUserGroupGroupRoles(
058                            long userGroupId, long groupId, long[] roleIds)
059                    throws PortalException, SystemException {
060    
061                    PermissionChecker permissionChecker = getPermissionChecker();
062    
063                    if (!permissionChecker.isCommunityOwner(groupId)) {
064                            throw new PrincipalException();
065                    }
066    
067                    userGroupGroupRoleLocalService.deleteUserGroupGroupRoles(
068                            userGroupId, groupId, roleIds);
069            }
070    
071            public void deleteUserGroupGroupRoles(
072                            long[] userGroupIds, long groupId, long roleId)
073                    throws PortalException, SystemException {
074    
075                    PermissionChecker permissionChecker = getPermissionChecker();
076    
077                    if (!permissionChecker.isCommunityOwner(groupId)) {
078                            throw new PrincipalException();
079                    }
080    
081                    userGroupGroupRoleLocalService.deleteUserGroupGroupRoles(
082                            userGroupIds, groupId, roleId);
083            }
084    
085    }