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;
}
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;
}
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);
}
}
Aggregations