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

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

Introduction

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

Prototype

public String getString(String key) 

Source Link

Document

Get the string value with the specified key, special cases are addressed for extended JSON types Instant , byte[] and Enum which can be converted to String.

Usage

From source file:io.knotx.dataobjects.Fragment.java

License:Apache License

public Fragment(JsonObject fragment) {
    this.knots = fragment.getJsonArray(KNOTS_KEY).stream().map(String::valueOf).collect(Collectors.toList());
    this.content = fragment.getString(CONTENT_KEY);
    this.context = fragment.getJsonObject(CONTEXT_KEY, new JsonObject());
}

From source file:io.knotx.knot.action.ActionKnotConfiguration.java

License:Apache License

public ActionKnotConfiguration(JsonObject config) {
    this.address = config.getString("address");
    this.formIdentifierName = config.getString("formIdentifierName");
    this.adapterMetadataList = config.getJsonArray("adapters").stream().map(item -> (JsonObject) item)
            .map(item -> {/*ww  w . ja va  2  s.  co  m*/
                AdapterMetadata metadata = new AdapterMetadata();
                metadata.name = item.getString("name");
                metadata.address = item.getString("address");
                metadata.params = item.getJsonObject("params", new JsonObject()).getMap();
                metadata.allowedRequestHeaders = item.getJsonArray("allowedRequestHeaders", new JsonArray())
                        .stream().map(object -> (String) object).map(new StringToPatternFunction())
                        .collect(Collectors.toList());
                metadata.allowedResponseHeaders = item.getJsonArray("allowedResponseHeaders", new JsonArray())
                        .stream().map(object -> (String) object).map(new StringToPatternFunction())
                        .collect(Collectors.toList());
                return metadata;
            }).collect(Collectors.toList());
}

From source file:io.knotx.knot.assembler.FragmentAssemblerConfiguration.java

License:Apache License

public FragmentAssemblerConfiguration(JsonObject config) {
    address = config.getString("address");
    assemblyStrategy = UnprocessedFragmentStrategy.valueOf(
            config.getString("unprocessedStrategy", UnprocessedFragmentStrategy.UNWRAP.name()).toUpperCase());
}

From source file:io.knotx.knot.service.ServiceKnotConfiguration.java

License:Apache License

public ServiceKnotConfiguration(JsonObject config) {
    address = config.getString("address");
    services = config.getJsonArray("services").stream().map(item -> (JsonObject) item).map(item -> {
        ServiceMetadata metadata = new ServiceMetadata();
        metadata.name = item.getString("name");
        metadata.address = item.getString("address");
        metadata.params = item.getJsonObject("params");
        metadata.cacheKey = item.getString("cacheKey");
        return metadata;
    }).collect(Collectors.toList());
}

From source file:io.knotx.knot.templating.HandlebarsKnotConfiguration.java

License:Apache License

public HandlebarsKnotConfiguration(JsonObject config) {
    this.address = config.getString("address");
    this.templateDebug = config.getBoolean("templateDebug", false);
}

From source file:io.knotx.launcher.KnotxModuleVerticleFactory.java

License:Apache License

private String readVerticleMainClass(JsonObject descriptor, String descriptorFile) {
    String main = descriptor.getString("main");
    if (main == null) {
        throw new IllegalArgumentException(descriptorFile + " does not contain a main field");
    }// w ww .j ava 2s. c  o  m
    return main;
}

From source file:io.knotx.mocks.adapter.MockActionAdapterHandler.java

License:Apache License

@Override
public void handle(Message<AdapterRequest> message) {
    ClientRequest request = message.body().getRequest();
    JsonObject params = message.body().getParams();

    String resourcePath = getFilePath(params.getString("step"));
    fileSystem.readFile(resourcePath, ar -> {
        if (ar.succeeded()) {
            final JsonObject transitions = ar.result().toJsonObject();
            message.reply(replyTransition(request, transitions));
        } else {//from  w w w. j  a v  a  2 s.c  om
            LOGGER.error("Unable to read file. {}", ar.cause());
            message.reply(errorResponse());
        }
    });
}

From source file:io.knotx.mocks.adapter.MockAdapterHandler.java

License:Apache License

@Override
public void handle(Message<AdapterRequest> message) {
    ClientRequest request = message.body().getRequest();
    JsonObject params = message.body().getParams();

    String resourcePath = getFilePath(params.getString("path"));
    fileSystem.readFile(resourcePath, ar -> {
        if (ar.succeeded()) {
            String mockData = ar.result().toString();
            message.reply(okResponse(request, mockData));
        } else {/* w w  w  .j ava  2s  . c o  m*/
            LOGGER.error("Unable to read file. {}", ar.cause());
            message.reply(errorResponse());
        }
    });
}

From source file:io.knotx.mocks.knot.KnotContextKeys.java

License:Apache License

Observable<Pair<String, Optional<Object>>> valueOrDefault(FileSystem fileSystem, JsonObject responseConfig,
        KnotContext context) {/*  w ww  . j a  va  2 s . com*/
    return Observable.just(key).filter(responseConfig::containsKey)
            .flatMap(contextKey -> this.mockValue(fileSystem, responseConfig.getString(contextKey)))
            .map(value -> Pair.of(key, value)).defaultIfEmpty(Pair.of(key, this.defaultValue(context)));
}

From source file:io.knotx.repository.impl.FilesystemRepositoryConnectorProxyImpl.java

License:Apache License

public FilesystemRepositoryConnectorProxyImpl(Vertx vertx, JsonObject configuration) {
    this.fileSystem = vertx.fileSystem();
    this.catalogue = configuration.getString("catalogue");
}