default byte[] getAsByteArray(String path) { return getAsByteArray(path, null); }
default byte[] getAsByteArray(String path) { return getAsByteArray(path, null); }
/** * @param path - the object or value to get * @param options options that control formatting of the result. * @return the json result or null if the path does not exist */ default String getAsString(String path, GetOptions options) { byte[] data = getAsByteArray(path, options); if( data==null ) { return null; } return new String(data, StandardCharsets.UTF_8); }
/** * @param path - the object or value to get * @param options options that control formatting of the result. * @return the json result or null if the path does not exist */ default String getAsString(String path, GetOptions options) { byte[] data = getAsByteArray(path, options); if( data==null ) { return null; } return new String(data, StandardCharsets.UTF_8); }
private <T> T dbGet(Class<T> type, String path, GetOptions options) throws IOException { byte[] data = jsonDB.getAsByteArray(path, options); if (data == null) { return null; } return Json.mapper().readValue(data, type); }
@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)); }
@Override public T fetch(String id) { try { String dbPath = getCollectionPath()+"/:"+id; byte[] json = jsondb.getAsByteArray(dbPath); if( json==null || json.length == 0 ) { return null; } return Json.mapper().readValue(json, getType()); } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") RuntimeException|IOException e) { throw SyndesisServerException.launderThrowable(e); } }
@Override public T fetch(String id) { try { String dbPath = getCollectionPath()+"/:"+id; byte[] json = jsondb.getAsByteArray(dbPath); if( json==null || json.length == 0 ) { return null; } return Json.reader().forType(getType()).readValue(json); } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") RuntimeException|IOException e) { throw SyndesisServerException.launderThrowable(e); } }
byte[] json = jsondb.getAsByteArray(getCollectionPath(), options); ListResult<T> result; if( json!=null && json.length > 0 ) {
byte[] json = jsondb.getAsByteArray(getCollectionPath(), options); ListResult<T> result; if( json!=null && json.length > 0 ) {