Example usage for io.vertx.core.json JsonObject put

List of usage examples for io.vertx.core.json JsonObject put

Introduction

In this page you can find the example usage for io.vertx.core.json JsonObject put.

Prototype

public JsonObject put(String key, Object value) 

Source Link

Document

Put an Object into the JSON object with the specified key.

Usage

From source file:com.github.meshuga.vertx.neo4j.rbac.auth.AuthServiceVertxEBProxy.java

License:Apache License

public void hasPermission(String userName, String permission, Handler<AsyncResult<Boolean>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;//  w  w w . ja  v a2  s. c  o  m
    }
    JsonObject _json = new JsonObject();
    _json.put("userName", userName);
    _json.put("permission", permission);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "hasPermission");
    _vertx.eventBus().<Boolean>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.glt.cronjob.JobServiceVertxEBProxy.java

License:Apache License

public JobService schedule(JsonObject jobDescriptor, Handler<AsyncResult<Boolean>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*from   www . j  a va2  s  . com*/
    JsonObject _json = new JsonObject();
    _json.put("jobDescriptor", jobDescriptor);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "schedule");
    _vertx.eventBus().<Boolean>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:com.glt.cronjob.JobServiceVertxEBProxy.java

License:Apache License

public JobService unschedule(JsonObject jobDescriptor, Handler<AsyncResult<Boolean>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//from  w w w .  j a va 2s  .co m
    JsonObject _json = new JsonObject();
    _json.put("jobDescriptor", jobDescriptor);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "unschedule");
    _vertx.eventBus().<Boolean>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:com.glt.rest.client.RestServiceVertxEBProxy.java

License:Apache License

public void get(JsonObject command, Handler<AsyncResult<String>> asyncHandler) {
    if (closed) {
        asyncHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*ww w.  jav  a2  s .  c  om*/
    }
    JsonObject _json = new JsonObject();
    _json.put("command", command);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "get");
    _vertx.eventBus().<String>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            asyncHandler.handle(Future.failedFuture(res.cause()));
        } else {
            asyncHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.glt.rest.client.RestServiceVertxEBProxy.java

License:Apache License

public void post(JsonObject command, Handler<AsyncResult<String>> asyncHandler) {
    if (closed) {
        asyncHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;//from   w  w  w. j  a  v  a2 s. c o  m
    }
    JsonObject _json = new JsonObject();
    _json.put("command", command);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "post");
    _vertx.eventBus().<String>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            asyncHandler.handle(Future.failedFuture(res.cause()));
        } else {
            asyncHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.glt.rest.client.RestServiceVertxEBProxy.java

License:Apache License

public void put(JsonObject command, Handler<AsyncResult<String>> asyncHandler) {
    if (closed) {
        asyncHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;// w  w  w  .j av  a  2 s. c  o m
    }
    JsonObject _json = new JsonObject();
    _json.put("command", command);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "put");
    _vertx.eventBus().<String>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            asyncHandler.handle(Future.failedFuture(res.cause()));
        } else {
            asyncHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.glt.rest.client.RestServiceVertxEBProxy.java

License:Apache License

public void delete(JsonObject command, Handler<AsyncResult<String>> asyncHandler) {
    if (closed) {
        asyncHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*from  w w w  .  ja  v  a 2s  .  c  o m*/
    }
    JsonObject _json = new JsonObject();
    _json.put("command", command);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "delete");
    _vertx.eventBus().<String>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            asyncHandler.handle(Future.failedFuture(res.cause()));
        } else {
            asyncHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.glt.rest.client.RestServiceVertxEBProxy.java

License:Apache License

public void getJson(JsonObject command, Handler<AsyncResult<JsonObject>> asyncHandler) {
    if (closed) {
        asyncHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;// ww w  .ja  v  a 2 s  .c o m
    }
    JsonObject _json = new JsonObject();
    _json.put("command", command);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "getJson");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            asyncHandler.handle(Future.failedFuture(res.cause()));
        } else {
            asyncHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.glt.rest.client.RestServiceVertxEBProxy.java

License:Apache License

public void postJson(JsonObject command, Handler<AsyncResult<JsonObject>> asyncHandler) {
    if (closed) {
        asyncHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;//  ww  w. ja va2s . c o m
    }
    JsonObject _json = new JsonObject();
    _json.put("command", command);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "postJson");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            asyncHandler.handle(Future.failedFuture(res.cause()));
        } else {
            asyncHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.glt.rest.client.RestServiceVertxEBProxy.java

License:Apache License

public void putJson(JsonObject command, Handler<AsyncResult<JsonObject>> asyncHandler) {
    if (closed) {
        asyncHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*from  w  ww  . j ava2s  .  c  o  m*/
    }
    JsonObject _json = new JsonObject();
    _json.put("command", command);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "putJson");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            asyncHandler.handle(Future.failedFuture(res.cause()));
        } else {
            asyncHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}