Search in sources :

Example 1 with ExtSourceAlreadyRemovedException

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

the class ExtSourcesManagerImpl method deleteExtSource.

public void deleteExtSource(PerunSession sess, ExtSource extSource) throws InternalErrorException, ExtSourceAlreadyRemovedException {
    try {
        // Delete associated attributes
        jdbc.update("delete from ext_sources_attributes where ext_sources_id=?", extSource.getId());
        // Delete the external source
        int numAffected = jdbc.update("delete from ext_sources where id=?", extSource.getId());
        if (numAffected == 0)
            throw new ExtSourceAlreadyRemovedException("ExtSource: " + extSource);
    } catch (RuntimeException e) {
        throw new InternalErrorException(e);
    }
}
Also used : ExtSourceAlreadyRemovedException(cz.metacentrum.perun.core.api.exceptions.ExtSourceAlreadyRemovedException) InternalErrorRuntimeException(cz.metacentrum.perun.core.api.exceptions.rt.InternalErrorRuntimeException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException)

Aggregations

ExtSourceAlreadyRemovedException (cz.metacentrum.perun.core.api.exceptions.ExtSourceAlreadyRemovedException)1 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)1 InternalErrorRuntimeException (cz.metacentrum.perun.core.api.exceptions.rt.InternalErrorRuntimeException)1