use of net.ripe.rpki.validator3.api.validationruns.ValidationCheckResource in project rpki-validator-3 by RIPE-NCC.
the class TrustAnchorController method validationChecks.
@GetMapping(path = "/{id}/validation-checks")
public ResponseEntity<ApiResponse<Stream<ValidationCheckResource>>> validationChecks(@PathVariable long id, @RequestParam(name = "startFrom", defaultValue = "0") int startFrom, @RequestParam(name = "pageSize", defaultValue = "20") int pageSize, @RequestParam(name = "search", required = false) String searchString, @RequestParam(name = "sortBy", defaultValue = "location") String sortBy, @RequestParam(name = "sortDirection", defaultValue = "asc") String sortDirection, Locale locale) {
final SearchTerm searchTerm = StringUtils.isNotBlank(searchString) ? new SearchTerm(searchString) : null;
final Sorting sorting = Sorting.parse(sortBy, sortDirection);
final Paging paging = Paging.of(startFrom, pageSize);
int totalCount = validationRunRepository.countValidationChecksForValidationRun(id, searchTerm);
Stream<ValidationCheckResource> checks = validationRunRepository.findValidationChecksForValidationRun(id, paging, searchTerm, sorting).map(check -> ValidationCheckResource.of(check, messageSource.getMessage(check, locale)));
Links links = Paging.links(startFrom, pageSize, totalCount, (sf, ps) -> methodOn(TrustAnchorController.class).validationChecks(id, sf, ps, searchString, sortBy, sortDirection, locale));
return ResponseEntity.ok(ApiResponse.<Stream<ValidationCheckResource>>builder().links(links).data(checks).metadata(Metadata.of(totalCount)).build());
}
Aggregations