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

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

Introduction

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

Prototype

public JsonObject getJsonObject(String key) 

Source Link

Document

Get the JsonObject value with the specified key

Usage

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

License:Apache License

protected String getClassname(JsonObject obj, String prefix) {
    return obj.getJsonObject(prefix).getString(GATEWAY_CLASS);
}

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

License:Apache License

protected JsonObject getConfig(JsonObject obj, String prefix) {
    return obj.getJsonObject(prefix).getJsonObject(GATEWAY_CONFIG);
}

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

License:Apache License

public static void fromJson(JsonObject json, VertxApiRequest obj) {
    if (json.getValue("apiKey") instanceof String) {
        obj.setApiKey((String) json.getValue("apiKey"));
    }//from   ww  w. jav a  2 s . c  o m
    if (json.getValue("destination") instanceof String) {
        obj.setDestination((String) json.getValue("destination"));
    }
    if (json.getValue("headers") instanceof JsonObject) {
        HeaderMap map = new HeaderMap();
        json.getJsonObject("headers").forEach(entry -> {
            if (entry.getValue() instanceof String)
                map.put(entry.getKey(), (String) entry.getValue());
        });
        obj.setHeaders(map);
    }
    if (json.getValue("queryParams") instanceof JsonObject) {
        QueryMap map = new QueryMap();
        json.getJsonObject("queryParams").forEach(entry -> {
            if (entry.getValue() instanceof String)
                map.put(entry.getKey(), (String) entry.getValue());
        });
        obj.setQueryParams(map);
    }
    if (json.getValue("rawRequest") instanceof Object) {
        obj.setRawRequest(json.getValue("rawRequest"));
    }
    if (json.getValue("remoteAddr") instanceof String) {
        obj.setRemoteAddr((String) json.getValue("remoteAddr"));
    }
    if (json.getValue("serviceId") instanceof String) {
        obj.setApiId((String) json.getValue("serviceId"));
    }
    if (json.getValue("serviceOrgId") instanceof String) {
        obj.setApiOrgId((String) json.getValue("serviceOrgId"));
    }
    if (json.getValue("serviceVersion") instanceof String) {
        obj.setApiVersion((String) json.getValue("serviceVersion"));
    }
    if (json.getValue("transportSecure") instanceof Boolean) {
        obj.setTransportSecure((Boolean) json.getValue("transportSecure"));
    }
    if (json.getValue("type") instanceof String) {
        obj.setType((String) json.getValue("type"));
    }
}

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

License:Apache License

public static void fromJson(JsonObject json, VertxApiResponse obj) {
    if (json.getValue("attributes") instanceof JsonObject) {
        java.util.Map<String, java.lang.Object> map = new java.util.LinkedHashMap<>();
        json.getJsonObject("attributes").forEach(entry -> {
            if (entry.getValue() instanceof Object)
                map.put(entry.getKey(), entry.getValue());
        });/*from   w  w  w. j av a  2 s  .c o m*/
        obj.setAttributes(map);
    }
    if (json.getValue("code") instanceof Number) {
        obj.setCode(((Number) json.getValue("code")).intValue());
    }
    if (json.getValue("headers") instanceof JsonObject) {
        HeaderMap map = new HeaderMap();
        json.getJsonObject("headers").forEach(entry -> {
            if (entry.getValue() instanceof String)
                map.put(entry.getKey(), (String) entry.getValue());
        });
        obj.setHeaders(map);
    }
    if (json.getValue("message") instanceof String) {
        obj.setMessage((String) json.getValue("message"));
    }
}

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

License:Apache License

public static void fromJson(JsonObject json, VertxPolicyFailure obj) {
    if (json.getValue("failureCode") instanceof Number) {
        obj.setFailureCode(((Number) json.getValue("failureCode")).intValue());
    }// w w  w.  j a  v  a2s . c o m
    if (json.getValue("headers") instanceof JsonObject) {
        HeaderMap map = new HeaderMap();
        json.getJsonObject("headers").forEach(entry -> {
            if (entry.getValue() instanceof String)
                map.put(entry.getKey(), (String) entry.getValue());
        });
        obj.setHeaders(map);
    }
    if (json.getValue("message") instanceof String) {
        obj.setMessage((String) json.getValue("message"));
    }
    if (json.getValue("raw") instanceof String) {
        obj.setRaw((String) json.getValue("raw"));
    }
    if (json.getValue("responseCode") instanceof Number) {
        obj.setResponseCode(((Number) json.getValue("responseCode")).intValue());
    }
    if (json.getValue("type") instanceof String) {
        obj.setType(io.apiman.gateway.engine.beans.PolicyFailureType.valueOf((String) json.getValue("type")));
    }
}

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

License:Apache License

public static void fromJson(JsonObject json, VertxServiceRequest obj) {
    if (json.getValue("apiKey") instanceof String) {
        obj.setApiKey((String) json.getValue("apiKey"));
    }/*from  ww w. j a v  a 2  s . c  o m*/
    if (json.getValue("destination") instanceof String) {
        obj.setDestination((String) json.getValue("destination"));
    }
    if (json.getValue("headers") instanceof JsonObject) {
        java.util.Map<String, java.lang.String> map = new java.util.LinkedHashMap<>();
        json.getJsonObject("headers").forEach(entry -> {
            if (entry.getValue() instanceof String)
                map.put(entry.getKey(), (String) entry.getValue());
        });
        obj.setHeaders(map);
    }
    if (json.getValue("queryParams") instanceof JsonObject) {
        java.util.Map<String, java.lang.String> map = new java.util.LinkedHashMap<>();
        json.getJsonObject("queryParams").forEach(entry -> {
            if (entry.getValue() instanceof String)
                map.put(entry.getKey(), (String) entry.getValue());
        });
        obj.setQueryParams(map);
    }
    if (json.getValue("rawRequest") instanceof Object) {
        obj.setRawRequest(json.getValue("rawRequest"));
    }
    if (json.getValue("remoteAddr") instanceof String) {
        obj.setRemoteAddr((String) json.getValue("remoteAddr"));
    }
    if (json.getValue("serviceId") instanceof String) {
        obj.setServiceId((String) json.getValue("serviceId"));
    }
    if (json.getValue("serviceOrgId") instanceof String) {
        obj.setServiceOrgId((String) json.getValue("serviceOrgId"));
    }
    if (json.getValue("serviceVersion") instanceof String) {
        obj.setServiceVersion((String) json.getValue("serviceVersion"));
    }
    if (json.getValue("transportSecure") instanceof Boolean) {
        obj.setTransportSecure((Boolean) json.getValue("transportSecure"));
    }
    if (json.getValue("type") instanceof String) {
        obj.setType((String) json.getValue("type"));
    }
}

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

License:Apache License

public static void fromJson(JsonObject json, VertxServiceResponse obj) {
    if (json.getValue("attributes") instanceof JsonObject) {
        java.util.Map<String, java.lang.Object> map = new java.util.LinkedHashMap<>();
        json.getJsonObject("attributes").forEach(entry -> {
            if (entry.getValue() instanceof Object)
                map.put(entry.getKey(), entry.getValue());
        });/* ww w. j ava  2 s  . c  om*/
        obj.setAttributes(map);
    }
    if (json.getValue("code") instanceof Number) {
        obj.setCode(((Number) json.getValue("code")).intValue());
    }
    if (json.getValue("headers") instanceof JsonObject) {
        java.util.Map<String, java.lang.String> map = new java.util.LinkedHashMap<>();
        json.getJsonObject("headers").forEach(entry -> {
            if (entry.getValue() instanceof String)
                map.put(entry.getKey(), (String) entry.getValue());
        });
        obj.setHeaders(map);
    }
    if (json.getValue("message") instanceof String) {
        obj.setMessage((String) json.getValue("message"));
    }
}

From source file:io.apiman.gateway.platforms.vertx3.services.IngestorToPolicyServiceVertxProxyHandler.java

License:Apache License

@Override
public void handle(Message<JsonObject> msg) {
    JsonObject json = msg.body();
    String action = msg.headers().get("action");
    if (action == null) {
        throw new IllegalStateException("action not specified");
    }//from   ww  w.  j  av  a  2 s.co m
    accessed();
    switch (action) {

    case "head": {
        service.head(json.getJsonObject("apiRequest") == null ? null
                : new io.apiman.gateway.platforms.vertx3.io.VertxApiRequest(json.getJsonObject("apiRequest")),
                createHandler(msg));
        break;
    }
    case "write": {
        service.write((java.lang.String) json.getValue("chunk"));
        break;
    }
    case "end": {
        service.end(createHandler(msg));
        close();
        break;
    }
    default: {
        throw new IllegalStateException("Invalid action: " + action);
    }
    }
}

From source file:io.apiman.gateway.platforms.vertx3.services.PolicyToIngestorServiceVertxProxyHandler.java

License:Apache License

@Override
public void handle(Message<JsonObject> msg) {
    JsonObject json = msg.body();
    String action = msg.headers().get("action");
    if (action == null) {
        throw new IllegalStateException("action not specified");
    }/*  w w  w . j  a v a2s  .c o  m*/
    accessed();
    switch (action) {

    case "head": {
        service.head(json.getJsonObject("apiResponse") == null ? null
                : new io.apiman.gateway.platforms.vertx3.io.VertxApiResponse(json.getJsonObject("apiResponse")),
                createHandler(msg));
        break;
    }
    case "write": {
        service.write((java.lang.String) json.getValue("chunk"));
        break;
    }
    case "end": {
        service.end(createHandler(msg));
        close();
        break;
    }
    case "policyFailure": {
        service.policyFailure(json.getJsonObject("policyFailure") == null ? null
                : new io.apiman.gateway.platforms.vertx3.io.VertxPolicyFailure(
                        json.getJsonObject("policyFailure")));
        break;
    }
    default: {
        throw new IllegalStateException("Invalid action: " + action);
    }
    }
}

From source file:io.engagingspaces.graphql.events.SchemaReferenceData.java

License:Open Source License

/**
 * Creates a new {@link SchemaReferenceData} from
 * its json representation.// www . j  a va 2s . c o m
 *
 * @param json the json object
 */
public SchemaReferenceData(JsonObject json) {
    this.id = json.getString("id");
    this.record = new Record(json.getJsonObject("record"));
    this.status = "bind".equals(json.getValue("type")) ? Status.BOUND : Status.RELEASED;
}