use of cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberRemovedFromGroupTotally in project perun by CESNET.
the class GroupsManagerBlImpl method logTotallyRemovedMembers.
/**
* Log members that were deleted from parent group totally to auditer.
*
* @param sess perun session
* @param parentGroupId group id
* @param membersFromDeletedGroup deleted members from child group
* @throws InternalErrorException
*/
private void logTotallyRemovedMembers(PerunSession sess, Integer parentGroupId, List<Member> membersFromDeletedGroup) {
while (parentGroupId != null) {
Group parentGroup;
try {
parentGroup = getGroupById(sess, parentGroupId);
} catch (GroupNotExistsException ex) {
throw new ConsistencyErrorException(ex);
}
// getting members from parent group AFTER the indirect members from subgroup were removed from this group.
List<Member> membersFromParentGroup = getGroupMembers(sess, parentGroup);
// removeAll will remove all members which remains in parent group even after they removal of INDIRECT records.
membersFromDeletedGroup.removeAll(membersFromParentGroup);
// so we need to log them to auditer
for (Member m : membersFromDeletedGroup) {
notifyMemberRemovalFromGroup(sess, parentGroup, m);
getPerunBl().getAuditer().log(sess, new MemberRemovedFromGroupTotally(m, parentGroup));
}
parentGroupId = parentGroup.getParentGroupId();
}
}
use of cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberRemovedFromGroupTotally 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);
}
}
use of cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberRemovedFromGroupTotally in project perun by CESNET.
the class urn_perun_user_attribute_def_virt_studentIdentifiersTest method setUp.
@Before
public void setUp() throws Exception {
setUpUser();
setUpVo();
setUpMember();
setUpGroup();
setUpExtSource();
createUserExtSourceAttributes();
memberAddedEvent = new DirectMemberAddedToGroup(member, group);
memberRemovedEvent = new MemberRemovedFromGroupTotally(member, group);
}
Aggregations