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

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

Introduction

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

Prototype

public JsonObject() 

Source Link

Document

Create a new, empty instance

Usage

From source file:io.apiman.gateway.platforms.vertx3.common.config.VertxEngineConfig.java

License:Apache License

protected Map<String, String> getConfig(JsonObject obj, String prefix) {
    // First, check whether there's something interesting in System properties.
    Map<String, String> mfp = getConfigMapFromProperties("apiman-gateway." + prefix);

    if (mfp != null && !mfp.isEmpty()) { // TODO
        return mfp;
    }/*from ww  w. java 2 s.c  o m*/
    return toFlatStringMap(obj.getJsonObject(prefix, new JsonObject()).getJsonObject(GATEWAY_CONFIG));
}

From source file:io.apiman.gateway.platforms.vertx3.components.jdbc.VertxJdbcClientImpl.java

License:Apache License

/**
 * Translate our abstracted {@link JdbcOptionsBean} into a Vert.x-specific config.
 *
 * We are assuming that the user is using HikariCP.
 *///from   w  w  w.j a v a  2 s  .  c  o m
@SuppressWarnings("nls")
protected JsonObject parseConfig(JdbcOptionsBean config) {
    JsonObject jsonConfig = new JsonObject();
    nullSafePut(jsonConfig, "provider_class", HikariCPDataSourceProvider.class.getCanonicalName()); // Vert.x thing
    nullSafePut(jsonConfig, "jdbcUrl", config.getJdbcUrl());
    nullSafePut(jsonConfig, "username", config.getUsername());
    nullSafePut(jsonConfig, "password", config.getPassword());
    nullSafePut(jsonConfig, "autoCommit", config.isAutoCommit());
    nullSafePut(jsonConfig, "connectionTimeout", config.getConnectionTimeout());
    nullSafePut(jsonConfig, "idleTimeout", config.getIdleTimeout());
    nullSafePut(jsonConfig, "maxLifetime", config.getMaxLifetime());
    nullSafePut(jsonConfig, "minimumIdle", config.getMinimumIdle());
    nullSafePut(jsonConfig, "maximumPoolSize", config.getMaximumPoolSize());
    nullSafePut(jsonConfig, "poolName", config.getPoolName());

    JsonObject dsProperties = new JsonObject();

    for (Entry<String, Object> entry : config.getDsProperties().entrySet()) {
        dsProperties.put(entry.getKey(), entry.getValue());
    }

    jsonConfig.put("properties", dsProperties);
    return jsonConfig;
}

From source file:io.apiman.gateway.platforms.vertx3.io.VertxApiRequest.java

License:Apache License

public JsonObject toJson() {
    JsonObject asJson = new JsonObject();
    VertxApiRequestConverter.toJson(this, asJson);
    return asJson;
}

From source file:io.apiman.gateway.platforms.vertx3.io.VertxApiRequestConverter.java

License:Apache License

public static void toJson(VertxApiRequest obj, JsonObject json) {
    if (obj.getApiKey() != null) {
        json.put("apiKey", obj.getApiKey());
    }/*from ww  w  .  j av  a 2s.c om*/
    if (obj.getDestination() != null) {
        json.put("destination", obj.getDestination());
    }
    if (obj.getHeaders() != null) {
        JsonObject map = new JsonObject();
        obj.getHeaders().forEach((pair) -> map.put(pair.getKey(), pair.getValue()));
        json.put("headers", map);
    }
    if (obj.getQueryParams() != null) {
        JsonObject map = new JsonObject();
        obj.getQueryParams().forEach((pair) -> map.put(pair.getKey(), pair.getValue()));
        json.put("queryParams", map);
    }
    if (obj.getRawRequest() != null) {
        json.put("rawRequest", obj.getRawRequest());
    }
    if (obj.getRemoteAddr() != null) {
        json.put("remoteAddr", obj.getRemoteAddr());
    }
    if (obj.getApiId() != null) {
        json.put("serviceId", obj.getApiId());
    }
    if (obj.getApiOrgId() != null) {
        json.put("serviceOrgId", obj.getApiOrgId());
    }
    if (obj.getApiVersion() != null) {
        json.put("serviceVersion", obj.getApiVersion());
    }
    json.put("transportSecure", obj.isTransportSecure());
    if (obj.getType() != null) {
        json.put("type", obj.getType());
    }
}

From source file:io.apiman.gateway.platforms.vertx3.io.VertxApiResponse.java

License:Apache License

public JsonObject toJson() {
    JsonObject asJson = new JsonObject();
    VertxApiResponseConverter.toJson(this, asJson);
    return asJson;
}

From source file:io.apiman.gateway.platforms.vertx3.io.VertxApiResponseConverter.java

License:Apache License

public static void toJson(VertxApiResponse obj, JsonObject json) {
    if (obj.getAttributes() != null) {
        JsonObject map = new JsonObject();
        obj.getAttributes().forEach((key, value) -> map.put(key, value));
        json.put("attributes", map);
    }//from  w  w w . j a va 2s .co m
    json.put("code", obj.getCode());
    if (obj.getHeaders() != null) {
        JsonObject map = new JsonObject();
        obj.getHeaders().forEach((pair) -> map.put(pair.getKey(), pair.getValue()));
        json.put("headers", map);
    }
    if (obj.getMessage() != null) {
        json.put("message", obj.getMessage());
    }
}

From source file:io.apiman.gateway.platforms.vertx3.io.VertxPolicyFailure.java

License:Apache License

public JsonObject toJson() {
    JsonObject asJson = new JsonObject();
    VertxPolicyFailureConverter.toJson(this, asJson);
    return asJson;
}

From source file:io.apiman.gateway.platforms.vertx3.io.VertxPolicyFailureConverter.java

License:Apache License

public static void toJson(VertxPolicyFailure obj, JsonObject json) {
    json.put("failureCode", obj.getFailureCode());
    if (obj.getHeaders() != null) {
        JsonObject map = new JsonObject();
        obj.getHeaders().forEach((pair) -> map.put(pair.getKey(), pair.getValue()));
        json.put("headers", map);
    }/*w w  w . jav  a2 s  .c  o  m*/
    if (obj.getMessage() != null) {
        json.put("message", obj.getMessage());
    }
    if (obj.getRaw() != null) {
        json.put("raw", obj.getRaw());
    }
    json.put("responseCode", obj.getResponseCode());
    if (obj.getType() != null) {
        json.put("type", obj.getType().name());
    }
}

From source file:io.apiman.gateway.platforms.vertx3.io.VertxServiceRequest.java

License:Apache License

public JsonObject toJson() {
    JsonObject asJson = new JsonObject();
    VertxServiceRequestConverter.toJson(this, asJson);
    return asJson;
}

From source file:io.apiman.gateway.platforms.vertx3.io.VertxServiceRequestConverter.java

License:Apache License

public static void toJson(VertxServiceRequest obj, JsonObject json) {
    if (obj.getApiKey() != null) {
        json.put("apiKey", obj.getApiKey());
    }//from  ww  w.  ja  va  2 s  .c  om
    if (obj.getDestination() != null) {
        json.put("destination", obj.getDestination());
    }
    if (obj.getHeaders() != null) {
        JsonObject map = new JsonObject();
        obj.getHeaders().forEach((key, value) -> map.put(key, value));
        json.put("headers", map);
    }
    if (obj.getQueryParams() != null) {
        JsonObject map = new JsonObject();
        obj.getQueryParams().forEach((key, value) -> map.put(key, value));
        json.put("queryParams", map);
    }
    if (obj.getRawRequest() != null) {
        json.put("rawRequest", obj.getRawRequest());
    }
    if (obj.getRemoteAddr() != null) {
        json.put("remoteAddr", obj.getRemoteAddr());
    }
    if (obj.getServiceId() != null) {
        json.put("serviceId", obj.getServiceId());
    }
    if (obj.getServiceOrgId() != null) {
        json.put("serviceOrgId", obj.getServiceOrgId());
    }
    if (obj.getServiceVersion() != null) {
        json.put("serviceVersion", obj.getServiceVersion());
    }
    json.put("transportSecure", obj.isTransportSecure());
    if (obj.getType() != null) {
        json.put("type", obj.getType());
    }
}