Пример #1
0
  @GET
  @Path("/entries")
  @Produces({
    ExtraMediaType.TEXT_HTML,
    MediaType.APPLICATION_JSON,
    ExtraMediaType.TEXT_YAML,
    ExtraMediaType.TEXT_CSV,
    ExtraMediaType.TEXT_TSV,
    ExtraMediaType.TEXT_TTL
  })
  public EntryListView entries(
      @QueryParam("start") Optional<Integer> optionalStart,
      @QueryParam("limit") Optional<Integer> optionalLimit) {
    int totalEntries = entryDAO.getTotalEntries();
    NewPagination newPagination = new NewPagination(optionalStart, optionalLimit, totalEntries);

    Collection<Entry> entries = entryDAO.getEntries(newPagination.start, newPagination.limit);

    setHeaders(newPagination);

    return viewFactory.getEntriesView(entries, newPagination);
  }
Пример #2
0
 @GET
 @Path("/entry/{entry-number}")
 @Produces({
   ExtraMediaType.TEXT_HTML,
   MediaType.APPLICATION_JSON,
   ExtraMediaType.TEXT_YAML,
   ExtraMediaType.TEXT_CSV,
   ExtraMediaType.TEXT_TSV,
   ExtraMediaType.TEXT_TTL
 })
 public AttributionView findByEntryNumber(@PathParam("entry-number") int entryNumber) {
   Optional<Entry> entry = entryDAO.findByEntryNumber(entryNumber);
   return entry.map(viewFactory::getEntryView).orElseThrow(NotFoundException::new);
 }