@GET @Produces(MediaType.APPLICATION_JSON) @Path(value = "/{integrationId}") public List<Exchange> getLogs( @PathParam("integrationId") String integrationId, @QueryParam("from") String from, @QueryParam("limit") Integer requestedLimit ) throws IOException { String path = "/logs/exchanges/" + integrationId; int limit = 10; if( requestedLimit != null ) { limit = requestedLimit; } if( limit > 1000 ) { limit = 1000; // max out to 1000 per request. } GetOptions options = new GetOptions() .order(GetOptions.Order.DESC) // reverse the order since we want most recent exchanges first. .startAfter(from).limitToFirst(limit); // allow paging byte[] data = jsondb.getAsByteArray(path, options); if( data == null ) { return new ArrayList<>(); } return toAPIAPITxLogEntryList(Json.mapper().readTree(data)); }
if( this.options.limitToFirst() !=null ) { if( !newPath.get(0).equals(currentRootField) ) { this.entriesAdded++; currentRootField = newPath.get(0); if( this.entriesAdded > this.options.limitToFirst() ) { close(); return;
if( this.options.limitToFirst() !=null ) { if( !newPath.get(0).equals(currentRootField) ) { this.entriesAdded++; currentRootField = newPath.get(0); if( this.entriesAdded > this.options.limitToFirst() ) { close(); return;
@Test public void testGetLimitDeeper() throws IOException { jsondb.update("/test", mapper.writeValueAsString(map( "user1/value", "test 1", "user2/value", "test 2", "user3/value", "test 3", "user4/value", "test 4", "user5/value", "test 5", "user6/value", "test 6" ))); String json = jsondb.getAsString("/test", new GetOptions().limitToFirst(3)); assertThat(json).isEqualTo("{\"user1\":{\"value\":\"test 1\"},\"user2\":{\"value\":\"test 2\"},\"user3\":{\"value\":\"test 3\"}}"); }
@Test public void testGetLimitDeeper() throws IOException { jsondb.update("/test", mapper.writeValueAsString(map( "user1/value", "test 1", "user2/value", "test 2", "user3/value", "test 3", "user4/value", "test 4", "user5/value", "test 5", "user6/value", "test 6" ))); String json = jsondb.getAsString("/test", new GetOptions().limitToFirst(3)); assertThat(json).isEqualTo("{\"user1\":{\"value\":\"test 1\"},\"user2\":{\"value\":\"test 2\"},\"user3\":{\"value\":\"test 3\"}}"); }
@Test public void testGetLimit() throws IOException { jsondb.set("/test", mapper.writeValueAsString(map( "user1", "test 1", "user2", "test 2", "user3", "test 3", "user4", "test 4", "user5", "test 5", "user6", "test 6" ))); String json = jsondb.getAsString("/test", new GetOptions().limitToFirst(3)); assertThat(json).isEqualTo("{\"user1\":\"test 1\",\"user2\":\"test 2\",\"user3\":\"test 3\"}"); }
@Test public void testGetLimit() throws IOException { jsondb.set("/test", mapper.writeValueAsString(map( "user1", "test 1", "user2", "test 2", "user3", "test 3", "user4", "test 4", "user5", "test 5", "user6", "test 6" ))); String json = jsondb.getAsString("/test", new GetOptions().limitToFirst(3)); assertThat(json).isEqualTo("{\"user1\":\"test 1\",\"user2\":\"test 2\",\"user3\":\"test 3\"}"); }