001    /**
002     * Copyright (c) 2000-2013 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.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            @Override
030            public void addUserGroupGroupRoles(
031                            long userGroupId, long groupId, long[] roleIds)
032                    throws PortalException, SystemException {
033    
034                    PermissionChecker permissionChecker = getPermissionChecker();
035    
036                    if (!permissionChecker.isGroupOwner(groupId)) {
037                            throw new PrincipalException();
038                    }
039    
040                    userGroupGroupRoleLocalService.addUserGroupGroupRoles(
041                            userGroupId, groupId, roleIds);
042            }
043    
044            @Override
045            public void addUserGroupGroupRoles(
046                            long[] userGroupIds, long groupId, long roleId)
047                    throws PortalException, SystemException {
048    
049                    PermissionChecker permissionChecker = getPermissionChecker();
050    
051                    if (!permissionChecker.isGroupOwner(groupId)) {
052                            throw new PrincipalException();
053                    }
054    
055                    userGroupGroupRoleLocalService.addUserGroupGroupRoles(
056                            userGroupIds, groupId, roleId);
057            }
058    
059            @Override
060            public void deleteUserGroupGroupRoles(
061                            long userGroupId, long groupId, long[] roleIds)
062                    throws PortalException, SystemException {
063    
064                    PermissionChecker permissionChecker = getPermissionChecker();
065    
066                    if (!permissionChecker.isGroupOwner(groupId)) {
067                            throw new PrincipalException();
068                    }
069    
070                    userGroupGroupRoleLocalService.deleteUserGroupGroupRoles(
071                            userGroupId, groupId, roleIds);
072            }
073    
074            @Override
075            public void deleteUserGroupGroupRoles(
076                            long[] userGroupIds, long groupId, long roleId)
077                    throws PortalException, SystemException {
078    
079                    PermissionChecker permissionChecker = getPermissionChecker();
080    
081                    if (!permissionChecker.isGroupOwner(groupId)) {
082                            throw new PrincipalException();
083                    }
084    
085                    userGroupGroupRoleLocalService.deleteUserGroupGroupRoles(
086                            userGroupIds, groupId, roleId);
087            }
088    
089    }