List of usage examples for org.springframework.util LinkedMultiValueMap LinkedMultiValueMap
public LinkedMultiValueMap()
From source file:com.weibo.api.Statuses.java
/** * http://open.weibo.com/wiki/2/statuses/destroy * @param id//from w w w. j a v a 2 s . c om * @param accessToken * @return */ public Status destroy(String id, String accessToken) { MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>(); map.add("id", id); map.add("access_token", accessToken); return weiboHttpClient.postForm(STATUSES_DESTROY_URL, map, Status.class); }
From source file:com.taxamo.example.ec.ApplicationController.java
/** * This method initializes Express Checkout token with PayPal and then redirects to Taxamo checkout form. * * Please note that only Express Checkout token is provided to Taxamo - and Taxamo will use * provided PayPal credentials to get order details from it and render the checkout form. * * * @param model//w w w . ja v a2 s .c om * @return */ @RequestMapping("/express-checkout") public String expressCheckout(Model model) { RestTemplate template = new RestTemplate(); MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>(); map.add("USER", ppUser); map.add("PWD", ppPass); map.add("SIGNATURE", ppSign); map.add("VERSION", "117"); map.add("METHOD", "SetExpressCheckout"); map.add("returnUrl", properties.getProperty(PropertiesConstants.STORE) + properties.getProperty(PropertiesConstants.CONFIRM_LINK)); map.add("cancelUrl", properties.getProperty(PropertiesConstants.STORE) + properties.getProperty(PropertiesConstants.CANCEL_LINK)); //shopping item(s) map.add("PAYMENTREQUEST_0_AMT", "20.00"); // total amount map.add("PAYMENTREQUEST_0_PAYMENTACTION", "Sale"); map.add("PAYMENTREQUEST_0_CURRENCYCODE", "EUR"); map.add("L_PAYMENTREQUEST_0_NAME0", "ProdName"); map.add("L_PAYMENTREQUEST_0_DESC0", "ProdName desc"); map.add("L_PAYMENTREQUEST_0_AMT0", "20.00"); map.add("L_PAYMENTREQUEST_0_QTY0", "1"); map.add("L_PAYMENTREQUEST_0_ITEMCATEGORY0", "Digital"); List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>(); messageConverters.add(new FormHttpMessageConverter()); messageConverters.add(new StringHttpMessageConverter()); template.setMessageConverters(messageConverters); HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED); HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(map, requestHeaders); ResponseEntity<String> res = template.exchange( URI.create(properties.get(PropertiesConstants.PAYPAL_NVP).toString()), HttpMethod.POST, request, String.class); Map<String, List<String>> params = parseQueryParams(res.getBody()); String ack = params.get("ACK").get(0); if (!ack.equals("Success")) { model.addAttribute("error", params.get("L_LONGMESSAGE0").get(0)); return "error"; } else { String token = params.get("TOKEN").get(0); return "redirect:" + properties.get(PropertiesConstants.TAXAMO) + "/checkout/index.html?" + "token=" + token + "&public_token=" + publicToken + "&cancel_url=" + new String( Base64.encodeBase64((properties.getProperty(PropertiesConstants.STORE) + properties.getProperty(PropertiesConstants.CANCEL_LINK)).getBytes())) + "&return_url=" + new String(Base64.encodeBase64((properties.getProperty(PropertiesConstants.STORE) + properties.getProperty(PropertiesConstants.CONFIRM_LINK)).getBytes())) + "#/paypal_express_checkout"; } }
From source file:comsat.sample.ui.SampleGroovyTemplateApplicationTests.java
@Test public void testCreateValidation() throws Exception { MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>(); map.set("text", ""); map.set("summary", ""); ResponseEntity<String> entity = new TestRestTemplate().postForEntity("http://localhost:" + this.port, map, String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertTrue("Wrong body ('required' validation error doesn't match):\n" + entity.getBody(), entity.getBody().contains("is required")); }
From source file:org.trustedanalytics.h2oscoringengine.publisher.restapi.validation.HostValidationRuleTest.java
@Test public void validate_invalidUrlInHostKeyInData_exceptionThrown() { //given/*from w w w .ja va 2 s . co m*/ MultiValueMap<String, String> requestWithInvalidUrl = new LinkedMultiValueMap<>(); requestWithInvalidUrl.add(HostValidationRule.HOST_KEY, "lsakjfajkadf"); HostValidationRule rule = new HostValidationRule(new FormDataValidator()); //then thrown.expect(ValidationException.class); //when rule.validate(requestWithInvalidUrl); }
From source file:io.lavagna.web.security.login.PersonaLogin.java
@Override public boolean doAction(HttpServletRequest req, HttpServletResponse resp) throws IOException { if (!("POST".equalsIgnoreCase(req.getMethod()) && req.getParameterMap().containsKey("assertion"))) { resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); return true; }// w w w. ja va2 s. com String audience = configurationRepository.getValue(Key.PERSONA_AUDIENCE); MultiValueMap<String, String> toPost = new LinkedMultiValueMap<>(); toPost.add("assertion", req.getParameter("assertion")); toPost.add("audience", audience); VerifierResponse verifier = restTemplate.postForObject("https://verifier.login.persona.org/verify", toPost, VerifierResponse.class); if ("okay".equals(verifier.status) && audience.equals(verifier.audience) && userRepository.userExistsAndEnabled(USER_PROVIDER, verifier.email)) { String url = Redirector.cleanupRequestedUrl(req.getParameter("reqUrl")); UserSession.setUser(userRepository.findUserByName(USER_PROVIDER, verifier.email), req, resp, userRepository); resp.setStatus(HttpServletResponse.SC_OK); resp.setContentType("application/json"); JsonObject jsonObject = new JsonObject(); jsonObject.add("redirectTo", new JsonPrimitive(url)); resp.getWriter().write(jsonObject.toString()); } else { resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); } return true; }
From source file:org.meruvian.yama.service.jpa.social.JpaSocialConnectionManager.java
@Override public MultiValueMap<String, Connection<?>> findAllConnections() { List<JpaSocialConnection> socialConnections = connectionRepository.findByUserIdOrderByRankAsc(userId); MultiValueMap<String, Connection<?>> connections = new LinkedMultiValueMap<String, Connection<?>>(); Set<String> registeredProviderIds = connectionFactoryLocator.registeredProviderIds(); for (String registeredProviderId : registeredProviderIds) { connections.put(registeredProviderId, Collections.<Connection<?>>emptyList()); }//from w w w.ja va 2 s . c o m for (SocialConnection uc : socialConnections) { Connection<?> connection = connectionMapper.mapRow(uc); String providerId = connection.getKey().getProviderId(); if (connections.get(providerId).size() == 0) { connections.put(providerId, new LinkedList<Connection<?>>()); } connections.add(providerId, connection); } return connections; }
From source file:net.gplatform.spring.social.weibo.connect.WeiboOAuth2Template.java
@Override protected RestTemplate createRestTemplate() { RestTemplate restTemplate = new RestTemplate(ClientHttpRequestFactorySelector.getRequestFactory()); HttpMessageConverter<?> messageConverter = new FormHttpMessageConverter() { private final ObjectMapper objectMapper = new ObjectMapper(); @Override/*from w w w . j a v a 2 s .c o m*/ public boolean canRead(Class<?> clazz, MediaType mediaType) { return true; } @Override public MultiValueMap<String, String> read(Class<? extends MultiValueMap<String, ?>> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { TypeReference<Map<String, ?>> mapType = new TypeReference<Map<String, ?>>() { }; LinkedHashMap<String, ?> readValue = objectMapper.readValue(inputMessage.getBody(), mapType); LinkedMultiValueMap<String, String> result = new LinkedMultiValueMap<String, String>(); for (Entry<String, ?> currentEntry : readValue.entrySet()) { result.add(currentEntry.getKey(), currentEntry.getValue().toString()); } return result; } }; restTemplate.setMessageConverters(Collections.<HttpMessageConverter<?>>singletonList(messageConverter)); return restTemplate; }
From source file:org.n52.io.request.IoParametersTest.java
@Test public void when_creationViaFromMultiValuedMap_then_keysGetLowerCased() { MultiValueMap<String, String> map = new LinkedMultiValueMap<>(); map.add("camelCased", "value"); map.add("UPPERCASED", "value"); IoParameters parameters = createFromMultiValueMap(map); Assert.assertTrue(parameters.containsParameter("camelCased")); Assert.assertTrue(parameters.containsParameter("camelcased")); Assert.assertTrue(parameters.containsParameter("UPPERCASED")); Assert.assertTrue(parameters.containsParameter("uppercased")); }