use of cz.metacentrum.perun.audit.events.GroupManagerEvents.DirectMemberRemovedFromGroup in project perun by CESNET.
the class GroupsManagerBlImpl method removeDirectMember.
private void removeDirectMember(PerunSession sess, Group group, Member member) throws NotGroupMemberException, GroupNotExistsException, WrongAttributeValueException, WrongReferenceAttributeValueException {
lockGroupMembership(group, Collections.singletonList(member));
Map<Integer, Map<Integer, MemberGroupStatus>> previousStatuses = getPreviousStatuses(sess, group, List.of(member));
member.setSourceGroupId(group.getId());
getGroupsManagerImpl().removeMember(sess, group, member);
if (this.getGroupsManagerImpl().isGroupMember(sess, group, member)) {
getPerunBl().getAuditer().log(sess, new DirectMemberRemovedFromGroup(member, group));
// If member was indirect in group before, we don't need to change anything in other groups
return;
} else {
notifyMemberRemovalFromGroup(sess, group, member);
// remove all member-group attributes because member is not part of group any more
try {
getPerunBl().getAttributesManagerBl().removeAllAttributes(sess, member, group);
} catch (MemberGroupMismatchException e) {
throw new InternalErrorException(e);
}
getPerunBl().getAuditer().log(sess, new MemberRemovedFromGroupTotally(member, group));
}
// check all relations with this group and call removeRelationMembers to reflect changes of removing member from group
List<Integer> relations = groupsManagerImpl.getResultGroupsIds(sess, group.getId());
for (Integer groupId : relations) {
removeRelationMembers(sess, groupsManagerImpl.getGroupById(sess, groupId), Collections.singletonList(member), group.getId());
}
if (!VosManager.MEMBERS_GROUP.equals(group.getName())) {
recalculateMemberGroupStatusRecursively(sess, member, group, previousStatuses);
}
if (!getGroupsManagerImpl().isGroupMember(sess, group, member)) {
addMemberToGroupsFromTriggerAttribute(sess, group, member);
}
}
Aggregations