use of org.springframework.dao.DuplicateKeyException in project perun by CESNET.
the class GroupsManagerImpl method addMember.
public Member addMember(PerunSession sess, Group group, Member member, MembershipType type, int sourceGroupId) throws InternalErrorException, AlreadyMemberException, WrongAttributeValueException, WrongReferenceAttributeValueException {
member.setMembershipType(type);
member.setSourceGroupId(sourceGroupId);
try {
jdbc.update("insert into groups_members (group_id, member_id, created_by, created_at, modified_by, modified_at, created_by_uid, modified_by_uid, membership_type, source_group_id) " + "values (?,?,?," + Compatibility.getSysdate() + ",?," + Compatibility.getSysdate() + ",?,?,?,?)", group.getId(), member.getId(), sess.getPerunPrincipal().getActor(), sess.getPerunPrincipal().getActor(), sess.getPerunPrincipal().getUserId(), sess.getPerunPrincipal().getUserId(), type.getCode(), sourceGroupId);
} catch (DuplicateKeyException ex) {
throw new AlreadyMemberException(member);
} catch (RuntimeException ex) {
throw new InternalErrorException(ex);
}
return member;
}
Aggregations