Search in sources :

Example 1 with DestinationExistsException

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

the class ServicesManagerBlImpl method createDestination.

public Destination createDestination(PerunSession sess, Destination destination) throws DestinationExistsException {
    if (getServicesManagerImpl().destinationExists(sess, destination))
        throw new DestinationExistsException(destination);
    destination = getServicesManagerImpl().createDestination(sess, destination);
    getPerunBl().getAuditer().log(sess, new DestinationCreated(destination));
    return destination;
}
Also used : DestinationCreated(cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationCreated) DestinationExistsException(cz.metacentrum.perun.core.api.exceptions.DestinationExistsException)

Example 2 with DestinationExistsException

use of cz.metacentrum.perun.core.api.exceptions.DestinationExistsException 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;
}
Also used : FreeDenialServiceOnDestination(cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.FreeDenialServiceOnDestination) BanServiceOnDestination(cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.BanServiceOnDestination) RichDestination(cz.metacentrum.perun.core.api.RichDestination) Destination(cz.metacentrum.perun.core.api.Destination) FreeAllDenialsOnDestination(cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.FreeAllDenialsOnDestination) 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) DestinationAddedToServiceAndFacility(cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationAddedToServiceAndFacility)

Example 3 with DestinationExistsException

use of cz.metacentrum.perun.core.api.exceptions.DestinationExistsException 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;
}
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) DestinationAddedToServiceAndFacility(cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationAddedToServiceAndFacility)

Example 4 with DestinationExistsException

use of cz.metacentrum.perun.core.api.exceptions.DestinationExistsException 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;
}
Also used : FreeDenialServiceOnDestination(cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.FreeDenialServiceOnDestination) BanServiceOnDestination(cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.BanServiceOnDestination) RichDestination(cz.metacentrum.perun.core.api.RichDestination) Destination(cz.metacentrum.perun.core.api.Destination) FreeAllDenialsOnDestination(cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.FreeAllDenialsOnDestination) ConsistencyErrorException(cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException) DestinationNotExistsException(cz.metacentrum.perun.core.api.exceptions.DestinationNotExistsException) RequiredAttributeRemovedFromService(cz.metacentrum.perun.audit.events.ServicesManagerEvents.RequiredAttributeRemovedFromService) DestinationRemovedFromService(cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationRemovedFromService) PropagationPlannedOnFacilityAndService(cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.PropagationPlannedOnFacilityAndService) PropagationPlannedOnService(cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.PropagationPlannedOnService) RequiredAttributesRemovedFromService(cz.metacentrum.perun.audit.events.ServicesManagerEvents.RequiredAttributesRemovedFromService) DestinationsRemovedFromService(cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationsRemovedFromService) ForcePropagationOnService(cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.ForcePropagationOnService) Service(cz.metacentrum.perun.core.api.Service) AttributesAddedAsRequiredToService(cz.metacentrum.perun.audit.events.ServicesManagerEvents.AttributesAddedAsRequiredToService) ForcePropagationOnFacilityAndService(cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.ForcePropagationOnFacilityAndService) AllRequiredAttributesRemovedFromService(cz.metacentrum.perun.audit.events.ServicesManagerEvents.AllRequiredAttributesRemovedFromService) AttributeAddedAsRequiredToService(cz.metacentrum.perun.audit.events.ServicesManagerEvents.AttributeAddedAsRequiredToService) DestinationExistsException(cz.metacentrum.perun.core.api.exceptions.DestinationExistsException) DestinationAddedToServiceAndFacility(cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationAddedToServiceAndFacility)

Aggregations

DestinationExistsException (cz.metacentrum.perun.core.api.exceptions.DestinationExistsException)4 DestinationAddedToServiceAndFacility (cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationAddedToServiceAndFacility)3 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)3 DestinationNotExistsException (cz.metacentrum.perun.core.api.exceptions.DestinationNotExistsException)3 BanServiceOnDestination (cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.BanServiceOnDestination)2 FreeAllDenialsOnDestination (cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.FreeAllDenialsOnDestination)2 FreeDenialServiceOnDestination (cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.FreeDenialServiceOnDestination)2 Destination (cz.metacentrum.perun.core.api.Destination)2 RichDestination (cz.metacentrum.perun.core.api.RichDestination)2 ForcePropagationOnFacilityAndService (cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.ForcePropagationOnFacilityAndService)1 ForcePropagationOnService (cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.ForcePropagationOnService)1 PropagationPlannedOnFacilityAndService (cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.PropagationPlannedOnFacilityAndService)1 PropagationPlannedOnService (cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.PropagationPlannedOnService)1 AllRequiredAttributesRemovedFromService (cz.metacentrum.perun.audit.events.ServicesManagerEvents.AllRequiredAttributesRemovedFromService)1 AttributeAddedAsRequiredToService (cz.metacentrum.perun.audit.events.ServicesManagerEvents.AttributeAddedAsRequiredToService)1 AttributesAddedAsRequiredToService (cz.metacentrum.perun.audit.events.ServicesManagerEvents.AttributesAddedAsRequiredToService)1 DestinationCreated (cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationCreated)1 DestinationRemovedFromService (cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationRemovedFromService)1 DestinationsRemovedFromService (cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationsRemovedFromService)1 RequiredAttributeRemovedFromService (cz.metacentrum.perun.audit.events.ServicesManagerEvents.RequiredAttributeRemovedFromService)1