Example usage for io.vertx.core MultiMap set

List of usage examples for io.vertx.core MultiMap set

Introduction

In this page you can find the example usage for io.vertx.core MultiMap set.

Prototype

@GenIgnore(GenIgnore.PERMITTED_TYPE)
@Fluent
MultiMap set(CharSequence name, Iterable<CharSequence> values);

Source Link

Document

Like #set(String,Iterable) but accepting CharSequence as parameters

Usage

From source file:org.sfs.nodes.compute.object.VerifyRepairObjectExecute.java

License:Apache License

@Override
public void handle(final SfsRequest httpServerRequest) {

    VertxContext<Server> vertxContext = httpServerRequest.vertxContext();

    Defer.aVoid().flatMap(new Authenticate(httpServerRequest))
            .flatMap(new ValidateActionAdminOrSystem(httpServerRequest)).map(aVoid -> httpServerRequest)
            .map(new ValidateHeaderBetweenLong(Jobs.Parameters.TIMEOUT, 100, Long.MAX_VALUE))
            .map(new ToVoid<>()).map(aVoid -> ObjectPath.fromSfsRequest(httpServerRequest))
            .map(new ValidateObjectPath()).flatMap(objectPath -> {
                ClusterInfo clusterInfo = vertxContext.verticle().getClusterInfo();
                Nodes nodes = vertxContext.verticle().nodes();
                MultiMap headers = httpServerRequest.headers();

                long timeout = headers.contains(Jobs.Parameters.TIMEOUT)
                        ? Long.parseLong(headers.get(Jobs.Parameters.TIMEOUT))
                        : 100;/*from  www.  ja  v  a2s . com*/

                String unparsedForceRemoveVolumes = headers.contains(Jobs.Parameters.FORCE_REMOVE_VOLUMES)
                        ? headers.get(Jobs.Parameters.FORCE_REMOVE_VOLUMES)
                        : null;

                MultiMap params = MultiMap.caseInsensitiveMultiMap();
                if (unparsedForceRemoveVolumes != null) {
                    params.add(Jobs.Parameters.FORCE_REMOVE_VOLUMES, unparsedForceRemoveVolumes);
                }
                params.set(Jobs.Parameters.OBJECT_ID, objectPath.objectPath().get());

                TransientServiceDef transientServiceDef = clusterInfo.getCurrentMasterNode();
                MasterNode masterNode = nodes.remoteMasterNode(vertxContext, transientServiceDef);

                httpServerRequest.startProxyKeepAlive();

                return masterNode.executeJob(Jobs.ID.VERIFY_REPAIR_OBJECT, params, timeout,
                        TimeUnit.MILLISECONDS);
            }).single().subscribe(new ConnectionCloseTerminus<Void>(httpServerRequest) {
                @Override
                public void onNext(Void aVoid) {
                    JsonObject responseJson = new JsonObject().put("code", HTTP_OK).put("message", "Success");
                    httpServerRequest.response().write(responseJson.encode(), StandardCharsets.UTF_8.toString())
                            .write(DELIMITER_BUFFER);
                }
            });
}