List of usage examples for org.springframework.util LinkedMultiValueMap LinkedMultiValueMap
public LinkedMultiValueMap()
From source file:com.weibo.api.OAuth2.java
/** * http://open.weibo.com/wiki/Oauth2/revokeoauth2 * @param accessToken/*from ww w. ja v a 2s . com*/ * @return */ public String revokeOauth2(String accessToken) { MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>(); map.add("access_token", accessToken); return weiboHttpClient.postForm(OAUTH2_REVOKE_OAUTH2, map, String.class); }
From source file:com.weibo.api.Statuses.java
/** * http://open.weibo.com/wiki/2/statuses/upload * @param status/* w w w . ja va2 s . c o m*/ * @param visible * @param listId * @param pic * @param accessToken * @return */ public Status upload(String status, Visible visible, String listId, String pic, String accessToken) { MultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>(); map.add("status", status); if (visible != null) { map.add("visible", visible.getCode()); if (visible == Visible.GROUP) { map.add("list_id", listId); } } map.add("pic", new ClassPathResource(pic)); map.add("access_token", accessToken); return weiboHttpClient.post(STATUSES_UPLOAD_URL, map, Status.class, MediaType.MULTIPART_FORM_DATA); }
From source file:ch.rasc.wampspring.config.WebMvcWampWebSocketEndpointRegistration.java
public final MultiValueMap<HttpRequestHandler, String> getMappings() { MultiValueMap<HttpRequestHandler, String> mappings = new LinkedMultiValueMap<>(); if (this.registration != null) { SockJsService sockJsService = this.registration.getSockJsService(); for (String path : this.paths) { String pattern = path.endsWith("/") ? path + "**" : path + "/**"; SockJsHttpRequestHandler handler = new SockJsHttpRequestHandler(sockJsService, this.webSocketHandler); mappings.add(handler, pattern); }//from w w w. java 2 s .c o m } else { for (String path : this.paths) { WebSocketHttpRequestHandler handler; if (this.handshakeHandler != null) { handler = new WebSocketHttpRequestHandler(this.webSocketHandler, this.handshakeHandler); } else { handler = new WebSocketHttpRequestHandler(this.webSocketHandler); } HandshakeInterceptor[] handshakeInterceptors = getInterceptors(); if (handshakeInterceptors.length > 0) { handler.setHandshakeInterceptors(Arrays.asList(handshakeInterceptors)); } mappings.add(handler, path); } } return mappings; }
From source file:com.work.petclinic.SampleWebUiApplicationTests.java
@Test public void testCreateUserAndLogin() throws Exception { ResponseEntity<String> page = getPage("http://localhost:" + this.port + "/users"); assertTrue("Client or server error.", !page.getStatusCode().is4xxClientError() && !page.getStatusCode().is5xxServerError()); if (page.getStatusCode() == HttpStatus.FOUND) { page = getPage(page.getHeaders().getLocation()); }//from ww w .jav a2 s . c o m String body = page.getBody(); assertNotNull("Body was null", body); String username = "newuser"; String password = "password"; String formAction = getFormAction(page); MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>(); form.set("username", username); form.set("email", "newuser@newuser.org"); form.set("name", "New User"); form.set("uiPassword", password); form.set("verifyPassword", password); form.set("_eventId_saveUser", "Create User"); form.set("_csrf", csrfValue); httpHeaders.set("X-CSRF-TOKEN", csrfValue); page = postPage(formAction, form); if (page.getStatusCode() == HttpStatus.FOUND) { page = getPage(page.getHeaders().getLocation()); } assertEquals(HttpStatus.OK, page.getStatusCode()); body = page.getBody(); assertNotNull("Body was null", body); assertTrue("User not created:\n" + body, body.contains("User " + username + " saved")); executeLogin(username, password); }
From source file:org.agorava.yammer.impl.MessageServiceImpl.java
public MessageInfo postUpdate(String message, YammerPostDetails details) { LinkedMultiValueMap<String, Object> params = new LinkedMultiValueMap<String, Object>(); params.set("body", message); params.putAll(details.toParameters()); return restTemplate.postForObject(buildUri("messages.json"), params, MessageInfo.class); }
From source file:com.fns.grivet.service.NamedQueryServiceSprocTest.java
@Test public void testNamedQueryNotExecutedBecauseParamSuppliedForExecutionNotCorrectlyNamed() throws IOException { Assertions.assertThrows(IllegalArgumentException.class, () -> { Resource r = resolver.getResource("classpath:TestSprocQuery.json"); String json = IOUtils.toString(r.getInputStream(), Charset.defaultCharset()); NamedQuery namedQuery = objectMapper.readValue(json, NamedQuery.class); namedQueryService.create(namedQuery); MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); Timestamp tomorrow = Timestamp.valueOf(LocalDateTime.now().plusDays(1)); params.add("timeCreated", tomorrow); namedQueryService.get("sproc.getAttributesCreatedBefore", params); });//from w w w. j a v a 2 s .c o m }
From source file:com.jiwhiz.domain.account.impl.ConnectionRepositoryImpl.java
public MultiValueMap<String, Connection<?>> findConnectionsToUsers( MultiValueMap<String, String> providerUsers) { if (providerUsers == null || providerUsers.isEmpty()) { throw new IllegalArgumentException("Unable to execute find: no providerUsers provided"); }/* ww w. j av a 2 s . c o m*/ MultiValueMap<String, Connection<?>> connectionsForUsers = new LinkedMultiValueMap<String, Connection<?>>(); for (Iterator<Entry<String, List<String>>> it = providerUsers.entrySet().iterator(); it.hasNext();) { Entry<String, List<String>> entry = it.next(); String providerId = entry.getKey(); List<String> providerUserIds = entry.getValue(); List<UserSocialConnection> userSocialConnections = userSocialConnectionRepository .findByProviderIdAndProviderUserIdIn(providerId, providerUserIds); List<Connection<?>> connections = new ArrayList<Connection<?>>(providerUserIds.size()); for (int i = 0; i < providerUserIds.size(); i++) { connections.add(null); } connectionsForUsers.put(providerId, connections); for (UserSocialConnection userSocialConnection : userSocialConnections) { String providerUserId = userSocialConnection.getProviderUserId(); int connectionIndex = providerUserIds.indexOf(providerUserId); connections.set(connectionIndex, buildConnection(userSocialConnection)); } } return connectionsForUsers; }
From source file:org.hdiv.web.multipart.HDIVMultipartResolver.java
/** * Return the multipart files as Map of field name to MultipartFile instance. */// w ww . j a v a 2s .c o m public MultiValueMap<String, MultipartFile> getMultipartFileElements(Hashtable fileElements) { MultiValueMap<String, MultipartFile> multipartFiles = new LinkedMultiValueMap<String, MultipartFile>(); for (Object key : fileElements.keySet()) { multipartFiles.add((String) key, (MultipartFile) fileElements.get(key)); } return multipartFiles; }
From source file:com.jiwhiz.domain.account.impl.MongoConnectionRepositoryImpl.java
public MultiValueMap<String, Connection<?>> findConnectionsToUsers( MultiValueMap<String, String> providerUsers) { if (providerUsers == null || providerUsers.isEmpty()) { throw new IllegalArgumentException("Unable to execute find: no providerUsers provided"); }//from ww w . j a v a2 s .c o m MultiValueMap<String, Connection<?>> connectionsForUsers = new LinkedMultiValueMap<String, Connection<?>>(); for (Iterator<Entry<String, List<String>>> it = providerUsers.entrySet().iterator(); it.hasNext();) { Entry<String, List<String>> entry = it.next(); String providerId = entry.getKey(); List<String> providerUserIds = entry.getValue(); List<UserSocialConnection> userSocialConnections = this.userSocialConnectionRepository .findByProviderIdAndProviderUserIdIn(providerId, providerUserIds); List<Connection<?>> connections = new ArrayList<Connection<?>>(providerUserIds.size()); for (int i = 0; i < providerUserIds.size(); i++) { connections.add(null); } connectionsForUsers.put(providerId, connections); for (UserSocialConnection userSocialConnection : userSocialConnections) { String providerUserId = userSocialConnection.getProviderUserId(); int connectionIndex = providerUserIds.indexOf(providerUserId); connections.set(connectionIndex, buildConnection(userSocialConnection)); } } return connectionsForUsers; }
From source file:org.pad.pgsql.loadmovies.LoadFiles.java
/** * Load ratings and enrich movies with tags informations before updating the related movie. * * @throws Exception/*from w ww . j a va2s .co m*/ */ private static void loadRatings() throws Exception { //MultivalueMap with key movieId and values all tags LinkedMultiValueMap<Integer, Tag> tags = readTags(); //MultivalueMap with key movieId and values all ratings LinkedMultiValueMap<Integer, Rating> ratings = new LinkedMultiValueMap(); //"userId,movieId,rating,timestamp final Reader reader = new FileReader("C:\\PRIVE\\SRC\\ml-20m\\ratings.csv"); CSVParser parser = new CSVParser(reader, CSVFormat.EXCEL.withHeader()); RatingDao ratingDao = new RatingDao(DS); for (CSVRecord record : parser) { Integer movieId = Integer.parseInt(record.get("movieId")); Integer userId = Integer.parseInt(record.get("userId")); if (keepId(movieId) && keepId(userId)) { //Building a rating object. Rating rating = new Rating(); rating.setUserId(userId); rating.setMovieId(movieId); rating.setRating(Float.parseFloat(record.get("rating"))); rating.setDate(new Date(Long.parseLong(record.get("timestamp")) * 1000)); //Add for json saving ratings.add(rating.getMovieId(), rating); //traditional saving //ratingDao.save(rating); } } MovieDaoJSON movieDaoJSON = new MovieDaoJSON(DS); ratings.entrySet().stream().forEach((integerListEntry -> { //Building other information objects OtherInformations otherInformations = new OtherInformations(); List ratingList = integerListEntry.getValue(); otherInformations.setRatings(ratingList.subList(0, Math.min(10, ratingList.size()))); otherInformations.computeMean(); //Retrieve tags from the movieId otherInformations.setTags(tags.get(integerListEntry.getKey())); try { movieDaoJSON.addOtherInformationsToMovie(integerListEntry.getKey(), otherInformations); } catch (JsonProcessingException e) { e.printStackTrace(); } })); }