Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Return 404 on unknown validator identifier
iay committed May 12, 2018
1 parent ce59b5f commit 5674c6d
Showing 2 changed files with 18 additions and 2 deletions.
@@ -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);
}

/**
@@ -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.

0 comments on commit 5674c6d

Please sign in to comment.