Search in sources :

Example 1 with SearchTerm

use of net.ripe.rpki.validator3.api.SearchTerm in project rpki-validator-3 by RIPE-NCC.

the class BgpPreviewController method list.

@GetMapping(path = "/")
public ResponseEntity<ApiResponse<Stream<BgpPreview>>> list(@RequestParam(name = "startFrom", defaultValue = "0") int startFrom, @RequestParam(name = "pageSize", defaultValue = "20") int pageSize, @RequestParam(name = "search", defaultValue = "", required = false) String searchString, @RequestParam(name = "sortBy", defaultValue = "prefix") String sortBy, @RequestParam(name = "sortDirection", defaultValue = "asc") String sortDirection) {
    final SearchTerm searchTerm = StringUtils.isNotBlank(searchString) ? new SearchTerm(searchString) : null;
    final Sorting sorting = Sorting.parse(sortBy, sortDirection);
    final Paging paging = Paging.of(startFrom, pageSize);
    BgpPreviewService.BgpPreviewResult bgpPreviewResult = bgpPreviewService.find(searchTerm, sorting, paging);
    return ResponseEntity.ok(ApiResponse.<Stream<BgpPreview>>builder().data(bgpPreviewResult.getData().map(entry -> BgpPreview.of(entry.getOrigin().toString(), entry.getPrefix().toString(), entry.getValidity().name()))).metadata(Metadata.of(bgpPreviewResult.getTotalCount())).build());
}
Also used : Paging(net.ripe.rpki.validator3.api.Paging) Stream(java.util.stream.Stream) SearchTerm(net.ripe.rpki.validator3.api.SearchTerm) Sorting(net.ripe.rpki.validator3.api.Sorting) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with SearchTerm

use of net.ripe.rpki.validator3.api.SearchTerm in project rpki-validator-3 by RIPE-NCC.

the class RoaPrefixAssertionsController method list.

@GetMapping
public ResponseEntity<ApiResponse<Stream<RoaPrefixAssertionResource>>> list(@RequestParam(name = "startFrom", defaultValue = "0") int startFrom, @RequestParam(name = "pageSize", defaultValue = "20") int pageSize, @RequestParam(name = "search", defaultValue = "", required = false) String searchString, @RequestParam(name = "sortBy", defaultValue = "prefix") String sortBy, @RequestParam(name = "sortDirection", defaultValue = "asc") String sortDirection) {
    final SearchTerm searchTerm = StringUtils.isNotBlank(searchString) ? new SearchTerm(searchString) : null;
    final Sorting sorting = Sorting.parse(sortBy, sortDirection);
    final Paging paging = Paging.of(startFrom, pageSize);
    final List<RoaPrefixAssertion> matching = roaPrefixAssertions.find(searchTerm, sorting, paging).collect(Collectors.toList());
    int totalSize = (int) roaPrefixAssertions.count(searchTerm);
    final Links links = Paging.links(startFrom, pageSize, totalSize, (sf, ps) -> methodOn(RoaPrefixAssertionsController.class).list(sf, ps, searchString, sortBy, sortDirection));
    return ResponseEntity.ok(ApiResponse.<Stream<RoaPrefixAssertionResource>>builder().links(links).metadata(Metadata.of(totalSize)).data(matching.stream().map(this::toResource)).build());
}
Also used : RoaPrefixAssertion(net.ripe.rpki.validator3.domain.RoaPrefixAssertion) Paging(net.ripe.rpki.validator3.api.Paging) Links(org.springframework.hateoas.Links) SearchTerm(net.ripe.rpki.validator3.api.SearchTerm) Sorting(net.ripe.rpki.validator3.api.Sorting) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 3 with SearchTerm

use of net.ripe.rpki.validator3.api.SearchTerm in project rpki-validator-3 by RIPE-NCC.

the class JPAValidationRuns method validationChecksQuery.

private JPAQuery<ValidationCheck> validationChecksQuery(long validationRunId, SearchTerm searchTerm) {
    QValidationRun latest = new QValidationRun("latest");
    JPQLQuery<Long> validationRunIds = JPAExpressions.select(latest.id.max()).where(latest.status.eq(ValidationRun.Status.SUCCEEDED).and(latest.as(QCertificateTreeValidationRun.class).trustAnchor.id.eq(validationRunId))).groupBy(JPAExpressions.type(latest), latest.as(QTrustAnchorValidationRun.class).trustAnchor, latest.as(QCertificateTreeValidationRun.class).trustAnchor).from(latest);
    return queryFactory.selectFrom(validationCheck).where(validationCheck.validationRun.id.in(validationRunIds).and(toPredicate(searchTerm)));
}
Also used : QTrustAnchorValidationRun(net.ripe.rpki.validator3.domain.querydsl.QTrustAnchorValidationRun) QCertificateTreeValidationRun(net.ripe.rpki.validator3.domain.querydsl.QCertificateTreeValidationRun) QValidationRun(net.ripe.rpki.validator3.domain.querydsl.QValidationRun)

Example 4 with SearchTerm

use of net.ripe.rpki.validator3.api.SearchTerm 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());
}
Also used : Paging(net.ripe.rpki.validator3.api.Paging) Links(org.springframework.hateoas.Links) ValidationCheckResource(net.ripe.rpki.validator3.api.validationruns.ValidationCheckResource) SearchTerm(net.ripe.rpki.validator3.api.SearchTerm) Sorting(net.ripe.rpki.validator3.api.Sorting) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 5 with SearchTerm

use of net.ripe.rpki.validator3.api.SearchTerm in project rpki-validator-3 by RIPE-NCC.

the class RpkiRepositoriesController method list.

@GetMapping
public ResponseEntity<ApiResponse<Stream<RpkiRepositoryResource>>> list(@RequestParam(name = "status", required = false) RpkiRepository.Status status, @RequestParam(name = "ta", required = false) Long taId, @RequestParam(name = "startFrom", defaultValue = "0") int startFrom, @RequestParam(name = "pageSize", defaultValue = "20") int pageSize, @RequestParam(name = "search", defaultValue = "", required = false) String searchString, @RequestParam(name = "sortBy", defaultValue = "location") String sortBy, @RequestParam(name = "sortDirection", defaultValue = "asc") String sortDirection, @RequestParam(name = "hideChildrenOfDownloadedParent", defaultValue = "true") boolean hideChildrenOfDownloadedParent) {
    final SearchTerm searchTerm = StringUtils.isNotBlank(searchString) ? new SearchTerm(searchString) : null;
    final Sorting sorting = Sorting.parse(sortBy, sortDirection);
    final Paging paging = Paging.of(startFrom, pageSize);
    final Stream<RpkiRepository> repositories = rpkiRepositories.findAll(status, taId, hideChildrenOfDownloadedParent, searchTerm, sorting, paging);
    final int totalSize = (int) rpkiRepositories.countAll(status, taId, hideChildrenOfDownloadedParent, searchTerm);
    final Links links = Paging.links(startFrom, pageSize, totalSize, (sf, ps) -> methodOn(RpkiRepositoriesController.class).list(status, taId, sf, ps, searchString, sortBy, sortDirection, hideChildrenOfDownloadedParent));
    final Stream<RpkiRepositoryResource> data = repositories.map(RpkiRepositoryResource::of);
    return ResponseEntity.ok(ApiResponse.<Stream<RpkiRepositoryResource>>builder().data(data).links(links).metadata(Metadata.of(totalSize)).build());
}
Also used : RpkiRepository(net.ripe.rpki.validator3.domain.RpkiRepository) Paging(net.ripe.rpki.validator3.api.Paging) Links(org.springframework.hateoas.Links) SearchTerm(net.ripe.rpki.validator3.api.SearchTerm) Sorting(net.ripe.rpki.validator3.api.Sorting) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

Paging (net.ripe.rpki.validator3.api.Paging)6 SearchTerm (net.ripe.rpki.validator3.api.SearchTerm)6 Sorting (net.ripe.rpki.validator3.api.Sorting)6 GetMapping (org.springframework.web.bind.annotation.GetMapping)6 Links (org.springframework.hateoas.Links)5 Stream (java.util.stream.Stream)2 URI (java.net.URI)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Valid (javax.validation.Valid)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Api (net.ripe.rpki.validator3.api.Api)1 ApiCommand (net.ripe.rpki.validator3.api.ApiCommand)1 ApiError (net.ripe.rpki.validator3.api.ApiError)1 ApiResponse (net.ripe.rpki.validator3.api.ApiResponse)1 Metadata (net.ripe.rpki.validator3.api.Metadata)1 ValidationCheckResource (net.ripe.rpki.validator3.api.validationruns.ValidationCheckResource)1 IgnoreFilters (net.ripe.rpki.validator3.domain.IgnoreFilters)1 RoaPrefixAssertion (net.ripe.rpki.validator3.domain.RoaPrefixAssertion)1 RpkiRepository (net.ripe.rpki.validator3.domain.RpkiRepository)1