Example usage for io.vertx.core Future succeededFuture

List of usage examples for io.vertx.core Future succeededFuture

Introduction

In this page you can find the example usage for io.vertx.core Future succeededFuture.

Prototype

static <T> Future<T> succeededFuture(T result) 

Source Link

Document

Created a succeeded future with the specified result.

Usage

From source file:io.hijynx.ensemble.identity.RoleServiceVertxEBProxy.java

License:Apache License

public RoleService deassign(String roleId, String userId, Handler<AsyncResult<Void>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*from  w ww  .  j  a  v  a 2s.  co m*/
    JsonObject _json = new JsonObject();
    _json.put("roleId", roleId);
    _json.put("userId", userId);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "deassign");
    _vertx.eventBus().<Void>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}

From source file:io.hijynx.ensemble.identity.UserServiceVertxEBProxy.java

License:Apache License

public UserService addUser(User user, Handler<AsyncResult<Void>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//from   w  w w  .j a  v  a2s  .co m
    JsonObject _json = new JsonObject();
    _json.put("user", user == null ? null : user.toJson());
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "addUser");
    _vertx.eventBus().<Void>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}

From source file:io.hijynx.ensemble.identity.UserServiceVertxEBProxy.java

License:Apache License

public UserService retrieveUser(String id, Handler<AsyncResult<User>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*  www. j a va  2s.  co m*/
    JsonObject _json = new JsonObject();
    _json.put("id", id);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "retrieveUser");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(
                    Future.succeededFuture(res.result().body() == null ? null : new User(res.result().body())));
        }
    });
    return this;
}

From source file:io.hijynx.ensemble.identity.UserServiceVertxEBProxy.java

License:Apache License

public UserService retrieveByUsername(String username, Handler<AsyncResult<User>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*ww w  .j a v  a  2  s. c o  m*/
    JsonObject _json = new JsonObject();
    _json.put("username", username);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "retrieveByUsername");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(
                    Future.succeededFuture(res.result().body() == null ? null : new User(res.result().body())));
        }
    });
    return this;
}

From source file:io.hijynx.ensemble.identity.UserServiceVertxEBProxy.java

License:Apache License

public UserService retrieveAllUsers(Handler<AsyncResult<List<User>>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*from ww  w  .  ja v a 2 s .  c om*/
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "retrieveAllUsers");
    _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body().stream()
                    .map(o -> o instanceof Map ? new User(new JsonObject((Map) o)) : new User((JsonObject) o))
                    .collect(Collectors.toList())));
        }
    });
    return this;
}

From source file:io.hijynx.ensemble.identity.UserServiceVertxEBProxy.java

License:Apache License

public UserService updateUser(User user, Handler<AsyncResult<User>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*ww w  .  j a va2  s  . c o  m*/
    JsonObject _json = new JsonObject();
    _json.put("user", user == null ? null : user.toJson());
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "updateUser");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(
                    Future.succeededFuture(res.result().body() == null ? null : new User(res.result().body())));
        }
    });
    return this;
}

From source file:io.hijynx.ensemble.identity.UserServiceVertxEBProxy.java

License:Apache License

public UserService deleteUser(String id, Handler<AsyncResult<Void>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//from  w w w  .  j  a va  2s . c o  m
    JsonObject _json = new JsonObject();
    _json.put("id", id);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "deleteUser");
    _vertx.eventBus().<Void>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}

From source file:io.hijynx.ensemble.identity.UserServiceVertxEBProxy.java

License:Apache License

public UserService updatePassword(String userId, String password, Handler<AsyncResult<Void>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//from   www .j  av a2 s . c o m
    JsonObject _json = new JsonObject();
    _json.put("userId", userId);
    _json.put("password", password);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "updatePassword");
    _vertx.eventBus().<Void>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}

From source file:io.knotx.adapter.AbstractAdapterProxy.java

License:Apache License

@Override
public void process(AdapterRequest request, Handler<AsyncResult<AdapterResponse>> result) {
    processRequest(request).subscribe(adapterResponse -> result.handle(Future.succeededFuture(adapterResponse)),
            error -> {//  w w w . j a  v  a 2 s. c o  m
                LOGGER.error("Error happened during Adapter Request processing", error);
                result.handle(Future.succeededFuture(getErrorResponse(error)));
            });
}

From source file:io.knotx.knot.AbstractKnotProxy.java

License:Apache License

@Override
public void process(KnotContext knotContext, Handler<AsyncResult<KnotContext>> result) {
    if (shouldProcess(knotContext)) {
        processRequest(knotContext).subscribe(ctx -> result.handle(Future.succeededFuture(ctx)), error -> {
            LOGGER.error("Error happened during Knot Context processing", error);
            result.handle(Future.succeededFuture(processError(knotContext, error)));
        });/* w w w . j  av  a  2s  .  c  om*/
    } else {
        knotContext.setTransition(StringUtils.isBlank(knotContext.getTransition()) ? DEFAULT_TRANSITION
                : knotContext.getTransition());
        result.handle(Future.succeededFuture(knotContext));
    }
}