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