List of usage examples for org.springframework.util LinkedMultiValueMap LinkedMultiValueMap
public LinkedMultiValueMap()
From source file:org.jnrain.mobile.accounts.kbs.KBSRegisterRequest.java
@Override public KBSRegisterResult loadDataFromNetwork() throws Exception { MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(); if (isPreflight) { // preflight request, only prereg flag is sent params.set("prereg", "1"); } else {/*w w w. ja va2 s . c o m*/ // please keep this in sync with rainstyle/apiregister.php params.set("userid", _uid); params.set("password", _password); params.set("nickname", _nickname); params.set("realname", _realname); params.set("email", _email); params.set("phone", _phone); params.set("idnumber", _idnumber); params.set("gender", Integer.toString(_gender)); params.set("captcha", _captcha); } HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); HttpEntity<MultiValueMap<String, String>> req = new HttpEntity<MultiValueMap<String, String>>(params, headers); return getRestTemplate().postForObject("http://bbs.jnrain.com/rainstyle/apiregister.php", req, KBSRegisterResult.class); }
From source file:com.work.petclinic.SampleWebUiApplicationTests.java
@After public void cleanSession() throws Exception { ResponseEntity<String> page = sendRequest("http://localhost:" + this.port, HttpMethod.GET); MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>(); form.set("_csrf", csrfValue); httpHeaders.set("X-CSRF-TOKEN", csrfValue); page = sendRequest("http://localhost:" + this.port + "/logout", HttpMethod.GET, form); assertEquals(HttpStatus.FOUND, page.getStatusCode()); if (page.getStatusCode() == HttpStatus.FOUND) { page = sendRequest(page.getHeaders().getLocation(), HttpMethod.GET); }/*ww w . j a v a 2 s .co m*/ httpHeaders = null; csrfValue = null; }
From source file:de.codecentric.batch.test.JobParametersIncrementerIntegrationTest.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/incrementerJob", requestMap, Long.class); while (!restTemplate .getForObject("http://localhost:" + port + "/batch/operations/jobs/executions/{executionId}", String.class, executionId) .equals("COMPLETED")) { Thread.sleep(1000);/*from w w w . j a v a 2 s . c o m*/ } JobExecution jobExecution = jobExplorer.getJobExecution(executionId); assertThat(jobExecution.getStatus(), is(BatchStatus.COMPLETED)); assertThat(jobExecution.getJobParameters().getLong("run.id"), is(1l)); assertThat(jobExecution.getJobParameters().getString("param1"), is("value1")); executionId = restTemplate.postForObject( "http://localhost:" + port + "/batch/operations/jobs/incrementerJob", "", Long.class); while (!restTemplate .getForObject("http://localhost:" + port + "/batch/operations/jobs/executions/{executionId}", String.class, executionId) .equals("COMPLETED")) { Thread.sleep(1000); } jobExecution = jobExplorer.getJobExecution(executionId); assertThat(jobExecution.getStatus(), is(BatchStatus.COMPLETED)); assertThat(jobExecution.getJobParameters().getLong("run.id"), is(2l)); requestMap = new LinkedMultiValueMap<>(); requestMap.add("jobParameters", "param1=value1,param2=value2"); executionId = restTemplate.postForObject( "http://localhost:" + port + "/batch/operations/jobs/incrementerJob", requestMap, Long.class); while (!restTemplate .getForObject("http://localhost:" + port + "/batch/operations/jobs/executions/{executionId}", String.class, executionId) .equals("COMPLETED")) { Thread.sleep(1000); } jobExecution = jobExplorer.getJobExecution(executionId); assertThat(jobExecution.getStatus(), is(BatchStatus.COMPLETED)); assertThat(jobExecution.getJobParameters().getLong("run.id"), is(3l)); assertThat(jobExecution.getJobParameters().getString("param1"), is("value1")); assertThat(jobExecution.getJobParameters().getString("param2"), is("value2")); }
From source file:at.create.android.ffc.http.FormBasedAuthentication.java
/** * Authentication via username and password. * @return True if the authentication succeeded, otherwise false is returned. *///from w ww.j a v a 2 s.c o m public boolean authenticate() { MultiValueMap<String, String> formData = new LinkedMultiValueMap<String, String>(); formData.add("authentication[username]", username); formData.add("authentication[password]", password); formData.add("authentication[remember_me]", "1"); restTemplate.getMessageConverters().add(new FormHttpMessageConverter()); restTemplate.postForLocation(getUrl(), formData); if (CookiePreserveHttpRequestInterceptor.getInstance().hasCookieWithName("user_credentials")) { return true; // Try with another method } else { restTemplate.getMessageConverters().add(new StringHttpMessageConverter()); HttpEntity<?> requestEntity = new HttpEntity<Object>(requestHeaders); ResponseEntity<String> responseEntity = restTemplate.exchange(baseUri, HttpMethod.GET, requestEntity, String.class); return !responseEntity.getBody().toString().contains("authentication[username]"); } }
From source file:org.cloudfoundry.identity.uaa.login.test.TestClient.java
public String getOAuthAccessToken(String username, String password, String grantType, String scope) { HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", getBasicAuthHeaderValue(username, password)); MultiValueMap<String, String> postParameters = new LinkedMultiValueMap<String, String>(); postParameters.add("grant_type", grantType); postParameters.add("client_id", username); postParameters.add("scope", scope); HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>( postParameters, headers);//from w ww. j a va 2 s . c o m ResponseEntity<Map> exchange = restTemplate.exchange(baseUrl + "/oauth/token", HttpMethod.POST, requestEntity, Map.class); return exchange.getBody().get("access_token").toString(); }
From source file:cr.ac.siua.tec.services.impl.RecaptchaServiceImpl.java
/** * Creates a hashmap with the parameters required for the Recaptcha Verification. *//*from w ww.j a v a2s . c o m*/ private MultiValueMap<String, String> createBody(String secret, String remoteIp, String response) { MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); form.add("secret", secret); form.add("remoteip", remoteIp); form.add("response", response); return form; }
From source file:com.naver.template.social.SocialPostBO.java
public void postToFacebook(String userId) { Facebook facebook = simpleSocialConnectionFactory.getFacebook(userId); String imageUrl = "http://cfile9.uf.tistory.com/image/1771223E4E3EAE20032F8B"; String linkUrl = ""; String linkName = "?"; String caption = "lovepin.it"; String description = "? blah blah"; String actions = "[{ name: 'Get the LOVEPIN App', link: 'http://lovepin.it/apps' }]"; MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>(); map.set("picture", imageUrl); map.set("link", linkUrl); map.set("name", linkName); map.set("caption", caption); map.set("description", description); map.set("actions", actions); String providerUserId = simpleSocialConnectionFactory.getConnectionRepository(userId) .getPrimaryConnection(Facebook.class).getKey().getProviderUserId(); try {/*from ww w .j a va 2s. c o m*/ facebook.post(providerUserId, "feed", map); } catch (NotAuthorizedException ex) { // } catch (OperationNotPermittedException ex) { // } catch (ApiException ex) { // } catch (ResourceAccessException ex) { // } }
From source file:com.jkthome.cmm.web.JkthomeMultipartResolver.java
/** * multipart? parsing? .//from ww w. j a v a2 s . c o m */ @SuppressWarnings("rawtypes") @Override protected MultipartParsingResult parseFileItems(List fileItems, String encoding) { //? 3.0 MultiValueMap<String, MultipartFile> multipartFiles = new LinkedMultiValueMap<String, MultipartFile>(); Map<String, String[]> multipartParameters = new HashMap<String, String[]>(); // Extract multipart files and multipart parameters. for (Iterator<?> it = fileItems.iterator(); it.hasNext();) { FileItem fileItem = (FileItem) it.next(); if (fileItem.isFormField()) { String value = null; if (encoding != null) { try { value = fileItem.getString(encoding); } catch (UnsupportedEncodingException ex) { LOGGER.warn( "Could not decode multipart item '{}' with encoding '{}': using platform default", fileItem.getFieldName(), encoding); value = fileItem.getString(); } } else { value = fileItem.getString(); } String[] curParam = (String[]) multipartParameters.get(fileItem.getFieldName()); if (curParam == null) { // simple form field multipartParameters.put(fileItem.getFieldName(), new String[] { value }); } else { // array of simple form fields String[] newParam = StringUtils.addStringToArray(curParam, value); multipartParameters.put(fileItem.getFieldName(), newParam); } } else { if (fileItem.getSize() > 0) { // multipart file field CommonsMultipartFile file = new CommonsMultipartFile(fileItem); //? 3.0 ? API? List<MultipartFile> fileList = new ArrayList<MultipartFile>(); fileList.add(file); if (multipartFiles.put(fileItem.getName(), fileList) != null) { // CHANGED!! throw new MultipartException("Multiple files for field name [" + file.getName() + "] found - not supported by MultipartResolver"); } LOGGER.debug( "Found multipart file [{}] of size {} bytes with original filename [{}], stored {}", file.getName(), file.getSize(), file.getOriginalFilename(), file.getStorageDescription()); } } } return new MultipartParsingResult(multipartFiles, multipartParameters, null); }
From source file:com.miserablemind.api.consumer.tradeking.api.impl.MarketTemplate.java
@Override public StockQuote[] getQuoteForStocks(String[] tickers) { String tickersParamString = this.buildCommaSeparatedParameterValue(tickers); MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>(); parameters.set("symbols", tickersParamString); URI url = this.buildUri(URL_QUOTES, parameters); ResponseEntity<TKStockQuoteResponse> response = this.getRestTemplate().getForEntity(url, TKStockQuoteResponse.class); if (null != response.getBody().getError()) throw new ApiException(TradeKingServiceProvider.PROVIDER_ID, response.getBody().getError()); return response.getBody().getQuotes(); }
From source file:com.miserablemind.api.consumer.tradeking.api.impl.WatchlistTemplate.java
@Override public String[] addList(String watchlistName, String[] tickers) { Assert.notNull(tickers);//www . j a va 2 s . c om URI url = this.buildUri(URL_WATCHLIST_LIST); MultiValueMap<String, Object> requestObject = new LinkedMultiValueMap<>(); requestObject.add("id", watchlistName); requestObject.add("symbols", this.buildCommaSeparatedParameterValue(tickers)); ResponseEntity<TKAllWatchListsResponse> response = this.getRestTemplate().postForEntity(url, requestObject, TKAllWatchListsResponse.class); if (response.getBody().getError() != null) throw new ApiException(TradeKingServiceProvider.PROVIDER_ID, response.getBody().getError()); return response.getBody().getWatchLists(); }