Search in sources :

Example 1 with MemberRemovedFromGroupTotally

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();
    }
}
Also used : EnrichedGroup(cz.metacentrum.perun.core.api.EnrichedGroup) IndirectMemberRemovedFromGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.IndirectMemberRemovedFromGroup) CandidateGroup(cz.metacentrum.perun.core.api.CandidateGroup) RichGroup(cz.metacentrum.perun.core.api.RichGroup) MemberExpiredInGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberExpiredInGroup) MemberValidatedInGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberValidatedInGroup) DirectMemberRemovedFromGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.DirectMemberRemovedFromGroup) Group(cz.metacentrum.perun.core.api.Group) DirectMemberAddedToGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.DirectMemberAddedToGroup) IndirectMemberAddedToGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.IndirectMemberAddedToGroup) ConsistencyErrorException(cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException) GroupNotExistsException(cz.metacentrum.perun.core.api.exceptions.GroupNotExistsException) ParentGroupNotExistsException(cz.metacentrum.perun.core.api.exceptions.ParentGroupNotExistsException) MemberRemovedFromGroupTotally(cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberRemovedFromGroupTotally) RichMember(cz.metacentrum.perun.core.api.RichMember) Member(cz.metacentrum.perun.core.api.Member)

Example 2 with MemberRemovedFromGroupTotally

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);
    }
}
Also used : DirectMemberRemovedFromGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.DirectMemberRemovedFromGroup) MemberGroupMismatchException(cz.metacentrum.perun.core.api.exceptions.MemberGroupMismatchException) MemberRemovedFromGroupTotally(cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberRemovedFromGroupTotally) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap)

Example 3 with MemberRemovedFromGroupTotally

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);
}
Also used : DirectMemberAddedToGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.DirectMemberAddedToGroup) MemberRemovedFromGroupTotally(cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberRemovedFromGroupTotally) Before(org.junit.Before)

Aggregations

MemberRemovedFromGroupTotally (cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberRemovedFromGroupTotally)3 DirectMemberAddedToGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.DirectMemberAddedToGroup)2 DirectMemberRemovedFromGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.DirectMemberRemovedFromGroup)2 IndirectMemberAddedToGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.IndirectMemberAddedToGroup)1 IndirectMemberRemovedFromGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.IndirectMemberRemovedFromGroup)1 MemberExpiredInGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberExpiredInGroup)1 MemberValidatedInGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberValidatedInGroup)1 CandidateGroup (cz.metacentrum.perun.core.api.CandidateGroup)1 EnrichedGroup (cz.metacentrum.perun.core.api.EnrichedGroup)1 Group (cz.metacentrum.perun.core.api.Group)1 Member (cz.metacentrum.perun.core.api.Member)1 RichGroup (cz.metacentrum.perun.core.api.RichGroup)1 RichMember (cz.metacentrum.perun.core.api.RichMember)1 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)1 GroupNotExistsException (cz.metacentrum.perun.core.api.exceptions.GroupNotExistsException)1 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)1 MemberGroupMismatchException (cz.metacentrum.perun.core.api.exceptions.MemberGroupMismatchException)1 ParentGroupNotExistsException (cz.metacentrum.perun.core.api.exceptions.ParentGroupNotExistsException)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1