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 retrieveRole(String id, Handler<AsyncResult<Role>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//ww 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", "retrieveRole");
    _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 Role(res.result().body())));
        }
    });
    return this;
}

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

License:Apache License

public RoleService retrieveRoleByName(String rolename, Handler<AsyncResult<Role>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//  ww  w. j av a  2s.  co m
    JsonObject _json = new JsonObject();
    _json.put("rolename", rolename);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "retrieveRoleByName");
    _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 Role(res.result().body())));
        }
    });
    return this;
}

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

License:Apache License

public RoleService retrieveAllRoles(Handler<AsyncResult<List<Role>>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }// w w w  .j av  a2s  .  c o  m
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "retrieveAllRoles");
    _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 Role(new JsonObject((Map) o)) : new Role((JsonObject) o))
                    .collect(Collectors.toList())));
        }
    });
    return this;
}

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

License:Apache License

public RoleService updateRole(Role role, Handler<AsyncResult<Role>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/* w  w w .  jav  a 2  s .  c om*/
    JsonObject _json = new JsonObject();
    _json.put("role", role == null ? null : role.toJson());
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "updateRole");
    _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 Role(res.result().body())));
        }
    });
    return this;
}

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

License:Apache License

public RoleService deleteRole(String id, Handler<AsyncResult<Void>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*from  ww  w .jav  a2s  . c o m*/
    JsonObject _json = new JsonObject();
    _json.put("id", id);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "deleteRole");
    _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.RoleServiceVertxEBProxy.java

License:Apache License

public RoleService retrieveAssignedMembers(String roleId, Handler<AsyncResult<List<String>>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*from   w w  w.  j av  a2  s  . com*/
    JsonObject _json = new JsonObject();
    _json.put("roleId", roleId);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "retrieveAssignedMembers");
    _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(convertList(res.result().body().getList())));
        }
    });
    return this;
}

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

License:Apache License

public RoleService retrieveAssignedPrivileges(String roleId, Handler<AsyncResult<List<String>>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*from   www.ja  v  a  2s.  c  om*/
    JsonObject _json = new JsonObject();
    _json.put("roleId", roleId);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "retrieveAssignedPrivileges");
    _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(convertList(res.result().body().getList())));
        }
    });
    return this;
}

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

License:Apache License

public RoleService grant(String roleId, String privilegeId, Handler<AsyncResult<Void>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//  w  ww. j  ava 2 s  .  c o m
    JsonObject _json = new JsonObject();
    _json.put("roleId", roleId);
    _json.put("privilegeId", privilegeId);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "grant");
    _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.RoleServiceVertxEBProxy.java

License:Apache License

public RoleService revoke(String roleId, String privilegeId, Handler<AsyncResult<Void>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*from   ww  w  .  ja va  2 s .  co m*/
    JsonObject _json = new JsonObject();
    _json.put("roleId", roleId);
    _json.put("privilegeId", privilegeId);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "revoke");
    _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.RoleServiceVertxEBProxy.java

License:Apache License

public RoleService assign(String roleId, String userId, Handler<AsyncResult<Void>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*  w  ww . j  av a2 s . c om*/
    JsonObject _json = new JsonObject();
    _json.put("roleId", roleId);
    _json.put("userId", userId);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "assign");
    _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;
}