diff --git a/src/main/java/uk/org/iay/incommon/validator/api/ValidatorsApiController.java b/src/main/java/uk/org/iay/incommon/validator/api/ValidatorsApiController.java index 8d93967..3f747e0 100644 --- a/src/main/java/uk/org/iay/incommon/validator/api/ValidatorsApiController.java +++ b/src/main/java/uk/org/iay/incommon/validator/api/ValidatorsApiController.java @@ -92,11 +92,17 @@ public ResponseEntity<List<Status>> validate( final String validatorId, @ApiParam(value = "The metadata to be validated.", required = true) @Valid @RequestBody final String metadata) throws ApiException { + + // Fetch the required validator. + final ValidatorCollection.Entry entry = validatorCollection.getEntry(validatorId); + if (entry == null) { + throw new NotFoundException("unknown validator identifier '" + validatorId + "'"); + } + final List<Status> statuses = new ArrayList<>(); statuses.add(makeStatus(StatusEnum.ERROR, "component", "message")); statuses.add(makeStatus(StatusEnum.WARNING, "component/sub", "another message")); - //return new ResponseEntity<List<Status>>(statuses, HttpStatus.NOT_IMPLEMENTED); - throw new NotFoundException("bad validator identifier '" + validatorId + "'"); + return new ResponseEntity<List<Status>>(statuses, HttpStatus.NOT_IMPLEMENTED); } /** diff --git a/src/main/java/uk/org/iay/incommon/validator/context/ValidatorCollection.java b/src/main/java/uk/org/iay/incommon/validator/context/ValidatorCollection.java index ab3c6c7..310a302 100644 --- a/src/main/java/uk/org/iay/incommon/validator/context/ValidatorCollection.java +++ b/src/main/java/uk/org/iay/incommon/validator/context/ValidatorCollection.java @@ -100,6 +100,16 @@ public List<Entry> getEntries() { return entries; } + /** + * Get the {@link Entry} with the given identifier, if any. + * + * @param id the identifier for the required {@link Entry} + * @return the {@link Entry}, or <code>null</code> + */ + public Entry getEntry(final String id) { + return byId.get(id); + } + /** * Build an {@link ApplicationContext} from the indicated configuration, * and add it to the collection.