List of usage examples for org.springframework.util LinkedMultiValueMap LinkedMultiValueMap
public LinkedMultiValueMap()
From source file:sample.web.thymeleaf3.SampleWebThymeleaf3ApplicationTests.java
@Test public void testCreate() throws Exception { MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>(); map.set("text", "FOO text"); map.set("summary", "FOO"); URI location = this.restTemplate.postForLocation("/", map); assertThat(location.toString()).contains("localhost:" + this.port); }
From source file:org.intermine.app.net.request.post.FetchListResultsRequest.java
@Override public MultiValueMap<String, String> getPost() { MultiValueMap<String, String> params = new LinkedMultiValueMap<>(); params.add(FORMAT_PARAM, JSON);//from w w w.j a va 2 s. c o m params.add(QUERY_PARAM, mQuery); if (mSize > 0) { params.add(START_PARAM, Integer.toString(mStart)); params.add(SIZE_PARAM, Integer.toString(mSize)); } return params; }
From source file:org.cloudfoundry.identity.uaa.integration.NativeApplicationIntegrationTests.java
/** * tests a happy-day flow of the Resource Owner Password Credentials grant type. (formerly native application * profile)./*from w ww .ja v a 2 s .com*/ */ @Test public void testHappyDay() throws Exception { MultiValueMap<String, String> formData = new LinkedMultiValueMap<String, String>(); formData.add("grant_type", "password"); formData.add("username", resource.getUsername()); formData.add("password", resource.getPassword()); formData.add("scope", "cloud_controller.read"); HttpHeaders headers = new HttpHeaders(); headers.set("Authorization", testAccounts.getAuthorizationHeader(resource.getClientId(), resource.getClientSecret())); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); ResponseEntity<String> response = serverRunning.postForString("/oauth/token", formData, headers); assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals("no-store", response.getHeaders().getFirst("Cache-Control")); }
From source file:com.gooddata.lcm.LcmEntityFilter.java
/** * This filter in the form of query parameters map. * @return filter as query params map// w ww. ja v a 2 s . com */ public MultiValueMap<String, String> asQueryParams() { final MultiValueMap<String, String> params = new LinkedMultiValueMap<>(); if (dataProduct != null) { params.put(DATA_PRODUCT, singletonList(dataProduct)); } if (segment != null) { params.put(SEGMENT, singletonList(segment)); } if (client != null) { params.put(CLIENT, singletonList(client)); } return params; }
From source file:info.smartkit.hairy_batman.query.KJsonApiQuery.java
private LinkedMultiValueMap<String, String> getParameters() { LinkedMultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>(); this.queriedSubscriber = this.subscribers.remove(0); LOG.info("this.queriedSubscriber: " + this.queriedSubscriber.toString()); parameters.add("urls", this.queriedSubscriber.getArticleUrl()); // "http://mp.weixin.qq.com/s?__biz=MjM5ODE4MTUzMg==&mid=202895379&idx=1&sn=a46187dd2e3fc704b72277dbf863f356&3rd=MzA3MDU4NTYzMw==&scene=6#rd"); return parameters; }
From source file:com.weibo.api.Statuses.java
/** * http://open.weibo.com/wiki/2/statuses/repost * @param id//from w ww. j av a 2s .c o m * @param status * @param isComment * @param rip * @param accessToken * @return */ public Status repost(String id, String status, IsComment isComment, String rip, String accessToken) { MultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>(); map.add("id", id); if (StringUtils.isNotBlank(status)) { map.add("status", status); } if (isComment == null) { isComment = IsComment.NO; } map.add("isComment", isComment.getCode()); if (StringUtils.isNotBlank(rip)) { map.add("rip", rip); } map.add("access_token", accessToken); return weiboHttpClient.postForm(STATUSES_REPORT_URL, map, Status.class); }
From source file:org.keycloak.adapters.springsecurity.service.KeycloakDirectAccessGrantService.java
@Override public RefreshableKeycloakSecurityContext login(String username, String password) throws VerificationException { final MultiValueMap<String, String> body = new LinkedMultiValueMap<>(); final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); body.set("username", username); body.set("password", password); body.set(OAuth2Constants.GRANT_TYPE, OAuth2Constants.PASSWORD); AccessTokenResponse response = template.postForObject(keycloakDeployment.getTokenUrl(), new HttpEntity<>(body, headers), AccessTokenResponse.class); return KeycloakSpringAdapterUtils.createKeycloakSecurityContext(keycloakDeployment, response); }
From source file:org.ow2.proactive.scheduling.api.graphql.client.SchedulingApiClient.java
public SchedulingApiResponse execute(Query query) throws SchedulingApiException { if (Strings.isNullOrEmpty(url)) { throw new SchedulingApiException("API server URL is not initialized"); }/*from ww w . j a v a2 s. co m*/ try { MultiValueMap<String, String> headers = new LinkedMultiValueMap<String, String>(); headers.add("sessionid", sessionId); headers.add("Content-Type", "application/json"); log.debug("request query : ", query.getQuery()); HttpEntity<Map<String, String>> request = new HttpEntity<>(query.getQueryMap(), headers); restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); return restTemplate.postForObject(url, request, SchedulingApiResponse.class); } catch (Exception e) { throw new SchedulingApiException("Exception", e); } }
From source file:org.kurento.repository.test.RangeGetTests.java
@Test public void test() throws Exception { String id = "logo.png"; RepositoryItem item;/*from w w w.j a v a2 s. com*/ try { item = getRepository().findRepositoryItemById(id); } catch (NoSuchElementException e) { item = getRepository().createRepositoryItem(id); uploadFile(new File("test-files/" + id), item); } RepositoryHttpPlayer player = item.createRepositoryHttpPlayer(); String url = player.getURL(); player.setAutoTerminationTimeout(100000); // Following sample // http://stackoverflow.com/questions/8293687/sample-http-range-request-session RestTemplate httpClient = getRestTemplate(); { HttpHeaders requestHeaders = new HttpHeaders(); MultiValueMap<String, String> postParameters = new LinkedMultiValueMap<String, String>(); HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>( postParameters, requestHeaders); ResponseEntity<byte[]> response = httpClient.exchange(url, HttpMethod.GET, requestEntity, byte[].class); System.out.println(response); assertTrue("The server doesn't accept ranges", response.getHeaders().containsKey("Accept-ranges")); assertTrue("The server doesn't accept ranges with bytes", response.getHeaders().get("Accept-ranges").contains("bytes")); } long fileLength = 0; { // Range: bytes=0- HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.set("Range", "bytes=0-"); MultiValueMap<String, String> postParameters = new LinkedMultiValueMap<String, String>(); HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>( postParameters, requestHeaders); ResponseEntity<byte[]> response = httpClient.exchange(url, HttpMethod.GET, requestEntity, byte[].class); System.out.println(response); assertEquals("The server doesn't respond with http status code 206 to a request with ranges", HttpStatus.PARTIAL_CONTENT, response.getStatusCode()); fileLength = Long.parseLong(response.getHeaders().get("Content-Length").get(0)); } { HttpHeaders requestHeaders = new HttpHeaders(); long firstByte = fileLength - 3000; long lastByte = fileLength - 1; long numBytes = lastByte - firstByte + 1; requestHeaders.set("Range", "bytes=" + firstByte + "-" + lastByte); MultiValueMap<String, String> postParameters = new LinkedMultiValueMap<String, String>(); HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>( postParameters, requestHeaders); ResponseEntity<byte[]> response = httpClient.exchange(url, HttpMethod.GET, requestEntity, byte[].class); System.out.println(response); assertEquals("The server doesn't respond with http status code 206 to a request with ranges", response.getStatusCode(), HttpStatus.PARTIAL_CONTENT); long responseContentLength = Long.parseLong(response.getHeaders().get("Content-Length").get(0)); assertEquals("The server doesn't send the requested bytes", numBytes, responseContentLength); assertEquals("The server doesn't send the requested bytes", responseContentLength, response.getBody().length); } }
From source file:info.smartkit.hairy_batman.query.SogouSearchQuery.java
public SogouSearchQuery(WxComplexSubscriber wxFoo) { this.wxFoo = wxFoo; this.parameters = new LinkedMultiValueMap<String, String>(); }