Search in sources :

Example 1 with ServiceAlreadyBannedException

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

the class ServicesManagerImpl method blockServiceOnDestination.

@SuppressWarnings("ConstantConditions")
@Override
public void blockServiceOnDestination(PerunSession sess, int serviceId, int destinationId) throws ServiceAlreadyBannedException {
    try {
        int newBanId = Utils.getNewId(jdbc, "service_denials_id_seq");
        jdbc.update("insert into service_denials(id, destination_id, service_id, created_by, modified_by, created_by_uid, modified_by_uid) values (?,?,?,?,?,?,?)", newBanId, destinationId, serviceId, sess.getPerunPrincipal().getActor(), sess.getPerunPrincipal().getActor(), sess.getPerunPrincipal().getUserId(), sess.getPerunPrincipal().getUserId());
    } catch (DuplicateKeyException ex) {
        throw new ServiceAlreadyBannedException(String.format("Service with id %d is already banned on the destination with id %d", serviceId, destinationId));
    } catch (RuntimeException ex) {
        throw new InternalErrorException(ex);
    }
}
Also used : InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) ServiceAlreadyBannedException(cz.metacentrum.perun.core.api.exceptions.ServiceAlreadyBannedException) DuplicateKeyException(org.springframework.dao.DuplicateKeyException)

Example 2 with ServiceAlreadyBannedException

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

the class ServicesManagerBlImpl method blockAllServicesOnFacility.

@Override
public void blockAllServicesOnFacility(PerunSession sess, Facility facility) {
    List<Service> services = getAssignedServices(sess, facility);
    for (Service service : services) {
        try {
            getServicesManagerImpl().blockServiceOnFacility(sess, service.getId(), facility.getId());
            sess.getPerun().getAuditer().log(sess, new BanServiceOnFacility(service, facility));
        } catch (ServiceAlreadyBannedException e) {
        // we ignore, that service was already blocked
        }
    }
}
Also used : BanServiceOnFacility(cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.BanServiceOnFacility) 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) ServiceAlreadyBannedException(cz.metacentrum.perun.core.api.exceptions.ServiceAlreadyBannedException)

Example 3 with ServiceAlreadyBannedException

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

the class ServicesManagerBlImpl method blockAllServicesOnDestination.

@Override
public void blockAllServicesOnDestination(PerunSession sess, int destinationId) throws PrivilegeException, DestinationNotExistsException {
    List<Service> services = getServicesManagerImpl().getServicesFromDestination(destinationId);
    for (Service service : services) {
        try {
            getServicesManagerImpl().blockServiceOnDestination(sess, service.getId(), destinationId);
            sess.getPerun().getAuditer().log(sess, new BanServiceOnDestination(service, destinationId));
        } catch (ServiceAlreadyBannedException e) {
        // we ignore, that service was already blocked
        }
    }
}
Also used : 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) BanServiceOnDestination(cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.BanServiceOnDestination) ServiceAlreadyBannedException(cz.metacentrum.perun.core.api.exceptions.ServiceAlreadyBannedException)

Aggregations

ServiceAlreadyBannedException (cz.metacentrum.perun.core.api.exceptions.ServiceAlreadyBannedException)3 ForcePropagationOnFacilityAndService (cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.ForcePropagationOnFacilityAndService)2 ForcePropagationOnService (cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.ForcePropagationOnService)2 PropagationPlannedOnFacilityAndService (cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.PropagationPlannedOnFacilityAndService)2 PropagationPlannedOnService (cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.PropagationPlannedOnService)2 AllRequiredAttributesRemovedFromService (cz.metacentrum.perun.audit.events.ServicesManagerEvents.AllRequiredAttributesRemovedFromService)2 AttributeAddedAsRequiredToService (cz.metacentrum.perun.audit.events.ServicesManagerEvents.AttributeAddedAsRequiredToService)2 AttributesAddedAsRequiredToService (cz.metacentrum.perun.audit.events.ServicesManagerEvents.AttributesAddedAsRequiredToService)2 DestinationRemovedFromService (cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationRemovedFromService)2 DestinationsRemovedFromService (cz.metacentrum.perun.audit.events.ServicesManagerEvents.DestinationsRemovedFromService)2 RequiredAttributeRemovedFromService (cz.metacentrum.perun.audit.events.ServicesManagerEvents.RequiredAttributeRemovedFromService)2 RequiredAttributesRemovedFromService (cz.metacentrum.perun.audit.events.ServicesManagerEvents.RequiredAttributesRemovedFromService)2 Service (cz.metacentrum.perun.core.api.Service)2 BanServiceOnDestination (cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.BanServiceOnDestination)1 BanServiceOnFacility (cz.metacentrum.perun.audit.events.GeneralServiceManagerEvents.BanServiceOnFacility)1 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)1 DuplicateKeyException (org.springframework.dao.DuplicateKeyException)1