Search in sources :

Example 1 with VoCreated

use of cz.metacentrum.perun.audit.events.VoManagerEvents.VoCreated in project perun by CESNET.

the class VosManagerBlImpl method createVo.

@Override
public Vo createVo(PerunSession sess, Vo vo) throws VoExistsException {
    // Create entries in the DB and Grouper
    vo = getVosManagerImpl().createVo(sess, vo);
    getPerunBl().getAuditer().log(sess, new VoCreated(vo));
    User user = sess.getPerunPrincipal().getUser();
    // set creator as VO manager
    if (user != null) {
        try {
            AuthzResolverBlImpl.setRole(sess, user, vo, Role.VOADMIN);
            log.debug("User {} added like administrator to VO {}", user, vo);
        } catch (AlreadyAdminException ex) {
            throw new ConsistencyErrorException("Add manager to newly created VO failed because there is a particular manager already assigned", ex);
        } catch (RoleCannotBeManagedException e) {
            throw new InternalErrorException(e);
        }
    } else {
        log.error("Can't set VO manager during creating of the VO. User from perunSession is null. {} {}", vo, sess);
    }
    try {
        // Create group containing VO members
        Group members = new Group(VosManager.MEMBERS_GROUP, VosManager.MEMBERS_GROUP_DESCRIPTION + " for VO " + vo.getName());
        getPerunBl().getGroupsManagerBl().createGroup(sess, vo, members);
        log.debug("Members group created, vo '{}'", vo);
    } catch (GroupExistsException e) {
        throw new ConsistencyErrorException("Group already exists", e);
    }
    // create empty application form
    getVosManagerImpl().createApplicationForm(sess, vo);
    log.info("Vo {} created", vo);
    return vo;
}
Also used : Group(cz.metacentrum.perun.core.api.Group) ConsistencyErrorException(cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException) User(cz.metacentrum.perun.core.api.User) RichUser(cz.metacentrum.perun.core.api.RichUser) GroupExistsException(cz.metacentrum.perun.core.api.exceptions.GroupExistsException) VoCreated(cz.metacentrum.perun.audit.events.VoManagerEvents.VoCreated) RoleCannotBeManagedException(cz.metacentrum.perun.core.api.exceptions.RoleCannotBeManagedException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) AlreadyAdminException(cz.metacentrum.perun.core.api.exceptions.AlreadyAdminException)

Aggregations

VoCreated (cz.metacentrum.perun.audit.events.VoManagerEvents.VoCreated)1 Group (cz.metacentrum.perun.core.api.Group)1 RichUser (cz.metacentrum.perun.core.api.RichUser)1 User (cz.metacentrum.perun.core.api.User)1 AlreadyAdminException (cz.metacentrum.perun.core.api.exceptions.AlreadyAdminException)1 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)1 GroupExistsException (cz.metacentrum.perun.core.api.exceptions.GroupExistsException)1 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)1 RoleCannotBeManagedException (cz.metacentrum.perun.core.api.exceptions.RoleCannotBeManagedException)1