List of usage examples for org.springframework.util LinkedMultiValueMap get
@Override
@Nullable
public List<V> get(Object key)
From source file:com.apress.prospringintegration.web.MultipartReceiver.java
@ServiceActivator public void handleMultipartRequest(LinkedMultiValueMap<String, Object> multipartRequest) { System.out.println("Received multipart request: " + multipartRequest); for (String elementName : multipartRequest.keySet()) { if (elementName.equals("name")) { LinkedList value = (LinkedList) multipartRequest.get("name"); String[] multiValues = (String[]) value.get(0); for (String name : multiValues) { System.out.println("Name: " + name); }/* ww w.j a va 2 s. c o m*/ } else if (elementName.equals("picture")) { System.out.println("Picture as UploadedMultipartFile: " + ((UploadedMultipartFile) multipartRequest.getFirst("picture")).getOriginalFilename()); } } }
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 w w . ja va 2 s. c om*/ */ 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(); } })); }
From source file:com.thoughtworks.go.server.service.ElasticAgentPluginService.java
public void heartbeat() { LinkedMultiValueMap<String, ElasticAgentMetadata> elasticAgentsOfMissingPlugins = agentService .allElasticAgents();/*ww w. jav a 2 s. c om*/ // pingMessage TTL is set lesser than elasticPluginHeartBeatInterval to ensure there aren't multiple ping request for the same plugin long pingMessageTimeToLive = elasticPluginHeartBeatInterval - 10000L; for (PluginDescriptor descriptor : elasticAgentPluginRegistry.getPlugins()) { List<ClusterProfile> clusterProfiles = clusterProfilesService.getPluginProfiles() .findByPluginId(descriptor.id()); serverPingQueue.post(new ServerPingMessage(descriptor.id(), clusterProfiles), pingMessageTimeToLive); elasticAgentsOfMissingPlugins.remove(descriptor.id()); serverHealthService.removeByScope(scope(descriptor.id())); } if (!elasticAgentsOfMissingPlugins.isEmpty()) { for (String pluginId : elasticAgentsOfMissingPlugins.keySet()) { Collection<String> uuids = elasticAgentsOfMissingPlugins.get(pluginId).stream() .map(ElasticAgentMetadata::uuid).collect(Collectors.toList()); String description = format( "Elastic agent plugin with identifier %s has gone missing, but left behind %s agent(s) with UUIDs %s.", pluginId, elasticAgentsOfMissingPlugins.get(pluginId).size(), uuids); serverHealthService.update(ServerHealthState.warning("Elastic agents with no matching plugins", description, HealthStateType.general(scope(pluginId)))); LOGGER.warn(description); } } }
From source file:org.slc.sli.api.resources.security.SamlFederationResource.java
private void setPrincipalRoles(SLIPrincipal principal, LinkedMultiValueMap<String, String> attributes, Entity realm, String tenant, boolean isAdminRealm, boolean isDevRealm) { List<String> roles = attributes.get("roles"); if (roles == null || roles.isEmpty()) { LOG.error("Attempted login by a user that did not include any roles in the SAML Assertion."); throw new APIAccessDeniedException("Invalid user. No roles specified for user.", realm); }/* ww w. j a va 2 s . c om*/ Set<Role> sliRoleSet = resolver.mapRoles(tenant, realm.getEntityId(), roles, isAdminRealm); List<String> sliRoleList = new ArrayList<String>(); boolean isAdminUser = true; for (Role role : sliRoleSet) { sliRoleList.addAll(role.getName()); if (!role.isAdmin()) { isAdminUser = false; break; } } if (!(isAdminRealm || isDevRealm) && (principal.getUserType() == null || principal.getUserType().equals("") || principal.getUserType().equals(EntityNames.STAFF))) { Map<String, List<String>> sliEdOrgRoleMap = edOrgRoleBuilder.buildValidStaffRoles(realm.getEntityId(), principal.getEntity().getEntityId(), tenant, roles); principal.setEdOrgRoles(sliEdOrgRoleMap); Set<String> allRoles = new HashSet<String>(); for (List<String> roleList : sliEdOrgRoleMap.values()) { allRoles.addAll(roleList); } principal.setRoles(new ArrayList<String>(allRoles)); } else { principal.setRoles(sliRoleList); if (principal.getRoles().isEmpty()) { LOG.debug( "Attempted login by a user that included no roles in the SAML Assertion that mapped to any of the SLI roles."); throw new APIAccessDeniedException( "Invalid user. No valid role mappings exist for the roles specified in the SAML Assertion.", realm); } } principal.setAdminUser(isAdminUser); principal.setAdminRealmAuthenticated(isAdminRealm || isDevRealm); }
From source file:org.springframework.integration.samples.multipart.MultipartReceiver.java
@SuppressWarnings("rawtypes") public void receive(LinkedMultiValueMap<String, Object> multipartRequest) { logger.info("Successfully received multipart request: " + multipartRequest); for (String elementName : multipartRequest.keySet()) { if (elementName.equals("company")) { LinkedList value = (LinkedList) multipartRequest.get("company"); String[] multiValues = (String[]) value.get(0); for (String companyName : multiValues) { logger.info(elementName + " - " + companyName); }/*from w w w . jav a 2 s.c o m*/ } else if (elementName.equals("company-logo")) { logger.info(elementName + " - as UploadedMultipartFile: " + ((UploadedMultipartFile) multipartRequest.getFirst("company-logo")) .getOriginalFilename()); } } }