use of cz.metacentrum.perun.core.api.exceptions.DestinationNotExistsException in project perun by CESNET.
the class ServicesManagerBlImpl method addDestinationEvenIfAlreadyExists.
private Destination addDestinationEvenIfAlreadyExists(PerunSession sess, Service service, Facility facility, Destination destination) throws InternalErrorException {
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) {
//This is ok, destination already exists so take it from DB
try {
destination = getServicesManagerImpl().getDestination(sess, destination.getDestination(), destination.getType());
} catch (DestinationNotExistsException exep) {
throw new ConsistencyErrorException("Destination seems to exists and not exists in the same time. There is some other problem." + exep);
}
}
}
}
//if destination is already assigned, do not add message to the log and only return it back
if (getServicesManagerImpl().destinationExists(sess, service, facility, destination))
return destination;
getServicesManagerImpl().addDestination(sess, service, facility, destination);
getPerunBl().getAuditer().log(sess, "{} added to {} and {}.", destination, service, facility);
return destination;
}
use of cz.metacentrum.perun.core.api.exceptions.DestinationNotExistsException 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;
}
use of cz.metacentrum.perun.core.api.exceptions.DestinationNotExistsException in project perun by CESNET.
the class ServicesManagerBlImpl method addDestination.
public Destination addDestination(PerunSession perunSession, List<Service> services, Facility facility, Destination destination) throws InternalErrorException, DestinationAlreadyAssignedException {
if (!getServicesManagerImpl().destinationExists(perunSession, destination)) {
try {
//Try to get the destination without id
destination = getServicesManagerImpl().getDestination(perunSession, destination.getDestination(), destination.getType());
} catch (DestinationNotExistsException ex) {
try {
destination = createDestination(perunSession, destination);
} catch (DestinationExistsException e) {
throw new ConsistencyErrorException(e);
}
}
}
for (Service s : services) {
if (!getServicesManagerImpl().destinationExists(perunSession, s, facility, destination)) {
getServicesManagerImpl().addDestination(perunSession, s, facility, destination);
getPerunBl().getAuditer().log(perunSession, "{} added to {} and {}.", destination, s, facility);
}
}
return destination;
}
use of cz.metacentrum.perun.core.api.exceptions.DestinationNotExistsException in project perun by CESNET.
the class ServicesManagerBlImpl method removeDestination.
public void removeDestination(PerunSession sess, Service service, Facility facility, Destination destination) throws InternalErrorException, DestinationAlreadyRemovedException {
if (!getServicesManagerImpl().destinationExists(sess, destination)) {
try {
//Try to get the destination without id
destination = getServicesManagerImpl().getDestination(sess, destination.getDestination(), destination.getType());
} catch (DestinationNotExistsException ex) {
throw new DestinationAlreadyRemovedException(destination);
}
}
getServicesManagerImpl().removeDestination(sess, service, facility, destination);
//TODO remove destination from destination taable if is not used anymore
getPerunBl().getAuditer().log(sess, "{} removed from {} and {}.", destination, service, facility);
}
Aggregations