use of cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationAddedToServiceAndFacility in project perun by CESNET.
the class ServicesManagerBlImpl method addDestination.
@Override
public Destination addDestination(PerunSession sess, Service service, Facility facility, Destination destination) throws DestinationAlreadyAssignedException {
if (!getServicesManagerImpl().destinationExists(sess, destination)) {
try {
// Try to get the destination without id
Destination existingDestination = getServicesManagerImpl().getDestination(sess, destination.getDestination(), destination.getType());
// pass new propagation type from API to object retrieved from DB,
// since it always contains PARALLEL type
existingDestination.setPropagationType(destination.getPropagationType());
destination = existingDestination;
} 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, new DestinationAddedToServiceAndFacility(destination, service, facility));
return destination;
}
use of cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationAddedToServiceAndFacility in project perun by CESNET.
the class ServicesManagerBlImpl method addDestinationEvenIfAlreadyExists.
private Destination addDestinationEvenIfAlreadyExists(PerunSession sess, Service service, Facility facility, Destination destination) {
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, new DestinationAddedToServiceAndFacility(destination, service, facility));
return destination;
}
use of cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationAddedToServiceAndFacility in project perun by CESNET.
the class ServicesManagerBlImpl method addDestination.
@Override
public Destination addDestination(PerunSession perunSession, List<Service> services, Facility facility, Destination destination) {
if (!getServicesManagerImpl().destinationExists(perunSession, destination)) {
try {
// Try to get the destination without id
Destination existingDestination = getServicesManagerImpl().getDestination(perunSession, destination.getDestination(), destination.getType());
// pass new propagation type from API to object retrieved from DB,
// since it always contains PARALLEL type
existingDestination.setPropagationType(destination.getPropagationType());
destination = existingDestination;
} 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, new DestinationAddedToServiceAndFacility(destination, s, facility));
}
}
return destination;
}
Aggregations