diff --git a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/controller/PipelineExceptionHandler.java b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/controller/PipelineExceptionHandler.java index c03c5637b..c9d32f0fc 100644 --- a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/controller/PipelineExceptionHandler.java +++ b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/controller/PipelineExceptionHandler.java @@ -17,4 +17,9 @@ public class PipelineExceptionHandler extends ResponseEntityExceptionHandler { public ResponseEntity handleConflict(RuntimeException ex, WebRequest request) { return handleExceptionInternal(ex, ex.getMessage(), new HttpHeaders(), HttpStatus.BAD_REQUEST, request); } + + @ExceptionHandler(value = {PipelineDoesNotExistException.class}) + public ResponseEntity handleNotFound(RuntimeException ex, WebRequest request) { + return handleExceptionInternal(ex, ex.getMessage(), new HttpHeaders(), HttpStatus.NOT_FOUND, request); + } } diff --git a/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/exception/PipelineDoesNotExistException.java b/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/exception/PipelineDoesNotExistException.java new file mode 100644 index 000000000..fe6622bd2 --- /dev/null +++ b/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/exception/PipelineDoesNotExistException.java @@ -0,0 +1,14 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio.exception; + +public class PipelineDoesNotExistException extends PipelineException { + private final String pipeline; + + public PipelineDoesNotExistException(String pipeline) { + this.pipeline = pipeline; + } + + @Override + public String getMessage() { + return "Pipeline \"%s\": No pipeline like that exists".formatted(pipeline); + } +} diff --git a/ldi-orchestrator/ldio-connectors/ldio-http-in/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioHttpInController.java b/ldi-orchestrator/ldio-connectors/ldio-http-in/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioHttpInController.java index 38720495a..357ad3cf8 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-http-in/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioHttpInController.java +++ b/ldi-orchestrator/ldio-connectors/ldio-http-in/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioHttpInController.java @@ -2,6 +2,7 @@ import be.vlaanderen.informatievlaanderen.ldes.ldio.event.HttpInPipelineCreatedEvent; import be.vlaanderen.informatievlaanderen.ldes.ldio.events.PipelineDeletedEvent; +import be.vlaanderen.informatievlaanderen.ldes.ldio.exception.PipelineDoesNotExistException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.event.EventListener; @@ -29,7 +30,7 @@ ResponseEntity processInput(@RequestHeader("Content-Type") String conten logIncomingRequest(contentType, contentLength, pipeline); ofNullable(httpInProcesses.get(pipeline)) - .orElseThrow(() -> new IllegalArgumentException("Not a valid pipeline")) + .orElseThrow(() -> new PipelineDoesNotExistException(pipeline)) .processInput(content, contentType); return ResponseEntity.accepted().build(); }