Example usage for org.springframework.util MultiValueMap add

List of usage examples for org.springframework.util MultiValueMap add

Introduction

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

Prototype

void add(K key, @Nullable V value);

Source Link

Document

Add the given single value to the current list of values for the given key.

Usage

From source file:org.mifos.androidclient.net.services.LoginService.java

public SessionStatus logIn(String userName, String password) {
    MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
    params.add(USERNAME_KEY, userName);
    params.add(PASSWORD_KEY, password);//w w w .ja  v  a2  s . c o  m
    params.add(SPRING_REDIRECT_KEY, STATUS_PATH);

    String url = getServerUrl() + LOGIN_PATH;

    return mRestConnector.postForObject(url, params, SessionStatus.class);
}

From source file:io.curly.bloodhound.query.SearchTranspiler.java

/**
 * Execute the steps to change the query into a multi map, if there is no key the
 * full text search parameter will take place.
 *
 * @param query the user input query//from   w w w  .  j  a v a2 s  .c o  m
 * @return MultiMap with query items and its values
 */
@Override
public MultiValueMap<String, String> execute(String query) {
    Assert.hasText(query, "A query must have text!");
    if (QueryUtils.isParametrized(query)) {
        MultiValueMap<String, String> parameter = QueryParser.resolveMultiParameter(query);
        return resolver.resolve(parameter);
    } else if (QueryUtils.isFullText(query)) {
        MultiValueMap<String, String> fullTextMap = new LinkedMultiValueMap<>(1);
        fullTextMap.add("text", query);
        return fullTextMap;
    }
    return new LinkedMultiValueMap<>();
}

From source file:de.codecentric.batch.test.ListenerProviderIntegrationTest.java

@Test
public void testRunJob() throws InterruptedException {
    MultiValueMap<String, Object> requestMap = new LinkedMultiValueMap<>();
    requestMap.add("jobParameters", "param1=value1");
    Long executionId = restTemplate.postForObject(
            "http://localhost:" + port + "/batch/operations/jobs/simpleJob", requestMap, Long.class);
    while (!restTemplate
            .getForObject("http://localhost:" + port + "/batch/operations/jobs/executions/{executionId}",
                    String.class, executionId)
            .equals("COMPLETED")) {
        Thread.sleep(1000);//w w  w .j ava  2s.  c  o  m
    }
    assertThat(testListener.getCounter() > 1, is(true));
}

From source file:org.intermine.app.net.request.post.GetUserTokenRequest.java

@Override
public MultiValueMap<String, String> getPost() {
    MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.add(TOKEN_TYPE_PARAM, DEFAULT_TOKEN_TYPE_VALUE);
    params.add(TOKEN_MESSAGE_PARAM, TOKEN_MESSAGE_VALUE);
    return params;
}

From source file:com.ctrip.infosec.rule.rest.RuleEngineRESTfulControllerTest.java

@Test
@Ignore//from ww  w  . j  av a2  s . c  o m
public void testVerify() throws Exception {
    System.out.println("verify");
    MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
    params.add("fact", JSON.toJSONString(fact));
    String response = rt.postForObject("http://10.2.10.77:8080/ruleenginews/rule/verify", params, String.class);
    System.out.println("response: " + response);
}

From source file:com.epam.reportportal.auth.OAuthSuccessHandler.java

@Override
protected void handle(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
        throws IOException, ServletException {
    OAuth2Authentication oauth = (OAuth2Authentication) authentication;
    OAuth2AccessToken accessToken = tokenServicesFacade.get().createToken(ReportPortalClient.ui,
            oauth.getName(), oauth.getUserAuthentication(), oauth.getOAuth2Request().getExtensions());

    MultiValueMap<String, String> query = new LinkedMultiValueMap<>();
    query.add("token", accessToken.getValue());
    query.add("token_type", accessToken.getTokenType());
    URI rqUrl = UriComponentsBuilder.fromHttpRequest(new ServletServerHttpRequest(request))
            .replacePath("/ui/authSuccess.html").replaceQueryParams(query).build().toUri();

    eventPublisher.publishEvent(new UiUserSignedInEvent(authentication));

    getRedirectStrategy().sendRedirect(request, response, rqUrl.toString());
}

From source file:com.t163.api.T163OAuth2.java

/**
 * http://open.t.163.com/wiki/index.php?title=Oauth2/access_token
 * @param code//from  w  w w.  ja v  a 2 s. co m
 * @return
 */
public T163AccessToken accessToken(String code) {
    MultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
    map.add("client_id", appKey);
    map.add("client_secret", appSecret);
    map.add("grant_type", "authorization_code");
    map.add("code", code);
    map.add("redirect_uri", redirectUri);
    return t163HttpClient.postForm(OAUTH2_ACCESS_TOKEN, map, T163AccessToken.class);
}

From source file:com.weibo.api.Messages.java

/**
 * http://open.weibo.com/wiki/2/messages/invite
 * @param uid//w ww. j a  va  2s  .  c  om
 * @param data
 * @param accessToken
 * @return
 */
public InviteResult invite(String uid, InviteData data, String accessToken) {
    String jsonData = StringUtils.EMPTY;
    try {
        ObjectMapper objectMapper = new ObjectMapper();
        jsonData = objectMapper.writeValueAsString(data);
    } catch (JsonGenerationException e) {
        log.error(ExceptionUtils.getFullStackTrace(e));
    } catch (JsonMappingException e) {
        log.error(ExceptionUtils.getFullStackTrace(e));
    } catch (IOException e) {
        log.error(ExceptionUtils.getFullStackTrace(e));
    }
    MultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
    map.add("uid", uid);
    map.add("data", jsonData);
    map.add("access_token", accessToken);
    return weiboHttpClient.postForm(MESSAGES_INVITE_URL, map, InviteResult.class);
}

From source file:org.cloudfoundry.identity.uaa.integration.PasswordCheckEndpointIntegrationTests.java

@Test
public void passwordPostSucceeds() throws Exception {
    MultiValueMap<String, String> formData = new LinkedMultiValueMap<String, String>();
    formData.add("password", "password1");
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> response = serverRunning.postForMap("/password/score", formData, headers);
    assertEquals(HttpStatus.OK, response.getStatusCode());

    assertTrue(response.getBody().containsKey("score"));
    assertTrue(response.getBody().containsKey("requiredScore"));
    assertEquals(0, response.getBody().get("score"));
}

From source file:org.cloudfoundry.identity.uaa.integration.PasswordCheckEndpointIntegrationTests.java

@Test
public void passwordPostWithUserDataSucceeds() throws Exception {
    MultiValueMap<String, String> formData = new LinkedMultiValueMap<String, String>();
    formData.add("password", "joe@joesplace.blah");
    formData.add("userData", "joe,joe@joesplace.blah,joesdogsname");
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> response = serverRunning.postForMap("/password/score", formData, headers);
    assertEquals(HttpStatus.OK, response.getStatusCode());

    assertTrue(response.getBody().containsKey("score"));
    assertTrue(response.getBody().containsKey("requiredScore"));
    assertEquals(0, response.getBody().get("score"));
}