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:io.github.pflima92.plyshare.common.configuration.ConfigurationProviderVertxEBProxy.java

License:Apache License

public ConfigurationProvider getConfiguration(String name, Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*w ww.ja v a  2s  . co  m*/
    JsonObject _json = new JsonObject();
    _json.put("name", name);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "getConfiguration");
    _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()));
        }
    });
    return this;
}

From source file:io.github.pflima92.plyshare.common.discovery.HeartbeatConverter.java

License:Apache License

public static void toJson(Heartbeat obj, JsonObject json) {
    json.put("healthy", obj.isHealthy());
    if (obj.getRecord() != null) {
        json.put("record", obj.getRecord().toJson());
    }//from  w  w w  .  ja va  2 s . c  o m
}

From source file:io.github.pflima92.plyshare.common.discovery.RecordMetadataConverter.java

License:Apache License

public static void toJson(RecordMetadata obj, JsonObject json) {
    json.put("healthCheck", obj.isHealthCheck());
    if (obj.getHealthPathCheck() != null) {
        json.put("healthPathCheck", obj.getHealthPathCheck());
    }//from w w  w .  j  a  va  2 s  . c  o  m
    if (obj.getName() != null) {
        json.put("name", obj.getName());
    }
}

From source file:io.github.pflima92.plyshare.common.MicroserviceOptionsConverter.java

License:Apache License

public static void toJson(MicroserviceOptions obj, JsonObject json) {
    if (obj.getAddress() != null) {
        json.put("address", obj.getAddress());
    }//from   w ww.  j  av  a 2 s .co m
    if (obj.getCircuitBreakerOptions() != null) {
        json.put("circuitBreakerOptions", obj.getCircuitBreakerOptions().toJson());
    }
    if (obj.getConfig() != null) {
        json.put("config", obj.getConfig());
    }
    json.put("healthCheck", obj.isHealthCheck());
    if (obj.getHealthPathCheck() != null) {
        json.put("healthPathCheck", obj.getHealthPathCheck());
    }
    if (obj.getName() != null) {
        json.put("name", obj.getName());
    }
    json.put("port", obj.getPort());
    if (obj.getServiceDiscoveryOptions() != null) {
        json.put("serviceDiscoveryOptions", obj.getServiceDiscoveryOptions().toJson());
    }
}

From source file:io.github.pflima92.plyshare.microservice.utility.MailServiceVertxEBProxy.java

License:Apache License

public MailService send(MailMessage message, Handler<AsyncResult<MailResult>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//from  w w w . j  av  a2s .c  om
    JsonObject _json = new JsonObject();
    _json.put("message", message == null ? null : message.toJson());
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "send");
    _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 MailResult(res.result().body())));
        }
    });
    return this;
}

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

License:Apache License

public static void toJson(Privilege obj, JsonObject json) {
    if (obj.getDescription() != null) {
        json.put("description", obj.getDescription());
    }/*from www  .j  av a 2s  . c o  m*/
    if (obj.getPrivilegeCreate() != null) {
        json.put("privilegeCreate", obj.getPrivilegeCreate());
    }
    if (obj.getPrivilegeDelete() != null) {
        json.put("privilegeDelete", obj.getPrivilegeDelete());
    }
    if (obj.getPrivilegeId() != null) {
        json.put("privilegeId", obj.getPrivilegeId());
    }
    if (obj.getPrivilegeName() != null) {
        json.put("privilegeName", obj.getPrivilegeName());
    }
    if (obj.getPrivilegeRead() != null) {
        json.put("privilegeRead", obj.getPrivilegeRead());
    }
    if (obj.getPrivilegeUpdate() != null) {
        json.put("privilegeUpdate", obj.getPrivilegeUpdate());
    }
    if (obj.getTarget() != null) {
        json.put("target", obj.getTarget());
    }
}

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

License:Apache License

public PrivilegeService addPrivilege(Privilege privilege, Handler<AsyncResult<Void>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//from   www  . j av  a  2 s  . c o m
    JsonObject _json = new JsonObject();
    _json.put("privilege", privilege == null ? null : privilege.toJson());
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "addPrivilege");
    _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.PrivilegeServiceVertxEBProxy.java

License:Apache License

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

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

License:Apache License

public PrivilegeService retrievePrivilegeByName(String privilegeName,
        Handler<AsyncResult<Privilege>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*from ww  w .  j  a  va2  s .  c  o m*/
    JsonObject _json = new JsonObject();
    _json.put("privilegeName", privilegeName);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "retrievePrivilegeByName");
    _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 Privilege(res.result().body())));
        }
    });
    return this;
}

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

License:Apache License

public PrivilegeService updatePrivilege(Privilege privilege, Handler<AsyncResult<Privilege>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//from  ww w  .  j a  v a2s.c o m
    JsonObject _json = new JsonObject();
    _json.put("privilege", privilege == null ? null : privilege.toJson());
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "updatePrivilege");
    _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 Privilege(res.result().body())));
        }
    });
    return this;
}