/** * Get all values for the specified property * @param search the search query * @param path the path * @param property the name of the property * @param response the http response */ private void getPropertyValues(String search, String path, String property, HttpServerResponse response) { final Boolean[] first = {true}; response.setChunked(true); response.write("["); store.rxGetPropertyValues(search, path, property) .flatMapObservable(x -> new RxAsyncCursor<>(x).toObservable()) .subscribe( x -> { if (first[0]) { first[0] = false; } else { response.write(","); } response.write("\"" + StringEscapeUtils.escapeJson(x) + "\""); }, err -> fail(response, err), () -> response .write("]") .setStatusCode(200) .end()); }
/** * Get all values for the specified attribute * @param search the search query * @param path the path * @param attribute the name of the attribute * @param response the http response */ private void getAttributeValues(String search, String path, String attribute, HttpServerResponse response) { final Boolean[] first = {true}; response.setChunked(true); response.write("["); store.rxGetAttributeValues(search, path, attribute) .flatMapObservable(x -> new RxAsyncCursor<>(x).toObservable()) .subscribe( x -> { if (first[0]) { first[0] = false; } else { response.write(","); } response.write("\"" + StringEscapeUtils.escapeJson(x) + "\""); }, err -> fail(response, err), () -> response .write("]") .setStatusCode(200) .end()); }