Search in sources :

Example 1 with VoExistsException

use of cz.metacentrum.perun.core.api.exceptions.VoExistsException in project perun by CESNET.

the class VosManagerImpl method createVo.

public Vo createVo(PerunSession sess, Vo vo) throws VoExistsException, InternalErrorException {
    Utils.notNull(vo.getName(), "vo.getName()");
    Utils.notNull(vo.getShortName(), "vo.getShortName()");
    // Check if the Vo already exists
    if (this.voExists(sess, vo))
        throw new VoExistsException(vo.toString());
    // Get VO ID
    int voId;
    try {
        voId = Utils.getNewId(jdbc, "vos_id_seq");
        jdbc.update("insert into vos(id, name, short_name, created_by,modified_by, created_by_uid, modified_by_uid) values (?,?,?,?,?,?,?)", voId, vo.getName(), vo.getShortName(), sess.getPerunPrincipal().getActor(), sess.getPerunPrincipal().getActor(), sess.getPerunPrincipal().getUserId(), sess.getPerunPrincipal().getUserId());
    } catch (RuntimeException e) {
        throw new InternalErrorException(e);
    }
    // set assigned id
    vo.setId(voId);
    return vo;
}
Also used : InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) VoExistsException(cz.metacentrum.perun.core.api.exceptions.VoExistsException)

Aggregations

InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)1 VoExistsException (cz.metacentrum.perun.core.api.exceptions.VoExistsException)1