Search in sources :

Example 1 with DestinationAlreadyAssignedException

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

the class ServicesManagerBlImpl method addDestination.

public Destination addDestination(PerunSession sess, Service service, Facility facility, Destination destination) throws InternalErrorException, DestinationAlreadyAssignedException {
    if (!getServicesManagerImpl().destinationExists(sess, destination)) {
        try {
            //Try to get the destination without id
            destination = getServicesManagerImpl().getDestination(sess, destination.getDestination(), destination.getType());
        } catch (DestinationNotExistsException ex) {
            try {
                destination = createDestination(sess, destination);
            } catch (DestinationExistsException e) {
                throw new ConsistencyErrorException(e);
            }
        }
    }
    if (getServicesManagerImpl().destinationExists(sess, service, facility, destination))
        throw new DestinationAlreadyAssignedException(destination);
    getServicesManagerImpl().addDestination(sess, service, facility, destination);
    getPerunBl().getAuditer().log(sess, "{} added to {} and {}.", destination, service, facility);
    return destination;
}
Also used : ConsistencyErrorException(cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException) DestinationNotExistsException(cz.metacentrum.perun.core.api.exceptions.DestinationNotExistsException) DestinationExistsException(cz.metacentrum.perun.core.api.exceptions.DestinationExistsException) DestinationAlreadyAssignedException(cz.metacentrum.perun.core.api.exceptions.DestinationAlreadyAssignedException)

Aggregations

ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)1 DestinationAlreadyAssignedException (cz.metacentrum.perun.core.api.exceptions.DestinationAlreadyAssignedException)1 DestinationExistsException (cz.metacentrum.perun.core.api.exceptions.DestinationExistsException)1 DestinationNotExistsException (cz.metacentrum.perun.core.api.exceptions.DestinationNotExistsException)1