List of usage examples for io.vertx.core Future succeededFuture
static <T> Future<T> succeededFuture(T result)
From source file:org.etourdot.vertx.marklogic.impl.MarkLogicManagementImpl.java
License:Open Source License
void getDefaultHost(Handler<AsyncResult<Host>> resultHandler) { HostsOptions hostsOptions = new HostsOptions(); getHosts(hostsOptions, r -> resultHandler.handle(Future.succeededFuture(new Host().name(r.result())))); }
From source file:org.etourdot.vertx.marklogic.impl.MarkLogicManagementImpl.java
License:Open Source License
void databaseOperation(DatabasesOptions databasesOptions, Handler<AsyncResult<String>> resultHandler) { requireNonNull(databasesOptions, "databaseOption cannot be null"); requireNonNull(resultHandler, "resultHandler cannot be null"); MarkLogicRequest marklogicRequest = restService.newMarklogicRequest(); String serverHttpString = getUrlWithInstance(MANAGE_DATABASES, databasesOptions); marklogicRequest.post(serverHttpString).withBody(databasesOptions.getOperation()).execute(response -> { if (HttpResponseStatus.ACCEPTED.code() == response.statusCode()) { resultHandler.handle(Future.succeededFuture(response.statusMessage())); } else {//from w w w. ja va 2 s .c o m resultHandler.handle(Future.failedFuture(response.statusMessage())); } }); }
From source file:org.etourdot.vertx.marklogic.impl.MarkLogicManagementImpl.java
License:Open Source License
private void getNameViewConfig(Handler<AsyncResult<JsonObject>> resultHandler, NameViewOptions option, String baseUrl) {/* w w w. j a va 2 s. c om*/ MarkLogicRequest marklogicRequest = restService.newMarklogicRequest(); String serverHttpString = getUrlWithInstance(baseUrl, option); marklogicRequest.get(serverHttpString); if (option.hasView()) { marklogicRequest.addParam(VIEW, option.getView()); } marklogicRequest.execute(response -> { if (HttpResponseStatus.OK.code() == response.statusCode()) { response.contentHandler( buffer -> resultHandler.handle(Future.succeededFuture(buffer.toJsonObject()))); } else if (HttpResponseStatus.FOUND.code() == response.statusCode()) { // uri in Location header resultHandler.handle(Future.succeededFuture()); } else { resultHandler.handle(Future.failedFuture(response.statusMessage())); } }); }
From source file:org.etourdot.vertx.marklogic.impl.MarkLogicManagementImpl.java
License:Open Source License
private void getNameViewProperties(Handler<AsyncResult<JsonObject>> resultHandler, NameViewOptions option, String baseUrl) {//from w ww. j a v a 2 s. c o m MarkLogicRequest marklogicRequest = restService.newMarklogicRequest(); String serverHttpString = getUrlWithInstance(baseUrl, option) + "/properties"; marklogicRequest.get(serverHttpString).execute(response -> { if (HttpResponseStatus.OK.code() == response.statusCode()) { response.contentHandler( buffer -> resultHandler.handle(Future.succeededFuture(buffer.toJsonObject()))); } else { resultHandler.handle(Future.failedFuture(response.statusMessage())); } }); }
From source file:org.etourdot.vertx.marklogic.impl.MarkLogicSearchImpl.java
License:Open Source License
void search(SearchOptions searchOptions, Handler<AsyncResult<JsonObject>> resultHandler) { requireNonNull(searchOptions, "searchOptions cannot be null"); requireNonNull(resultHandler, "resultHandler cannot be null"); MarkLogicRequest marklogicRequest = restService.newMarklogicRequest(); if (searchOptions.hasQbe()) { marklogicRequest.get(QBE_URL); } else {//from w ww . j a v a2 s . c o m marklogicRequest.get(SEARCH_URL); } putSearchOptions(searchOptions, marklogicRequest); marklogicRequest.execute(response -> { if (HttpResponseStatus.OK.code() == response.statusCode()) { response.contentHandler( buffer -> resultHandler.handle(Future.succeededFuture(buffer.toJsonObject()))); //response.bodyHandler(buffer -> resultHandler.handle(Future.succeededFuture(buffer.toJsonObject()))); } }); }
From source file:org.etourdot.vertx.marklogic.impl.MarkLogicSearchImpl.java
License:Open Source License
void searchDocuments(SearchOptions searchOptions, Handler<AsyncResult<JsonArray>> resultHandler) { requireNonNull(searchOptions, "searchOptions cannot be null"); requireNonNull(resultHandler, "resultHandler cannot be null"); doSeachDocPage(searchOptions, marklogicResponse -> { JsonArray documents = new JsonArray(); if (HttpResponseStatus.OK.code() == marklogicResponse.statusCode()) { for (Document document : ((MultiPartResponse) marklogicResponse).getDocuments()) { documents.add(document.toJson()); }/* w w w. j a v a2 s. co m*/ resultHandler.handle(Future.succeededFuture(documents)); } if (HttpResponseStatus.NOT_FOUND.code() == marklogicResponse.statusCode()) { resultHandler.handle( Future.failedFuture(new ResourceNotFoundException(marklogicResponse.statusMessage()))); } resultHandler.handle(Future.succeededFuture()); }); }
From source file:org.etourdot.vertx.marklogic.impl.MarkLogicSearchImpl.java
License:Open Source License
void searchBatch(SearchOptions searchOptions, Handler<AsyncResult<JsonObject>> resultHandler) { requireNonNull(searchOptions, "searchOptions cannot be null"); requireNonNull(resultHandler, "resultHandler cannot be null"); doSeachDocPage(searchOptions, marklogicResponse -> { if (HttpResponseStatus.OK.code() == marklogicResponse.statusCode()) { SearchResponse searchResponse = (SearchResponse) marklogicResponse; for (Document document : searchResponse.getDocuments()) { resultHandler.handle(Future.succeededFuture(document.toJson())); }/*from ww w.jav a 2 s. co m*/ if (searchResponse.getStart() + searchResponse.getNbResults() < searchResponse.getEstimate()) { searchOptions.start(searchResponse.getStart() + searchResponse.getPageLen()); searchBatch(searchOptions, resultHandler); } } if (HttpResponseStatus.NOT_FOUND.code() == marklogicResponse.statusCode()) { resultHandler.handle( Future.failedFuture(new ResourceNotFoundException(marklogicResponse.statusMessage()))); } }); }
From source file:org.folio.auth.login_module.impl.DummyAuthSource.java
@Override public Future<AuthResult> authenticate(JsonObject credentials, String tenant) { AuthResult authResult = new AuthResult(); authResult.setSuccess(true);/*from w ww .j a v a2s . com*/ authResult.setUser("dummy"); return Future.succeededFuture(authResult); }
From source file:org.folio.auth.login_module.impl.DummyAuthSource.java
@Override public Future<Boolean> addAuth(JsonObject credentials, JsonObject metadata, String tenant) { return Future.succeededFuture(true); }
From source file:org.folio.auth.login_module.impl.DummyAuthSource.java
@Override public Future<Boolean> updateAuth(JsonObject credentials, JsonObject metadata, String tenant) { return Future.succeededFuture(true); }