List of usage examples for org.springframework.util LinkedMultiValueMap LinkedMultiValueMap
public LinkedMultiValueMap()
From source file:com.apress.prospringintegration.web.MultipartHttpClient.java
public static void main(String[] args) { RestTemplate template = new RestTemplate(); String uri = "http://localhost:8080/http-adapter-1.0.0/inboundMultipartAdapter.html"; Resource picture = new ClassPathResource("com/apress/prospringintegration/web/test.png"); MultiValueMap map = new LinkedMultiValueMap(); map.add("name", "John Smith"); map.add("picture", picture); HttpHeaders headers = new HttpHeaders(); headers.setContentType(new MediaType("multipart", "form-data")); HttpEntity request = new HttpEntity(map, headers); ResponseEntity<?> httpResponse = template.exchange(uri, HttpMethod.POST, request, null); System.out.println("Status: " + httpResponse.getStatusCode().name()); }
From source file:eu.falcon.semantic.client.DenaClient.java
public static String publishOntology(String fileClassPath, String format, String dataset) { RestTemplate restTemplate = new RestTemplate(); LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>(); final String uri = "http://localhost:8090/api/v1/ontology/publish"; //final String uri = "http://falconsemanticmanager.euprojects.net/api/v1/ontology/publish"; map.add("file", new ClassPathResource(fileClassPath)); map.add("format", format); map.add("dataset", dataset); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.MULTIPART_FORM_DATA); HttpEntity<LinkedMultiValueMap<String, Object>> entity = new HttpEntity<LinkedMultiValueMap<String, Object>>( map, headers);//ww w .ja v a2 s . c o m String result = restTemplate.postForObject(uri, entity, String.class); return result; }
From source file:edu.infsci2560.LoginHelper.java
public static ResponseEntity<String> login(TestRestTemplate template, String route, String userName, String password) {/*from w ww . jav a 2 s. com*/ HttpHeaders headers = getHeaders(template, route); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>(); form.set("username", userName); form.set("password", password); ResponseEntity<String> entity = template.exchange(route, HttpMethod.POST, new HttpEntity<MultiValueMap<String, String>>(form, headers), String.class); return entity; }
From source file:cz.cvut.jirutjak.fastimport.droid.oauth2.AccessTokenUtils.java
public static MultiValueMap<String, String> createAccessTokenRequestForm(String authCode, OAuth2ResourceDetails resource) { MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>(); form.add("code", authCode); form.add("client_id", resource.getClientId()); form.add("client_secret", resource.getClientSecret()); form.add("redirect_uri", resource.getRedirectUri()); form.add("grant_type", GRANT_TYPE); return form;//from w ww .j ava 2 s.c o m }
From source file:com.iflytek.rest.demo.UserServiceTest.java
public static void requestRestApi(String access_token) { RestTemplate restTemplate = new RestTemplate(); MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>(); form.add("method", "user.get"); form.add("version", "1.0.0"); form.add("locale", "zh_CN"); form.add("format", "json"); form.add("appkey", "Hb0YhmOo"); //-Dexcludes.appkey=Hb0YhmOo form.add("access_token", access_token); form.add("id", "10001"); String result = restTemplate.postForObject("http://localhost:8090/api", form, String.class); System.out.println(result);// w ww . j av a2s . c o m }
From source file:io.curly.bloodhound.query.QueryParser.java
@NotNull static MultiValueMap<String, String> resolveMultiParameter(String query) { final MultiValueMap<String, String> multimap = new LinkedMultiValueMap<>(); convertToMap(query).forEach((key, value) -> { if (value.contains(L_CURLY) && value.contains(R_CURLY)) { Matcher matcher = Pattern.compile(REGEX_INNER_CURLY).matcher(value); if (matcher.find()) { String cleaned = cleanDelimiters(matcher.group()); if (cleaned.contains(COMMA)) { multimap.put(key, getCommaDelimitedValue(cleaned)); } else { multimap.put(key, getSpaceSplicedValue(cleaned)); }//w w w .ja va 2 s.c o m } } else { multimap.add(key, unquote(value)); } }); return multimap; }
From source file:eu.falcon.semantic.client.DenaClient.java
public static String addInstances(String fileClassPath, String format) { RestTemplate restTemplate = new RestTemplate(); LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>(); //final String uri = "http://localhost:8090/api/v1/ontology/instances/publish"; final String uri = "http://falconsemanticmanager.euprojects.net/api/v1/ontology/instances/publish"; map.add("file", new ClassPathResource(fileClassPath)); map.add("format", format); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.MULTIPART_FORM_DATA); HttpEntity<LinkedMultiValueMap<String, Object>> entity = new HttpEntity<LinkedMultiValueMap<String, Object>>( map, headers);//from www . j a v a 2 s .c om String result = restTemplate.postForObject(uri, entity, String.class); return result; }
From source file:org.wallride.web.support.ControllerUtils.java
public static MultiValueMap<String, String> convertBeanForQueryParams(Object target, ConversionService conversionService) { BeanWrapperImpl beanWrapper = new BeanWrapperImpl(target); beanWrapper.setConversionService(conversionService); MultiValueMap<String, String> queryParams = new LinkedMultiValueMap(); for (PropertyDescriptor pd : beanWrapper.getPropertyDescriptors()) { if (beanWrapper.isWritableProperty(pd.getName())) { Object pv = beanWrapper.getPropertyValue(pd.getName()); if (pv != null) { if (pv instanceof Collection) { if (!CollectionUtils.isEmpty((Collection) pv)) { for (Object element : (Collection) pv) { queryParams.set(pd.getName(), convertPropertyValueForString(target, pd, element)); }/* w ww .jav a 2 s . c o m*/ } } else { queryParams.set(pd.getName(), convertPropertyValueForString(target, pd, pv)); } } } } return queryParams; }
From source file:eu.cloudwave.wp5.common.rest.RestRequestBody.java
private RestRequestBody() { this.parameters = new LinkedMultiValueMap<String, String>(); }
From source file:com.iflytek.rest.demo.UserServiceTest.java
public static String requestAccessToken() { RestTemplate restTemplate = new RestTemplate(); MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>(); form.add("client_id", "Hb0YhmOo"); form.add("client_secret", "R7odNVS0KPtgXJ1TKQbHAxFP6EHdSW5d"); form.add("grant_type", "client_credentials"); //?password & client_credentials //grant_typeclient_credentials????username & password? form.add("username", "admin_test_333"); form.add("password", "passw0rd"); String result = restTemplate.postForObject(OAUTH_SERVER_URL, form, String.class); System.out.println(result);/*w ww. ja v a 2 s .c o m*/ String access_token = JSON.parseObject(result).getString("access_token"); return access_token; }