List of usage examples for org.springframework.util LinkedMultiValueMap LinkedMultiValueMap
public LinkedMultiValueMap()
From source file:com.mycompany.trader.TradingConnect.java
private static void loginAndSaveJsessionIdCookie(final String user, final String password, final HttpHeaders headersToUpdate) { String url = "http://localhost:" + port + "/blueprint-trading-services/login.html"; new RestTemplate().execute(url, HttpMethod.POST, new RequestCallback() { @Override/*from www . jav a 2 s .c om*/ public void doWithRequest(ClientHttpRequest request) throws IOException { MultiValueMap<String, String> map = new LinkedMultiValueMap<>(); map.add("username", user); map.add("password", password); new FormHttpMessageConverter().write(map, MediaType.APPLICATION_FORM_URLENCODED, request); } }, new ResponseExtractor<Object>() { @Override public Object extractData(ClientHttpResponse response) throws IOException { headersToUpdate.add("Cookie", response.getHeaders().getFirst("Set-Cookie")); return null; } }); }
From source file:org.nekorp.workflow.desktop.data.access.rest.ImagenDAOImp.java
@Override public ImagenMetadata saveImage(BufferedImage image) { try {// w w w. j ava 2 s . co m ImagenMetadata r = factory.getTemplate().getForObject(factory.getRootUlr() + "/upload/url", ImagenMetadata.class); File file = new File("data/upload.jpg"); ImageIO.write(image, "jpg", file); MultiValueMap<String, Object> form = new LinkedMultiValueMap<>(); form.add("myFile", new FileSystemResource(file)); r = factory.getTemplate().postForObject(r.getUploadUrl(), form, ImagenMetadata.class); File cache = new File("data/" + r.getRawBlobKey()); file.renameTo(cache); return r; } catch (IOException ex) { throw new RuntimeException(ex); } }
From source file:com.weibo.api.Messages.java
/** * http://open.weibo.com/wiki/2/messages/invite * @param uid/*from www . j ava2s. c o m*/ * @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:com.expedia.seiso.web.hateoas.link.PaginationLinkBuilderTests.java
@Before public void setUp() throws Exception { val uri = new URI("https://seiso.example.com/v2/cars/find-by-name"); this.uriComponents = UriComponentsBuilder.fromUri(uri).build(); this.params = new LinkedMultiValueMap<String, String>(); params.set("name", "honda"); this.builder = paginationLinkBuilder(3, 20, 204); }
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.bailen.radioOnline.recursos.REJA.java
public Incidencia ratings(String apiKey, String rating, String idCancion, String fav) { MultiValueMap<String, String> params1 = new LinkedMultiValueMap<>(); params1.add("rating", (rating)); params1.add("idCancion", (idCancion)); params1.add("fav", (fav)); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); headers.add("Authorization", apiKey); HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(params1, headers); String result = new RestTemplate().postForObject("http://ceatic.ujaen.es:8075/radioapi/v2/ratings", request, String.class); try {/*w w w .jav a 2 s.c o m*/ ObjectMapper a = new ObjectMapper(); Incidencia listilla = a.readValue(result, Incidencia.class); return listilla; } catch (Exception e) { return null; } }
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 av a 2 s .co m } assertThat(testListener.getCounter() > 1, is(true)); }
From source file:com.work.petclinic.MessageControllerWebTests.java
@Test public void testCreate() throws Exception { ResponseEntity<String> page = executeLogin("user", "user"); page = getPage("http://localhost:" + this.port + "/messages?form"); String body = page.getBody(); assertNotNull("Body was null", body); MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>(); form.set("summary", "summary"); form.set("messageText", "messageText"); form.set("_csrf", csrfValue); String formAction = getFormAction(page); page = postPage(formAction, form);// www . java2s. co m body = page.getBody(); assertTrue("Error creating message.", body == null || body.contains("alert alert-danger")); assertTrue("Status was not FOUND (redirect), means message was not created properly.", page.getStatusCode() == HttpStatus.FOUND); page = getPage(page.getHeaders().getLocation()); body = page.getBody(); assertTrue("Error creating message.", body.contains("Successfully created a new message")); }
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 .j av a 2 s . com*/ * @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.github.gabrielruiu.springsocial.yahoo.api.impl.AbstractYahooOperations.java
protected URI buildUri(String path, String parameterName, String parameterValue) { MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>(); parameters.set(parameterName, parameterValue); return buildUri(path, parameters); }