use of cz.metacentrum.perun.audit.events.GroupManagerEvents.IndirectMemberRemovedFromGroup in project perun by CESNET.
the class GroupsManagerBlImpl method removeIndirectMembers.
/**
* Remove records of the members with an INDIRECT membership type from the group.
*
* @param sess perun session
* @param group group to remove records of INDIRECT members from
* @param members list of members to remove
* @param sourceGroupId id of a group from which members originate
* @return list of members that were removed (their only record in the group was deleted)
*/
private List<Member> removeIndirectMembers(PerunSession sess, Group group, List<Member> members, int sourceGroupId) throws WrongAttributeValueException, WrongReferenceAttributeValueException, NotGroupMemberException {
List<Member> membersToRemove = new ArrayList<>(members);
lockGroupMembership(group, membersToRemove);
for (Member member : membersToRemove) {
member.setSourceGroupId(sourceGroupId);
groupsManagerImpl.removeMember(sess, group, member);
}
// get list of new members
List<Member> newMembers = this.getGroupMembers(sess, group);
// get only removed members
membersToRemove.removeAll(newMembers);
for (Member removedIndirectMember : membersToRemove) {
addMemberToGroupsFromTriggerAttribute(sess, group, removedIndirectMember);
notifyMemberRemovalFromGroup(sess, group, removedIndirectMember);
// remove all member-group attributes because member is not part of group any more
try {
getPerunBl().getAttributesManagerBl().removeAllAttributes(sess, removedIndirectMember, group);
} catch (MemberGroupMismatchException e) {
throw new InternalErrorException("Member we tried to remove all member-group attributes is not from the same VO as Group.", e);
}
getPerunBl().getAuditer().log(sess, new IndirectMemberRemovedFromGroup(removedIndirectMember, group));
}
return membersToRemove;
}
Aggregations