Search in sources :

Example 1 with MemberNotValidYetException

use of cz.metacentrum.perun.core.api.exceptions.MemberNotValidYetException in project perun by CESNET.

the class MembersManagerBlImpl method disableMember.

@Override
public Member disableMember(PerunSession sess, Member member) throws MemberNotValidYetException {
    if (this.haveStatus(sess, member, Status.DISABLED)) {
        log.debug("Trying to disable member who is already disabled. " + member);
        return member;
    }
    if (this.haveStatus(sess, member, Status.INVALID))
        throw new MemberNotValidYetException(member);
    getMembersManagerImpl().setStatus(sess, member, Status.DISABLED);
    member.setStatus(Status.DISABLED);
    getPerunBl().getAuditer().log(sess, new MemberDisabled(member));
    return member;
}
Also used : MemberNotValidYetException(cz.metacentrum.perun.core.api.exceptions.MemberNotValidYetException) MemberDisabled(cz.metacentrum.perun.audit.events.MembersManagerEvents.MemberDisabled)

Example 2 with MemberNotValidYetException

use of cz.metacentrum.perun.core.api.exceptions.MemberNotValidYetException in project perun by CESNET.

the class MembersManagerBlImpl method suspendMember.

public Member suspendMember(PerunSession sess, Member member) throws InternalErrorException, MemberNotValidYetException {
    if (this.haveStatus(sess, member, Status.SUSPENDED)) {
        log.warn("Trying to suspend member who is already suspended. Suspend operation will be procesed anyway (to be shure)." + member);
    }
    if (this.haveStatus(sess, member, Status.INVALID))
        throw new MemberNotValidYetException(member);
    getMembersManagerImpl().setStatus(sess, member, Status.SUSPENDED);
    member.setStatus(Status.SUSPENDED);
    getPerunBl().getAuditer().log(sess, "{} suspended #{}.", member, Auditer.engineForceKeyword);
    return member;
}
Also used : MemberNotValidYetException(cz.metacentrum.perun.core.api.exceptions.MemberNotValidYetException)

Example 3 with MemberNotValidYetException

use of cz.metacentrum.perun.core.api.exceptions.MemberNotValidYetException in project perun by CESNET.

the class MembersManagerBlImpl method moveMembership.

@Override
public void moveMembership(PerunSession sess, Vo vo, User sourceUser, User targetUser) throws MemberNotExistsException, AlreadyMemberException, ExtendMembershipException {
    Member sourceMember = this.getMemberByUserId(sess, vo, sourceUser.getId());
    List<Group> directGroups = getPerunBl().getGroupsManagerBl().getMemberDirectGroups(sess, sourceMember);
    List<Group> synchronizedGroups = new ArrayList<>();
    try {
        for (Group group : directGroups) {
            Attribute attrSynchronizeEnabled = getPerunBl().getAttributesManagerBl().getAttribute(sess, group, getPerunBl().getGroupsManager().GROUPSYNCHROENABLED_ATTRNAME);
            if ("true".equals(attrSynchronizeEnabled.getValue())) {
                synchronizedGroups.add(group);
            }
        }
    } catch (WrongAttributeAssignmentException | AttributeNotExistsException e) {
        throw new InternalErrorException(e);
    }
    Member targetMember;
    try {
        // create targetMember and add him to all direct groups that are not synchronized
        directGroups.removeAll(synchronizedGroups);
        targetMember = this.createMember(sess, vo, targetUser, directGroups);
    } catch (WrongAttributeValueException | WrongReferenceAttributeValueException e) {
        throw new InternalErrorException(e);
    }
    // add 'members' group to directGroups to move its member-group attributes too
    try {
        directGroups.add(getPerunBl().getGroupsManagerBl().getGroupByName(sess, vo, VosManager.MEMBERS_GROUP));
    } catch (GroupNotExistsException e) {
        throw new InternalErrorException(e);
    }
    moveMembersAttributes(sess, vo, sourceMember, targetMember, directGroups);
    // first validate member to prevent MemberNotValidYetException later
    try {
        this.validateMember(sess, targetMember);
    } catch (WrongAttributeValueException | WrongReferenceAttributeValueException e) {
        throw new InternalErrorException(e);
    }
    if (sourceMember.getStatus() != Status.VALID) {
        try {
            this.setStatus(sess, targetMember, sourceMember.getStatus());
        } catch (WrongAttributeValueException | WrongReferenceAttributeValueException | MemberNotValidYetException e) {
            throw new InternalErrorException(e);
        }
    }
    getMembersManagerImpl().moveMembersApplications(sess, sourceMember, targetMember);
    moveMembersSponsorships(sess, vo, sourceUser, targetUser, sourceMember, targetMember);
    moveMembersBans(sess, sourceMember, targetMember);
    try {
        this.deleteMember(sess, sourceMember);
    } catch (MemberAlreadyRemovedException e) {
        log.warn("Trying to delete already deleted member {}. Exception: {}", sourceMember, e);
    }
}
Also used : Group(cz.metacentrum.perun.core.api.Group) GroupNotExistsException(cz.metacentrum.perun.core.api.exceptions.GroupNotExistsException) ParentGroupNotExistsException(cz.metacentrum.perun.core.api.exceptions.ParentGroupNotExistsException) Attribute(cz.metacentrum.perun.core.api.Attribute) MemberNotValidYetException(cz.metacentrum.perun.core.api.exceptions.MemberNotValidYetException) WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) ArrayList(java.util.ArrayList) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) WrongReferenceAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException) MemberAlreadyRemovedException(cz.metacentrum.perun.core.api.exceptions.MemberAlreadyRemovedException) WrongAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException) RichMember(cz.metacentrum.perun.core.api.RichMember) Member(cz.metacentrum.perun.core.api.Member)

Aggregations

MemberNotValidYetException (cz.metacentrum.perun.core.api.exceptions.MemberNotValidYetException)3 MemberDisabled (cz.metacentrum.perun.audit.events.MembersManagerEvents.MemberDisabled)1 Attribute (cz.metacentrum.perun.core.api.Attribute)1 Group (cz.metacentrum.perun.core.api.Group)1 Member (cz.metacentrum.perun.core.api.Member)1 RichMember (cz.metacentrum.perun.core.api.RichMember)1 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)1 GroupNotExistsException (cz.metacentrum.perun.core.api.exceptions.GroupNotExistsException)1 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)1 MemberAlreadyRemovedException (cz.metacentrum.perun.core.api.exceptions.MemberAlreadyRemovedException)1 ParentGroupNotExistsException (cz.metacentrum.perun.core.api.exceptions.ParentGroupNotExistsException)1 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)1 WrongAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)1 WrongReferenceAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)1 ArrayList (java.util.ArrayList)1