List of usage examples for org.springframework.util MultiValueMap set
void set(K key, @Nullable V value);
From source file:org.encuestame.social.api.templates.FacebookAPITemplate.java
public TweetPublishedMetadata updateStatus(final String message) { log.debug("facebook message to publish: " + message); MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>(); map.set("message", message); return this.publish(CURRENT_USER_ID, FEED, map); }
From source file:org.encuestame.social.api.templates.FacebookAPITemplate.java
public void updateStatus(String message, FacebookLink link) { MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>(); map.set("link", link.getLink()); map.set("name", link.getName()); map.set("caption", link.getCaption()); map.set("description", link.getDescription()); map.set("message", message); this.publish(CURRENT_USER_ID, FEED, map); }
From source file:org.exem.flamingo.web.configuration.ConfigurationController.java
/** * ?? ?? JavaScript ./*from w w w . j a v a 2 s .com*/ */ @RequestMapping(value = "js", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public ResponseEntity<String> getJs(final HttpServletRequest request, final HttpServletResponse response, final Locale locale) throws IOException { Gson gson = new Gson(); MultiValueMap headers = new HttpHeaders(); headers.set("Content-Type", CONTENT_TYPE); Map configMap = gson.fromJson(configJson, Map.class); String configurationJson = JsonUtils.format(configMap); return new ResponseEntity(JS_PREFIX + configurationJson + JS_POSTFIX, headers, HttpStatus.OK); }
From source file:org.opentestsystem.shared.security.oauth.client.grant.samlbearer.SamlAssertionAccessTokenProvider.java
private MultiValueMap<String, String> getParametersForTokenRequest( final BaseOAuth2ProtectedResourceDetails resource, final String assertion) { final MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>(); form.set("grant_type", SAML2_BEARER_GRANT_TYPE); form.set("assertion", assertion); form.set("client_id", resource.getClientId()); LOGGER.info("YEAH... " + resource.getClientId()); if (resource.isScoped()) { final String scopeString = resource.getScope() != null ? StringUtils.collectionToDelimitedString(resource.getScope(), " ") : ""; form.set("scope", scopeString); LOGGER.info("YEAH... scope " + scopeString); }/*w w w .java 2s . c om*/ return form; }
From source file:org.springframework.cloud.netflix.zuul.filters.ProxyRequestHelper.java
public MultiValueMap<String, String> buildZuulRequestHeaders(HttpServletRequest request) { RequestContext context = RequestContext.getCurrentContext(); MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); Enumeration<?> headerNames = request.getHeaderNames(); if (headerNames != null) { while (headerNames.hasMoreElements()) { String name = (String) headerNames.nextElement(); String value = request.getHeader(name); if (isIncludedHeader(name)) headers.set(name, value); }//from w ww . j a v a 2 s . c o m } Map<String, String> zuulRequestHeaders = context.getZuulRequestHeaders(); for (String header : zuulRequestHeaders.keySet()) { headers.set(header, zuulRequestHeaders.get(header)); } headers.set("accept-encoding", "deflate, gzip"); return headers; }
From source file:org.springframework.cloud.netflix.zuul.FormZuulServletProxyApplicationTests.java
@Test public void postWithForm() { MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); form.set("foo", "bar"); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); ResponseEntity<String> result = testRestTemplate.exchange("/zuul/simplefzspat/form", HttpMethod.POST, new HttpEntity<>(form, headers), String.class); assertEquals(HttpStatus.OK, result.getStatusCode()); assertEquals("Posted! {foo=[bar]}", result.getBody()); }
From source file:org.springframework.cloud.netflix.zuul.FormZuulServletProxyApplicationTests.java
@Test public void postWithMultipartForm() { MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); form.set("foo", "bar"); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.MULTIPART_FORM_DATA); ResponseEntity<String> result = testRestTemplate.exchange("/zuul/simplefzspat/form", HttpMethod.POST, new HttpEntity<>(form, headers), String.class); assertEquals(HttpStatus.OK, result.getStatusCode()); assertEquals("Posted! {foo=[bar]}", result.getBody()); }
From source file:org.springframework.cloud.netflix.zuul.FormZuulServletProxyApplicationTests.java
@Test public void postWithMultipartFile() { MultiValueMap<String, Object> form = new LinkedMultiValueMap<>(); HttpHeaders part = new HttpHeaders(); part.setContentType(MediaType.TEXT_PLAIN); part.setContentDispositionFormData("file", "foo.txt"); form.set("foo", new HttpEntity<>("bar".getBytes(), part)); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.MULTIPART_FORM_DATA); headers.set("Transfer-Encoding", "chunked"); headers.setContentLength(-1);/* w w w . j ava 2 s. co m*/ ResponseEntity<String> result = testRestTemplate.exchange("/zuul/simplefzspat/file", HttpMethod.POST, new HttpEntity<>(form, headers), String.class); assertEquals(HttpStatus.OK, result.getStatusCode()); assertEquals("Posted! bar", result.getBody()); }
From source file:org.springframework.cloud.netflix.zuul.FormZuulServletProxyApplicationTests.java
@Test public void postWithUTF8Form() { MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); form.set("foo", "bar"); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.valueOf(MediaType.APPLICATION_FORM_URLENCODED_VALUE + "; charset=UTF-8")); ResponseEntity<String> result = testRestTemplate.exchange("/zuul/simplefzspat/form", HttpMethod.POST, new HttpEntity<>(form, headers), String.class); assertEquals(HttpStatus.OK, result.getStatusCode()); assertEquals("Posted! {foo=[bar]}", result.getBody()); }
From source file:org.springframework.http.converter.FormHttpMessageConverterTests.java
@Test public void writeForm() throws IOException { MultiValueMap<String, String> body = new LinkedMultiValueMap<>(); body.set("name 1", "value 1"); body.add("name 2", "value 2+1"); body.add("name 2", "value 2+2"); body.add("name 3", null); MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); this.converter.write(body, MediaType.APPLICATION_FORM_URLENCODED, outputMessage); assertEquals("Invalid result", "name+1=value+1&name+2=value+2%2B1&name+2=value+2%2B2&name+3", outputMessage.getBodyAsString(StandardCharsets.UTF_8)); assertEquals("Invalid content-type", new MediaType("application", "x-www-form-urlencoded"), outputMessage.getHeaders().getContentType()); assertEquals("Invalid content-length", outputMessage.getBodyAsBytes().length, outputMessage.getHeaders().getContentLength()); }