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

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

Introduction

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

Prototype

public Integer getInteger(String key, Integer def) 

Source Link

Document

Like #getInteger(String) but specifying a default value to return if there is no entry.

Usage

From source file:org.hawkular.apm.examples.vertx.opentracing.OrderManager.java

License:Apache License

protected void checkStock(JsonObject order, HttpServerResponse response, Span parentSpan) {
    Span getItemSpan = tracer.buildSpan("GetItem").asChildOf(parentSpan).start();
    tracer.inject(getItemSpan.context(), Format.Builtin.TEXT_MAP, new VertxMessageInjectAdapter(order));

    // Check stock
    eb.send("InventoryManager.getItem", order, invresp -> {

        getItemSpan.finish();/*from  w  ww .  j  ava2s  .c o m*/

        if (invresp.succeeded()) {
            JsonObject item = (JsonObject) invresp.result().body();
            if (order.getInteger("quantity", 1) <= item.getInteger("quantity", 1)) {

                // Remove internal headers - necessary because we have had
                // to piggyback the APM state as a top level field in the
                // order JSON document - which now needs to be removed before
                // returning it to the end user.
                VertxMessageInjectAdapter.cleanup(order);

                // Assign id
                order.put("id", UUID.randomUUID().toString());
                orders.put(order.getString("id"), order);
                response.putHeader("content-type", "application/json").setStatusCode(202)
                        .end(order.encodePrettily());

                parentSpan.setTag("orderId", order.getString("id"));
                parentSpan.setTag("itemId", order.getString("itemId"));
                parentSpan.setTag("accountId", order.getString("accountId"));

                parentSpan.finish();

                orderConfirmed(order, parentSpan);
            } else {
                sendError(500, "Out of stock", response, parentSpan);
            }
        } else {
            sendError(500, invresp.cause().getMessage(), response, parentSpan);
        }
    });
}

From source file:org.sfs.vo.BlobReference.java

License:Apache License

public T merge(JsonObject jsonObject) {
    volumeId = jsonObject.getString("volume_id");
    position = jsonObject.getLong("position");
    readSha512 = jsonObject.getBinary("read_sha512");
    readLength = jsonObject.getLong("read_length");
    acknowledged = jsonObject.getBoolean("acknowledged");
    deleted = jsonObject.getBoolean("deleted");
    verifyFailCount = jsonObject.getInteger("verify_fail_count", 0);

    return (T) this;
}

From source file:pt.davidafsilva.slacker.server.HttpServerConfiguration.java

License:Open Source License

/**
 * Sets up the http server configuration based on the available environment variables (SLACK_*)
 * and current configuration via the json configuration file.
 *
 * @param config the current configuration
 * @return the configured server options
 *//*from  w  ww.  j  a v a 2  s.c o m*/
static HttpServerOptions setup(final JsonObject config) {
    // evaluate the environment variables
    evaluateEnvironmentVariables(config);

    // create the http server options
    final HttpServerOptions options = new HttpServerOptions().setIdleTimeout(IDLE_TIMEOUT)
            .setPort(config.getInteger(ConfigurationVariable.HTTP_PORT.name(), DEFAULT_HTTP_PORT))
            .setSsl(config.getBoolean(ConfigurationVariable.USE_SSL.name(), DEFAULT_USE_SSL));

    // setup the required SSL parameters
    if (options.isSsl()) {
        // validate the configuration
        validateOptions(config, ConfigurationVariable.KEY_STORE_FILE, ConfigurationVariable.KEY_STORE_PASS);

        // add the enabled cipher suites
        CIPHER_SUITES.stream().forEach(options::addEnabledCipherSuite);

        // set the both keystore location and keystore password
        options.setKeyStoreOptions(
                new JksOptions().setPath(config.getString(ConfigurationVariable.KEY_STORE_FILE.name()))
                        .setPassword(config.getString(ConfigurationVariable.KEY_STORE_PASS.name())));
    }

    return options;
}