Search in sources :

Example 1 with DestinationAddedToServiceAndFacility

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;
}
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 2 with DestinationAddedToServiceAndFacility

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;
}
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 3 with DestinationAddedToServiceAndFacility

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;
}
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

DestinationAddedToServiceAndFacility (cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationAddedToServiceAndFacility)3 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)3 DestinationExistsException (cz.metacentrum.perun.core.api.exceptions.DestinationExistsException)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 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 RequiredAttributesRemovedFromService (cz.metacentrum.perun.audit.events.ServicesManagerEvents.RequiredAttributesRemovedFromService)1