Example usage for org.springframework.util LinkedMultiValueMap LinkedMultiValueMap

List of usage examples for org.springframework.util LinkedMultiValueMap LinkedMultiValueMap

Introduction

In this page you can find the example usage for org.springframework.util LinkedMultiValueMap LinkedMultiValueMap.

Prototype

public LinkedMultiValueMap(Map<K, List<V>> otherMap) 

Source Link

Document

Copy constructor: Create a new LinkedMultiValueMap with the same mappings as the specified Map.

Usage

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Atomically updates a key-value pair in etcd.
 * //from   w w w .j a  va 2  s. com
 * @param key
 *            the key
 * @param value
 *            the value
 * @param prevIndex
 *            the modified index of the key
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse compareAndSwap(String key, String value, int prevIndex) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);
    builder.queryParam("prevIndex", prevIndex);

    MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1);
    payload.set("value", value);

    return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class);
}

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Atomically updates a key-value pair in etcd.
 * /*from  w w w. ja va2s .  c  o m*/
 * @param key
 *            the key
 * @param value
 *            the value
 * @param ttl
 *            the time-to-live
 * @param prevIndex
 *            the modified index of the key
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse compareAndSwap(String key, String value, int ttl, int prevIndex) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);
    builder.queryParam("ttl", ttl == -1 ? "" : ttl);
    builder.queryParam("prevIndex", prevIndex);

    MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1);
    payload.set("value", value);

    return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class);
}

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Atomically updates a key-value pair in etcd.
 * // w  w w  .  j  a va  2s . c  om
 * @param key
 *            the key
 * @param value
 *            the value
 * @param prevValue
 *            the previous value of the key
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse compareAndSwap(String key, String value, String prevValue) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);
    builder.queryParam("prevValue", prevValue);

    MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1);
    payload.set("value", value);

    return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class);
}

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Atomically updates a key-value pair in etcd.
 * //w ww .j  av  a2s.c o  m
 * @param key
 *            the key
 * @param value
 *            the value
 * @param ttl
 *            the time-to-live
 * @param prevValue
 *            the previous value of the key
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse compareAndSwap(String key, String value, int ttl, String prevValue) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);
    builder.queryParam("ttl", ttl == -1 ? "" : ttl);
    builder.queryParam("prevValue", prevValue);

    MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1);
    payload.set("value", value);

    return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class);
}

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Creates a directory node in etcd.//from   w w  w. j  av  a  2 s  . c  o  m
 * 
 * @param key
 *            the key
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse putDir(final String key) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);

    MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1);
    payload.set("dir", "true");

    return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class);
}

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Creates a directory node in etcd.//from   w  w w  .j  a va 2s.co m
 * 
 * @param key
 *            the key
 * @param ttl
 *            the time-to-live
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse putDir(String key, int ttl) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);

    MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1);
    payload.set("dir", "true");
    payload.set("ttl", ttl == -1 ? "" : String.valueOf(ttl));

    return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class);
}

From source file:org.alfresco.integrations.google.docs.service.GoogleDocsServiceImpl.java

/**
 * The oauth authentication url//from   w  w  w.  java2 s .c o m
 * 
 * @param state the value of the oauth state parameter to be passed in the authentication url
 * @return The complete oauth authentication url
 */
public String getAuthenticateUrl(String state) {
    String authenticateUrl = null;

    if (state != null) {
        MultiValueMap<String, String> additionalParameters = new LinkedMultiValueMap<String, String>(1);
        additionalParameters.add("access_type", "offline");

        OAuth2Parameters parameters = new OAuth2Parameters(GoogleDocsConstants.REDIRECT_URI,
                GoogleDocsConstants.SCOPE, state, additionalParameters);
        parameters.getAdditionalParameters();
        authenticateUrl = connectionFactory.getOAuthOperations()
                .buildAuthenticateUrl(GrantType.AUTHORIZATION_CODE, parameters);
    }

    log.debug("Authentication URL: " + authenticateUrl);
    return authenticateUrl;
}

From source file:com.gooddata.dataload.processes.ProcessService.java

private DataloadProcess postProcess(DataloadProcess process, File processData, URI postUri) {
    File tempFile = createTempFile("process", ".zip");

    try (FileOutputStream output = new FileOutputStream(tempFile)) {
        ZipHelper.zip(processData, output);
    } catch (IOException e) {
        throw new GoodDataException("Unable to zip process data", e);
    }//  w w  w. j  av a 2s .c  om

    Object processToSend;
    HttpMethod method = HttpMethod.POST;
    if (tempFile.length() > MAX_MULTIPART_SIZE) {
        try {
            process.setPath(dataStoreService.getUri(tempFile.getName()).getPath());
            dataStoreService.upload(tempFile.getName(), new FileInputStream(tempFile));
            processToSend = process;
            if (DataloadProcess.TEMPLATE.matches(postUri.toString())) {
                method = HttpMethod.PUT;
            }
        } catch (FileNotFoundException e) {
            throw new GoodDataException("Unable to access zipped process data at " + tempFile.getAbsolutePath(),
                    e);
        }
    } else {
        final MultiValueMap<String, Object> parts = new LinkedMultiValueMap<>(2);
        parts.add("process", process);
        final HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MEDIA_TYPE_ZIP);
        parts.add("data", new HttpEntity<>(new FileSystemResource(tempFile), headers));
        processToSend = parts;
    }

    try {
        final ResponseEntity<DataloadProcess> response = restTemplate.exchange(postUri, method,
                new HttpEntity<>(processToSend), DataloadProcess.class);
        if (response == null) {
            throw new GoodDataException("Unable to post dataload process. No response returned from API.");
        }
        return response.getBody();
    } catch (GoodDataException | RestClientException e) {
        throw new GoodDataException("Unable to post dataload process.", e);
    } finally {
        deleteTempFile(tempFile);
    }
}

From source file:org.cloudfoundry.client.lib.rest.CloudControllerClientV1.java

private HttpEntity<MultiValueMap<String, ?>> generatePartialResourceRequest(
        UploadApplicationPayload application, CloudResources knownRemoteResources) throws IOException {
    MultiValueMap<String, Object> body = new LinkedMultiValueMap<String, Object>(2);
    if (application.getNumEntries() > 0) {
        //If the entire app contents are cached, send nothing
        body.add("application", application);
    }//from  w w  w . j  av  a 2s.c  o m
    ObjectMapper mapper = new ObjectMapper();
    String knownRemoteResourcesPayload = mapper.writeValueAsString(knownRemoteResources);
    body.add("resources", knownRemoteResourcesPayload);
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.MULTIPART_FORM_DATA);
    return new HttpEntity<MultiValueMap<String, ?>>(body, headers);
}

From source file:org.n52.io.request.IoParameters.java

public IoParameters removeAllOf(String key) {
    MultiValueMap<String, JsonNode> newValues = new LinkedMultiValueMap<>(query);
    newValues.remove(key.toLowerCase());
    return new IoParameters(newValues);
}