use of cz.metacentrum.perun.core.api.exceptions.MembershipMismatchException in project perun by CESNET.
the class GroupsManagerEntry method addMember.
public void addMember(PerunSession sess, Group group, Member member) throws InternalErrorException, MemberNotExistsException, PrivilegeException, AlreadyMemberException, GroupNotExistsException, WrongAttributeValueException, WrongReferenceAttributeValueException, NotMemberOfParentGroupException, WrongAttributeAssignmentException, AttributeNotExistsException, ExternallyManagedException, GroupOperationsException {
Utils.checkPerunSession(sess);
getGroupsManagerBl().checkGroupExists(sess, group);
getPerunBl().getMembersManagerBl().checkMemberExists(sess, member);
// Authorization
if (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, group) && !AuthzResolver.isAuthorized(sess, Role.GROUPADMIN, group)) {
throw new PrivilegeException(sess, "addMember");
}
// Check if the member and group are from the same VO
if (member.getVoId() != (group.getVoId())) {
throw new MembershipMismatchException("Member and group are form the different VO");
}
// Check if the group is externally synchronized
Attribute attrSynchronizeEnabled = getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GROUPSYNCHROENABLED_ATTRNAME);
if (Objects.equals("true", (String) attrSynchronizeEnabled.getValue())) {
throw new ExternallyManagedException("Adding of member is not allowed. Group is externally managed.");
}
getGroupsManagerBl().addMember(sess, group, member);
}
Aggregations