List of usage examples for org.springframework.util MultiValueMap add
void add(K key, @Nullable V value);
From source file:org.appverse.web.framework.backend.frontfacade.websocket.IntegrationWebsocketTest.java
private static void loginAndSaveJsessionIdCookie(final String user, final String password, final HttpHeaders headersToUpdate) { String url = "http://localhost:" + port + "/"; new RestTemplate().execute(url, HttpMethod.POST, new RequestCallback() { @Override/* ww w. j a v a 2 s. c o m*/ 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: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 ww . j av a2 s . c om } } else { multimap.add(key, unquote(value)); } }); return multimap; }
From source file:com.evozon.evoportal.my_account.util.MyAccountUtil.java
public static MultiValueMap<String, Object> getPMReportsParameters(AccountModelHolder oldModel, AccountModelHolder newModel, User selectedUser, UserAccountOperation commandType) { MultiValueMap<String, Object> mapModifications = new LinkedMultiValueMap<String, Object>(); if (!UserAccountOperation.ADD_USER.equals(commandType) && !hasPMReportsDataModified(oldModel, newModel)) { return mapModifications; }//ww w.j a va 2s .c om String userCNP = UserAccountOperation.USER_UPDATE.equals(commandType) ? oldModel.getDetailsModel().getCNP() : newModel.getDetailsModel().getCNP(); mapModifications.add(PMReportsConstants.USER_CNP, userCNP); mapModifications.add(PMReportsConstants.USER_EMAIL, newModel.getDetailsModel().getEmailAddress()); mapModifications.add(PMReportsConstants.USER_LAST_NAME, newModel.getDetailsModel().getLastName()); mapModifications.add(PMReportsConstants.USER_FIRST_NAME, newModel.getDetailsModel().getFirstName()); mapModifications.add(PMReportsConstants.USER_DATE_HIRED, convertDateToString(newModel.getFreeDaysModel().getStartDate(), DATE_FORMAT_MONTH_DAY_YEAR)); String pmDep = findPMReportsAssociatedDepartment(newModel, selectedUser); if (!pmDep.isEmpty()) { mapModifications.add(PMReportsConstants.DEPARTMENT_NAME, pmDep); } String countryCode = null; EvoAddressModel primaryAddress = newModel.getPrimaryAddress(); if (primaryAddress != null) { mapModifications.add(PMReportsConstants.USER_ZIP_CODE, primaryAddress.getPostalCode()); mapModifications.add(PMReportsConstants.USER_CITY_NAME, primaryAddress.getCity()); countryCode = primaryAddress.getCountryCode(); if (countryCode.isEmpty()) { countryCode = PMReportsConstants.USER_DEFAULT_COUNTRY_CODE; } mapModifications.add(PMReportsConstants.USER_STREET_NAME, primaryAddress.getStreetName()); mapModifications.add(PMReportsConstants.USER_STREET_NUMBER, primaryAddress.getStreetNumber()); } // The 'country code' is mandatory mapModifications.add(PMReportsConstants.USER_COUNTRY_CODE, (countryCode == null) ? PMReportsConstants.USER_DEFAULT_COUNTRY_CODE : countryCode); mapModifications.add(PMReportsConstants.USER_MOBILE_NUMBER, newModel.getDetailsModel().getPhoneNumber()); mapModifications.add(PMReportsConstants.USER_PLATE_NUMBER, newModel.getDetailsModel().getLicensePlate()); return mapModifications; }
From source file:eu.freme.eservices.epublishing.ServiceRestController.java
@RequestMapping(value = "/e-publishing/html", method = RequestMethod.POST) public ResponseEntity<byte[]> htmlToEPub(@RequestParam("htmlZip") MultipartFile file, @RequestParam("metadata") String jMetadata) throws IOException, InvalidZipException, EPubCreationException, MissingMetadataException { Gson gson = new Gson(); Metadata metadata = gson.fromJson(jMetadata, Metadata.class); MultiValueMap<String, String> headers = new HttpHeaders(); headers.add(HttpHeaders.CONTENT_TYPE, "Application/epub+zip"); try (InputStream in = file.getInputStream()) { return new ResponseEntity<>(epubAPI.createEPUB(metadata, in), headers, HttpStatus.OK); }//from ww w .j a va 2 s . c o m }
From source file:io.cfp.auth.service.ReCaptchaService.java
public boolean isCaptchaValid(String response) { MultiValueMap<String, String> map = new LinkedMultiValueMap<>(); map.add("secret", recaptchaSecret); map.add("response", response); @SuppressWarnings("unchecked") Map<String, Object> result = restTemplate.postForObject(RECAPTCHA_VERIF_URL, map, Map.class); return (boolean) result.get("success"); }
From source file:eu.freme.eservices.publishing.ServiceRestController.java
@RequestMapping(value = "/e-publishing/html", method = RequestMethod.POST) public ResponseEntity<byte[]> htmlToEPub(@RequestParam("htmlZip") MultipartFile file, @RequestParam("metadata") String jMetadata) throws IOException, InvalidZipException, EPubCreationException, MissingMetadataException { Gson gson = new Gson(); Metadata metadata = gson.fromJson(jMetadata, Metadata.class); MultiValueMap<String, String> headers = new HttpHeaders(); headers.add(HttpHeaders.CONTENT_TYPE, "Application/epub+zip"); String filename = file.getName(); headers.add(HttpHeaders.CONTENT_DISPOSITION, "Attachment; filename=" + filename.split("\\.")[0] + ".epub"); try (InputStream in = file.getInputStream()) { return new ResponseEntity<>(epubAPI.createEPUB(metadata, in), headers, HttpStatus.OK); }/*from www . j a v a2 s.c om*/ }
From source file:com.svds.resttest.operator.BuildWhereClauseNGTest.java
/** * Test of buildWhereClause method, of class BuildWhereClause. */// w w w . ja v a 2 s. c o m @Test public void testBuildWhereClause() throws Exception { System.out.println("buildWhereClause"); MultiValueMap<String, String> requestParams = new LinkedMultiValueMap<>(); requestParams.add("operator__episode_title", "stringlike"); requestParams.add("column__episode_title", "%Cybermen%"); String expResult = "episode_title LIKE '%Cybermen%' "; String result = BuildWhereClause.buildWhereClause(requestParams); assertEquals(result, expResult); }
From source file:io.github.cdelmas.spike.springboot.hello.SampleController.java
@RequestMapping("/") @ResponseBody/*from www .jav a 2 s . c om*/ String home(@RequestHeader("Authorization") String authToken) { MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); headers.add("Accept", "application/json"); headers.add("Authorization", authToken); HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(null, headers); RestTemplate rest = new RestTemplate(); ResponseEntity<Car[]> responseEntity = rest.exchange("https://localhost:8443/cars", HttpMethod.GET, requestEntity, Car[].class); List<Car> cars = asList(responseEntity.getBody()); return "Hello World! " + cars.stream().map(Car::getName).collect(toList()); }
From source file:cr.ac.siua.tec.services.impl.RecaptchaServiceImpl.java
/** * Creates a hashmap with the parameters required for the Recaptcha Verification. *//*from ww w. j av a2 s .c om*/ 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; }