Example usage for io.vertx.core MultiMap get

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

Introduction

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

Prototype

@Nullable
String get(String name);

Source Link

Document

Returns the value of with the specified name.

Usage

From source file:org.sfs.validate.ValidateParamBetweenInteger.java

License:Apache License

@Override
public SfsRequest call(SfsRequest httpServerRequest) {
    MultiMap params = httpServerRequest.params();

    String value = params.get(paramName);
    if (value != null) {
        Integer parsed = tryParse(value);
        if (parsed == null || parsed < min || parsed > max) {
            JsonObject jsonObject = new JsonObject().put("message",
                    format("%s must be between %d and %d", paramName, min, max));

            throw new HttpRequestValidationException(HTTP_BAD_REQUEST, jsonObject);
        }//from  w w w.  java 2s  .  co m
    }
    return httpServerRequest;
}

From source file:org.sfs.validate.ValidateParamBetweenLong.java

License:Apache License

@Override
public SfsRequest call(SfsRequest httpServerRequest) {
    MultiMap param = httpServerRequest.params();

    String value = param.get(paramName);
    if (value != null) {
        Long parsed = tryParse(value);
        if (parsed == null || parsed < min || parsed > max) {
            JsonObject jsonObject = new JsonObject().put("message",
                    format("%s must be between %d and %d", paramName, min, max));

            throw new HttpRequestValidationException(HTTP_BAD_REQUEST, jsonObject);
        }/*from   w w w .  jav  a  2  s  .co m*/
    }
    return httpServerRequest;
}

From source file:org.sfs.validate.ValidateParamExists.java

License:Apache License

@Override
public SfsRequest call(SfsRequest httpServerRequest) {
    MultiMap params = httpServerRequest.params();

    String value = params.get(paramName);
    if (value == null) {
        JsonObject jsonObject = new JsonObject().put("message", format("%s is required", paramName));

        throw new HttpRequestValidationException(HTTP_BAD_REQUEST, jsonObject);
    }/*from  w  ww  .j av a 2  s . c o  m*/
    return httpServerRequest;
}

From source file:org.sfs.validate.ValidateParamIsBase64Encoded.java

License:Apache License

@Override
public SfsRequest call(SfsRequest httpServerRequest) {
    MultiMap params = httpServerRequest.params();

    String value = params.get(paramName);
    if (value != null) {
        boolean failed = false;
        BaseEncoding baseEncoding = base64();
        try {//from w w  w  .  j  a  v a 2s .  c o m
            byte[] decoded = baseEncoding.decode(value);
            if (decoded == null || value.equals(baseEncoding.encode(decoded))) {
                failed = true;
            }
        } catch (Throwable e) {
            // do nothing
        }
        if (failed) {
            JsonObject jsonObject = new JsonObject().put("message",
                    format("%s must be Base64 encoded", paramName));

            throw new HttpRequestValidationException(HTTP_BAD_REQUEST, jsonObject);
        }
    }
    return httpServerRequest;
}

From source file:org.sfs.validate.ValidateParamNotExists.java

License:Apache License

@Override
public SfsRequest call(SfsRequest httpServerRequest) {
    MultiMap params = httpServerRequest.params();

    String value = params.get(paramName);
    if (value != null) {
        JsonObject jsonObject = new JsonObject().put("message", format("%s is not supported", paramName));

        throw new HttpRequestValidationException(HTTP_BAD_REQUEST, jsonObject);
    }/* ww w .  j av a 2 s  . co m*/
    return httpServerRequest;
}

From source file:org.sfs.validate.ValidateTtl.java

License:Apache License

@Override
public SfsRequest call(SfsRequest httpServerRequest) {
    MultiMap headers = httpServerRequest.headers();

    if (headers.contains(X_DELETE_AT) && headers.contains(X_DELETE_AFTER)) {
        JsonObject jsonObject = new JsonObject().put("message",
                format("Only one of %s or %s is allowed", X_DELETE_AFTER, X_DELETE_AT));

        throw new HttpRequestValidationException(HTTP_CONFLICT, jsonObject);
    }//from   w  w w  .  ja  v a 2s.com

    String deleteAt = headers.get(X_DELETE_AT);
    if (deleteAt != null) {
        long minDeleteAt = currentTimeMillis();
        Long parsed = tryParse(deleteAt);
        if (parsed == null || parsed < 0) {
            JsonObject jsonObject = new JsonObject().put("message",
                    format("%s must be between %d and %d", X_DELETE_AT, minDeleteAt, MAX_VALUE));

            throw new HttpRequestValidationException(HTTP_BAD_REQUEST, jsonObject);
        }
    }

    String deleteAfter = headers.get(X_DELETE_AFTER);
    if (deleteAfter != null) {
        Long parsed = tryParse(deleteAfter);
        if (parsed == null || parsed < 0) {
            JsonObject jsonObject = new JsonObject().put("message",
                    format("%s must be between %d and %d", X_DELETE_AFTER, 60000, MAX_VALUE));

            throw new HttpRequestValidationException(HTTP_BAD_REQUEST, jsonObject);
        }
    }
    return httpServerRequest;
}

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

License:Apache License

public T merge(SfsRequest httpServerRequest) {
    MultiMap headers = httpServerRequest.headers();

    if (headers.contains(X_SFS_OBJECT_REPLICAS)) {
        setObjectReplicas(parseInt(headers.get(X_SFS_OBJECT_REPLICAS)));
    } else {//from   w  ww . j  a va  2s  . c  o  m
        setObjectReplicas(NOT_SET);
    }

    getMetadata().withHttpHeaders(headers);

    return (T) this;
}

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

License:Apache License

public XBlob merge(SfsRequest httpServerRequest) {
    MultiMap queryParams = httpServerRequest.params();
    MultiMap headers = httpServerRequest.headers();

    if (queryParams.contains(VOLUME)) {
        volume = tryParse(queryParams.get(VOLUME));
    }/*from  ww w .ja  va  2 s .c  o  m*/
    if (queryParams.contains(POSITION)) {
        position = Longs.tryParse(queryParams.get(POSITION));
    }
    if (queryParams.contains(VERSION)) {
        version = base64().decode(queryParams.get(VERSION));
    }
    if (headers.contains(CONTENT_LENGTH)) {
        length = Longs.tryParse(headers.get(CONTENT_LENGTH));
    }

    for (String queryParam : queryParams.names()) {
        Matcher matcher = COMPUTED_DIGEST.matcher(queryParam);
        if (matcher.matches()) {
            MessageDigestFactory digest = fromValueIfExists(matcher.group(1)).get();
            messageDigests.add(digest);
        }
    }

    return this;
}

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

License:Apache License

public T merge(SfsRequest httpServerRequest) {

    MultiMap headers = httpServerRequest.headers();

    getMetadata().clear();/*  www .  ja  v a 2s  .c  o  m*/
    getMetadata().withHttpHeaders(headers);

    Calendar tsNow = getInstance();

    if (createTs == null) {
        setCreateTs(tsNow);
    }

    setUpdateTs(tsNow);

    String contentEncoding = headers.get(CONTENT_ENCODING);
    String contentType = headers.get(CONTENT_TYPE);
    String contentDisposition = headers.get(CONTENT_DISPOSITION);
    String contentLength = headers.get(CONTENT_LENGTH);
    String deleteAt = headers.get(X_DELETE_AT);
    String deleteAfter = headers.get(X_DELETE_AFTER);
    String etag = headers.get(ETAG);
    String contentMd5 = headers.get(CONTENT_MD5);
    String contentSha512 = headers.get(X_CONTENT_SHA512);
    String serverSideEncryption = headers.get(X_SERVER_SIDE_ENCRYPTION);
    String objectManifest = headers.get(X_OBJECT_MANIFEST);

    if (contentLength != null) {
        Long parsed = tryParse(contentLength);
        setContentLength(parsed);
    }

    checkState(deleteAt == null || deleteAfter == null, "DeleteAt and DeleteAfter were supplied");

    if (deleteAt != null) {
        Long parsed = tryParse(deleteAt);
        setDeleteAt(parsed);
    }

    if (deleteAfter != null) {
        Long parsed = tryParse(deleteAfter);
        long now = checkedAdd(updateTs.getTimeInMillis(), parsed);
        setDeleteAt(now);
    }

    if (etag != null) {
        setEtag(base16().lowerCase().decode(etag));
    }

    if (contentMd5 != null) {
        setContentMd5(base64().decode(contentMd5));
    }

    if (contentSha512 != null) {
        setContentSha512(base64().decode(contentSha512));
    }

    setContentEncoding(contentEncoding).setContentType(contentType).setContentDisposition(contentDisposition)
            .setServerSideEncryption(
                    serverSideEncryption == null ? getParent().getParent().getServerSideEncryption()
                            : equalsIgnoreCase("true", serverSideEncryption))
            .setObjectManifest(objectManifest);

    return (T) this;
}

From source file:org.symphonyoss.webservice.models.session.WebSession.java

License:Apache License

private WebSession(SockJSSocket sockJSSocket, MultiMap sessionData, AsyncCallback<WebSession> readyCallback,
        ErrorCallback errorCallback) {/*w ww .  j a  v  a2s.  c  o m*/

    this.sessionData = new SessionData(sessionData.get("name"), sessionData.get("email"),
            sessionData.get("topic"));
    this.sockJSSocket = sockJSSocket;

    initWebSocket(sockJSSocket);

    CompletableFuture.runAsync(() -> createRoom(readyCallback, errorCallback), executor);

}