001    /**
002     * Copyright (c) 2000-2013 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.service.base.UserGroupGroupRoleServiceBaseImpl;
020    import com.liferay.portal.service.permission.UserGroupRolePermissionUtil;
021    
022    /**
023     * @author Brett Swaim
024     * @author Akos Thurzo
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                    checkPermission(groupId, roleIds);
035    
036                    userGroupGroupRoleLocalService.addUserGroupGroupRoles(
037                            userGroupId, groupId, roleIds);
038            }
039    
040            @Override
041            public void addUserGroupGroupRoles(
042                            long[] userGroupIds, long groupId, long roleId)
043                    throws PortalException, SystemException {
044    
045                    checkPermission(groupId, new long[] {roleId});
046    
047                    userGroupGroupRoleLocalService.addUserGroupGroupRoles(
048                            userGroupIds, groupId, roleId);
049            }
050    
051            @Override
052            public void deleteUserGroupGroupRoles(
053                            long userGroupId, long groupId, long[] roleIds)
054                    throws PortalException, SystemException {
055    
056                    checkPermission(groupId, roleIds);
057    
058                    userGroupGroupRoleLocalService.deleteUserGroupGroupRoles(
059                            userGroupId, groupId, roleIds);
060            }
061    
062            @Override
063            public void deleteUserGroupGroupRoles(
064                            long[] userGroupIds, long groupId, long roleId)
065                    throws PortalException, SystemException {
066    
067                    checkPermission(groupId, new long[] {roleId});
068    
069                    userGroupGroupRoleLocalService.deleteUserGroupGroupRoles(
070                            userGroupIds, groupId, roleId);
071            }
072    
073            protected void checkPermission(long groupId, long[] roleIds)
074                    throws PortalException, SystemException {
075    
076                    for (long roleId : roleIds) {
077                            UserGroupRolePermissionUtil.check(
078                                    getPermissionChecker(), groupId, roleId);
079                    }
080            }
081    
082    }