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