Search in sources :

Example 1 with SponsorshipRemoved

use of cz.metacentrum.perun.audit.events.MembersManagerEvents.SponsorshipRemoved in project perun by CESNET.

the class MembersManagerBlImpl method unsetSponsorshipForMember.

@Override
public Member unsetSponsorshipForMember(PerunSession session, Member sponsoredMember) throws MemberNotSponsoredException {
    if (!sponsoredMember.isSponsored()) {
        throw new MemberNotSponsoredException(sponsoredMember + " is not sponsored member!");
    }
    // set member to be sponsored
    List<User> sponsors = getPerunBl().getUsersManagerBl().getSponsors(session, sponsoredMember);
    sponsoredMember = getMembersManagerImpl().unsetSponsorshipForMember(session, sponsoredMember);
    getPerunBl().getAuditer().log(session, new SponsoredMemberUnset(sponsoredMember));
    for (User sponsor : sponsors) {
        getPerunBl().getAuditer().log(session, new SponsorshipRemoved(sponsoredMember, sponsor));
    }
    return sponsoredMember;
}
Also used : User(cz.metacentrum.perun.core.api.User) RichUser(cz.metacentrum.perun.core.api.RichUser) SponsoredMemberUnset(cz.metacentrum.perun.audit.events.MembersManagerEvents.SponsoredMemberUnset) MemberNotSponsoredException(cz.metacentrum.perun.core.api.exceptions.MemberNotSponsoredException) SponsorshipRemoved(cz.metacentrum.perun.audit.events.MembersManagerEvents.SponsorshipRemoved)

Example 2 with SponsorshipRemoved

use of cz.metacentrum.perun.audit.events.MembersManagerEvents.SponsorshipRemoved in project perun by CESNET.

the class MembersManagerBlImpl method removeSponsor.

@Override
public void removeSponsor(PerunSession sess, Member sponsoredMember, User sponsorToRemove) {
    getMembersManagerImpl().removeSponsor(sess, sponsoredMember, sponsorToRemove);
    getPerunBl().getAuditer().log(sess, new SponsorshipRemoved(sponsoredMember, sponsorToRemove));
    // check if the user was the last sponsor
    Vo vo = getMemberVo(sess, sponsoredMember);
    boolean hasSponsor = false;
    for (User sponsor : getPerunBl().getUsersManagerBl().getSponsors(sess, sponsoredMember)) {
        if (getPerunBl().getVosManagerBl().isUserInRoleForVo(sess, sponsor, Role.SPONSOR, vo, true)) {
            hasSponsor = true;
            break;
        }
    }
    if (!hasSponsor) {
        processMemberAfterRemovingLastSponsor(sess, sponsoredMember, vo);
    }
}
Also used : User(cz.metacentrum.perun.core.api.User) RichUser(cz.metacentrum.perun.core.api.RichUser) Vo(cz.metacentrum.perun.core.api.Vo) BanOnVo(cz.metacentrum.perun.core.api.BanOnVo) SponsorshipRemoved(cz.metacentrum.perun.audit.events.MembersManagerEvents.SponsorshipRemoved)

Aggregations

SponsorshipRemoved (cz.metacentrum.perun.audit.events.MembersManagerEvents.SponsorshipRemoved)2 RichUser (cz.metacentrum.perun.core.api.RichUser)2 User (cz.metacentrum.perun.core.api.User)2 SponsoredMemberUnset (cz.metacentrum.perun.audit.events.MembersManagerEvents.SponsoredMemberUnset)1 BanOnVo (cz.metacentrum.perun.core.api.BanOnVo)1 Vo (cz.metacentrum.perun.core.api.Vo)1 MemberNotSponsoredException (cz.metacentrum.perun.core.api.exceptions.MemberNotSponsoredException)1