Search in sources :

Example 1 with IgnoreFilter

use of net.ripe.rpki.validator3.domain.IgnoreFilter in project rpki-validator-3 by RIPE-NCC.

the class IgnoreFilterService method execute.

public long execute(@Valid AddIgnoreFilter command) {
    IgnoreFilter ignoreFilter = new IgnoreFilter();
    if (command.getAsn() != null) {
        ignoreFilter.setAsn(Asn.parse(command.getAsn()).longValue());
    }
    ignoreFilter.setPrefix(command.getPrefix());
    ignoreFilter.setComment(command.getComment());
    return add(ignoreFilter);
}
Also used : IgnoreFilter(net.ripe.rpki.validator3.domain.IgnoreFilter)

Example 2 with IgnoreFilter

use of net.ripe.rpki.validator3.domain.IgnoreFilter in project rpki-validator-3 by RIPE-NCC.

the class RoaPrefixAssertionsController method add.

@PostMapping(consumes = { Api.API_MIME_TYPE, "application/json" })
public ResponseEntity<ApiResponse<RoaPrefixAssertionResource>> add(@RequestBody @Valid ApiCommand<AddRoaPrefixAssertion> command) {
    final long id = roaPrefixAssertionsService.execute(command.getData());
    final RoaPrefixAssertion ignoreFilter = roaPrefixAssertions.get(id);
    final Link selfRel = linkTo(methodOn(RoaPrefixAssertionsController.class).get(id)).withSelfRel();
    return ResponseEntity.created(URI.create(selfRel.getHref())).body(ApiResponse.data(toResource(ignoreFilter)));
}
Also used : RoaPrefixAssertion(net.ripe.rpki.validator3.domain.RoaPrefixAssertion) Link(org.springframework.hateoas.Link) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 3 with IgnoreFilter

use of net.ripe.rpki.validator3.domain.IgnoreFilter in project rpki-validator-3 by RIPE-NCC.

the class IgnoreFiltersController method list.

@GetMapping
public ResponseEntity<ApiResponse<Stream<IgnoreFilter>>> 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<net.ripe.rpki.validator3.domain.IgnoreFilter> all = ignoreFilters.all().collect(Collectors.toList());
    int totalSize = all.size();
    final Links links = Paging.links(startFrom, pageSize, totalSize, (sf, ps) -> methodOn(IgnoreFiltersController.class).list(sf, ps, searchString, sortBy, sortDirection));
    return ResponseEntity.ok(ApiResponse.<Stream<IgnoreFilter>>builder().links(links).metadata(Metadata.of(totalSize)).data(all.stream().map(f -> toIgnoreFilter(f))).build());
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) StringUtils(org.apache.commons.lang.StringUtils) RequestParam(org.springframework.web.bind.annotation.RequestParam) Links(org.springframework.hateoas.Links) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ControllerLinkBuilder.methodOn(org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn) Metadata(net.ripe.rpki.validator3.api.Metadata) Sorting(net.ripe.rpki.validator3.api.Sorting) RequestBody(org.springframework.web.bind.annotation.RequestBody) Valid(javax.validation.Valid) Paging(net.ripe.rpki.validator3.api.Paging) ControllerLinkBuilder.linkTo(org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo) Api(net.ripe.rpki.validator3.api.Api) GetMapping(org.springframework.web.bind.annotation.GetMapping) URI(java.net.URI) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) PostMapping(org.springframework.web.bind.annotation.PostMapping) Link(org.springframework.hateoas.Link) ApiError(net.ripe.rpki.validator3.api.ApiError) IgnoreFilters(net.ripe.rpki.validator3.domain.IgnoreFilters) RestController(org.springframework.web.bind.annotation.RestController) Collectors(java.util.stream.Collectors) HttpStatus(org.springframework.http.HttpStatus) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Stream(java.util.stream.Stream) ApiCommand(net.ripe.rpki.validator3.api.ApiCommand) SearchTerm(net.ripe.rpki.validator3.api.SearchTerm) ResponseEntity(org.springframework.http.ResponseEntity) ApiResponse(net.ripe.rpki.validator3.api.ApiResponse) 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 4 with IgnoreFilter

use of net.ripe.rpki.validator3.domain.IgnoreFilter in project rpki-validator-3 by RIPE-NCC.

the class IgnoreFilterService method remove.

public void remove(long ignoreFilterId) {
    IgnoreFilter ignoreFilter = ignoreFilters.get(ignoreFilterId);
    if (ignoreFilter != null) {
        ignoreFilters.remove(ignoreFilter);
        notifyListeners();
    }
}
Also used : IgnoreFilter(net.ripe.rpki.validator3.domain.IgnoreFilter)

Example 5 with IgnoreFilter

use of net.ripe.rpki.validator3.domain.IgnoreFilter in project rpki-validator-3 by RIPE-NCC.

the class BgpPreviewServiceTest method ignoreFilter.

private IgnoreFilter ignoreFilter(Long asn, String prefix) {
    IgnoreFilter f = new IgnoreFilter();
    f.setAsn(asn);
    f.setPrefix(prefix);
    return f;
}
Also used : IgnoreFilter(net.ripe.rpki.validator3.domain.IgnoreFilter)

Aggregations

IgnoreFilter (net.ripe.rpki.validator3.domain.IgnoreFilter)3 Link (org.springframework.hateoas.Link)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 URI (java.net.URI)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)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 Paging (net.ripe.rpki.validator3.api.Paging)1 SearchTerm (net.ripe.rpki.validator3.api.SearchTerm)1 Sorting (net.ripe.rpki.validator3.api.Sorting)1 IgnoreFilters (net.ripe.rpki.validator3.domain.IgnoreFilters)1 RoaPrefixAssertion (net.ripe.rpki.validator3.domain.RoaPrefixAssertion)1 StringUtils (org.apache.commons.lang.StringUtils)1