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() 

Source Link

Document

Create a new LinkedMultiValueMap that wraps a LinkedHashMap .

Usage

From source file:org.fenixedu.bennu.social.domain.api.BitbucketAPI.java

public HttpEntity<MultiValueMap<String, String>> getAccessTokenRequest(String code) {
    MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
    map.add("grant_type", "authorization_code");
    map.add("code", code);

    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);

    String plainCreds = getClientId() + ":" + getClientSecret();
    byte[] plainCredsBytes = plainCreds.getBytes();
    byte[] base64CredsBytes = Base64.encodeBase64(plainCredsBytes);
    String base64Creds = new String(base64CredsBytes);
    headers.add("Authorization", "Basic " + base64Creds);

    return new HttpEntity<MultiValueMap<String, String>>(map, headers);
}

From source file:org.jahia.services.render.webflow.MultipartResolver.java

@Override
protected MultipartParsingResult parseRequest(HttpServletRequest request) throws MultipartException {
    FileUpload fileUpload = (FileUpload) request.getAttribute(FileUpload.FILEUPLOAD_ATTRIBUTE);
    List<FileItem> fileItems = new ArrayList<FileItem>(fileUpload.getFileItems().values());

    MultiValueMap<String, MultipartFile> multipartFiles = new LinkedMultiValueMap<String, MultipartFile>();
    Map<String, String> multipartParameterContentTypes = new HashMap<String, String>();

    for (FileItem fileItem : fileItems) {
        CommonsMultipartFile file = new CommonsMultipartFile(fileItem);
        multipartFiles.add(fileItem.getFieldName(), file);
    }//from  w ww.ja  va2 s.  co m

    Map<String, String[]> multipartParameters = new HashMap<String, String[]>();
    for (String param : fileUpload.getParameterNames()) {
        if (!request.getQueryString().contains("&" + param + "=")
                && !request.getQueryString().startsWith(param + "=")) {
            multipartParameters.put(param, fileUpload.getParameterValues(param));
            multipartParameterContentTypes.put(param, fileUpload.getParameterContentType(param));
        }
    }

    return new MultipartParsingResult(multipartFiles, multipartParameters, multipartParameterContentTypes);
}

From source file:org.jgrades.rest.client.lic.LicenceManagerServiceClient.java

@Override
public Licence uploadAndInstall(MultipartFile licence, MultipartFile signature) throws IOException {
    Resource licenceResource = getResource(licence);
    Resource signatureResource = getResource(signature);
    try {//  ww  w  . ja  va2s  . c o  m
        String serviceUrl = backendBaseUrl + "/licence";

        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.MULTIPART_FORM_DATA);

        LinkedMultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        params.add("licence", licenceResource);
        params.add("signature", signatureResource);

        HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);

        ResponseEntity<Licence> response = restTemplate.exchange(serviceUrl, HttpMethod.POST, requestEntity,
                Licence.class);
        return response.getBody();
    } finally {
        FileUtils.deleteQuietly(licenceResource.getFile());
        FileUtils.deleteQuietly(signatureResource.getFile());
    }
}

From source file:org.kaaproject.kaa.sandbox.rest.SandboxClient.java

public String buildProjectBinary(String projectId) {
    MultiValueMap<String, String> request = new LinkedMultiValueMap<>();
    request.add("projectId", projectId);
    request.add("dataType", "BINARY");
    byte[] result = restTemplate.postForObject(url + "buildProjectData", request, byte[].class);
    return new String(result);
}

From source file:org.kaaproject.kaa.server.common.admin.AdminClient.java

/**
 * Update server profile of endpoint.//from  ww w.java  2 s  . c o m
 *
 * @param endpointProfileKey the endpoint profile key
 * @param version            the version
 * @param serverProfileBody  the server profile body
 */
public EndpointProfileDto updateServerProfile(String endpointProfileKey, int version, String serverProfileBody)
        throws Exception {
    MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
    params.add("endpointProfileKey", endpointProfileKey);
    params.add("version", version);
    params.add("serverProfileBody", serverProfileBody);
    return restTemplate.postForObject(restTemplate.getUrl() + "updateServerProfile", params,
            EndpointProfileDto.class);
}

From source file:org.kaaproject.kaa.server.common.admin.AdminClient.java

/**
 * Creates the kaa admin with specific name and password.
 *
 * @param username admin's name//from   ww  w.ja v  a  2  s . c  om
 * @param password admin's password
 */
public void createKaaAdmin(String username, String password) throws Exception {
    MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
    params.add("username", username);
    params.add("password", password);
    restTemplate.postForObject(restTemplate.getUrl() + "auth/createKaaAdmin", params, Void.class);
}

From source file:org.kaaproject.kaa.server.common.admin.AdminClient.java

/**
 * Change password of user./*from   w  ww. ja v a 2  s . co  m*/
 *
 * @param username    the user name
 * @param oldPassword the old password
 * @param newPassword the new password
 * @return the result code
 * @throws Exception the exception
 */
public ResultCode changePassword(String username, String oldPassword, String newPassword) throws Exception {
    MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
    params.add("username", username);
    params.add("oldPassword", oldPassword);
    params.add("newPassword", newPassword);
    return restTemplate.postForObject(restTemplate.getUrl() + "auth/changePassword", params, ResultCode.class);
}

From source file:org.kaaproject.kaa.server.common.admin.AdminClient.java

/**
 * Adds the topic with specific id to endpoint group with specific id.
 *
 * @param endpointGroupId the endpoint group id
 * @param topicId         the topic id//from  w w w.j a  va2  s .  c  o  m
 */
public void addTopicToEndpointGroup(String endpointGroupId, String topicId) throws Exception {
    MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
    params.add("endpointGroupId", endpointGroupId);
    params.add("topicId", topicId);
    restTemplate.postForObject(restTemplate.getUrl() + "addTopicToEpGroup", params, Void.class);
}

From source file:org.kaaproject.kaa.server.common.admin.AdminClient.java

/**
 * Removes the topic with specific id to endpoint group with specific id.
 *
 * @param endpointGroupId the endpoint group id
 * @param topicId         the topic id//from  www  .  j av a2  s.c om
 */
public void removeTopicFromEndpointGroup(String endpointGroupId, String topicId) throws Exception {
    MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
    params.add("endpointGroupId", endpointGroupId);
    params.add("topicId", topicId);
    restTemplate.postForObject(restTemplate.getUrl() + "removeTopicFromEpGroup", params, Void.class);
}

From source file:org.kaaproject.kaa.server.common.admin.AdminClient.java

/**
 * Remove the endpoint with specific profile key.
 *
 * @param endpointProfileKeyHash the endpoint profile key hash
 *//*from   w  ww .  j a v  a2  s. c om*/
public void removeEndpointProfileByKeyHash(String endpointProfileKeyHash) throws Exception {
    MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
    params.add("endpointProfileKeyHash", endpointProfileKeyHash);
    restTemplate.postForObject(restTemplate.getUrl() + "removeEndpointProfileByKeyHash", params, Void.class);
}