List of usage examples for org.springframework.util MultiValueMap put
V put(K key, V value);
From source file:com.lixiaocong.social.MyJdbcConnection.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 w w w . j av a 2 s . co m StringBuilder providerUsersCriteriaSql = new StringBuilder(); MapSqlParameterSource parameters = new MapSqlParameterSource(); parameters.addValue("userId", userId); for (Iterator<Entry<String, List<String>>> it = providerUsers.entrySet().iterator(); it.hasNext();) { Entry<String, List<String>> entry = it.next(); String providerId = entry.getKey(); providerUsersCriteriaSql.append("providerId = :providerId_").append(providerId) .append(" and providerUserId in (:providerUserIds_").append(providerId).append(")"); parameters.addValue("providerId_" + providerId, providerId); parameters.addValue("providerUserIds_" + providerId, entry.getValue()); if (it.hasNext()) { providerUsersCriteriaSql.append(" or "); } } List<Connection<?>> resultList = new NamedParameterJdbcTemplate(jdbcTemplate) .query(selectFromUserConnection() + " where userId = :userId and " + providerUsersCriteriaSql + " order by providerId, rank", parameters, connectionMapper); MultiValueMap<String, Connection<?>> connectionsForUsers = new LinkedMultiValueMap<String, Connection<?>>(); for (Connection<?> connection : resultList) { String providerId = connection.getKey().getProviderId(); List<String> userIds = providerUsers.get(providerId); List<Connection<?>> connections = connectionsForUsers.get(providerId); if (connections == null) { connections = new ArrayList<Connection<?>>(userIds.size()); for (int i = 0; i < userIds.size(); i++) { connections.add(null); } connectionsForUsers.put(providerId, connections); } String providerUserId = connection.getKey().getProviderUserId(); int connectionIndex = userIds.indexOf(providerUserId); connections.set(connectionIndex, connection); } return connectionsForUsers; }
From source file:org.n52.io.request.IoParameters.java
public IoParameters extendWith(String key, String... values) { MultiValueMap<String, String> newValues = new LinkedMultiValueMap<>(); newValues.put(key.toLowerCase(), Arrays.asList(values)); MultiValueMap<String, JsonNode> mergedValues = new LinkedMultiValueMap<>(query); mergedValues.putAll(convertValuesToJsonNodes(newValues)); return new IoParameters(mergedValues); }
From source file:io.github.davejoyce.dao.composite.social.connect.jpa.JpaConnectionRepository.java
/** * {@inheritDoc}//from w ww .j a va2s . co m */ public MultiValueMap<String, Connection<?>> findConnectionsToUsers( MultiValueMap<String, String> providerUsers) { if (providerUsers == null || providerUsers.isEmpty()) { throw new IllegalArgumentException("Unable to execute find: no providerUsers provided"); } StringBuilder providerUsersCriteriaJpaQl = new StringBuilder(QUERY_SELECT_FROM) .append("WHERE ausc.key.appUser.userId = :userId").append(" AND "); for (Iterator<Entry<String, List<String>>> it = providerUsers.entrySet().iterator(); it.hasNext();) { Entry<String, List<String>> entry = it.next(); String providerId = entry.getKey(); providerUsersCriteriaJpaQl.append("ausc.key.providerId = :providerId_").append(providerId) .append("AND ausc.key.providerUserId IN (:providerUserIds_").append(providerId).append(")"); if (it.hasNext()) { providerUsersCriteriaJpaQl.append(" OR "); } } providerUsersCriteriaJpaQl.append(" ORDER BY ausc.key.providerId, ausc.rank"); TypedQuery<AppUserSocialConnection> query = entityManager .createQuery(providerUsersCriteriaJpaQl.toString(), AppUserSocialConnection.class) .setParameter("userId", userId); for (Iterator<Entry<String, List<String>>> it = providerUsers.entrySet().iterator(); it.hasNext();) { Entry<String, List<String>> entry = it.next(); String providerId = entry.getKey(); query.setParameter(("providerId_" + providerId), providerId) .setParameter(("providerUserIds_" + providerId), entry.getValue()); } List<Connection<?>> resultList = appUserSocialConnectionsToConnections(query.getResultList()); MultiValueMap<String, Connection<?>> connectionsForUsers = new LinkedMultiValueMap<String, Connection<?>>(); for (Connection<?> connection : resultList) { String providerId = connection.getKey().getProviderId(); List<String> userIds = providerUsers.get(providerId); List<Connection<?>> connections = connectionsForUsers.get(providerId); if (connections == null) { connections = new ArrayList<Connection<?>>(userIds.size()); for (int i = 0; i < userIds.size(); i++) { connections.add(null); } connectionsForUsers.put(providerId, connections); } String providerUserId = connection.getKey().getProviderUserId(); int connectionIndex = userIds.indexOf(providerUserId); connections.set(connectionIndex, connection); } return connectionsForUsers; }
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 . ja v a2s.co 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: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"); }/* ww w .j ava 2 s .co 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:com.jkthome.cmm.web.JkthomeMultipartResolver.java
/** * multipart? parsing? .//from w w w .ja va2 s. c o m */ @SuppressWarnings("rawtypes") @Override protected MultipartParsingResult parseFileItems(List fileItems, String encoding) { //? 3.0 MultiValueMap<String, MultipartFile> multipartFiles = new LinkedMultiValueMap<String, MultipartFile>(); Map<String, String[]> multipartParameters = new HashMap<String, String[]>(); // Extract multipart files and multipart parameters. for (Iterator<?> it = fileItems.iterator(); it.hasNext();) { FileItem fileItem = (FileItem) it.next(); if (fileItem.isFormField()) { String value = null; if (encoding != null) { try { value = fileItem.getString(encoding); } catch (UnsupportedEncodingException ex) { LOGGER.warn( "Could not decode multipart item '{}' with encoding '{}': using platform default", fileItem.getFieldName(), encoding); value = fileItem.getString(); } } else { value = fileItem.getString(); } String[] curParam = (String[]) multipartParameters.get(fileItem.getFieldName()); if (curParam == null) { // simple form field multipartParameters.put(fileItem.getFieldName(), new String[] { value }); } else { // array of simple form fields String[] newParam = StringUtils.addStringToArray(curParam, value); multipartParameters.put(fileItem.getFieldName(), newParam); } } else { if (fileItem.getSize() > 0) { // multipart file field CommonsMultipartFile file = new CommonsMultipartFile(fileItem); //? 3.0 ? API? List<MultipartFile> fileList = new ArrayList<MultipartFile>(); fileList.add(file); if (multipartFiles.put(fileItem.getName(), fileList) != null) { // CHANGED!! throw new MultipartException("Multiple files for field name [" + file.getName() + "] found - not supported by MultipartResolver"); } LOGGER.debug( "Found multipart file [{}] of size {} bytes with original filename [{}], stored {}", file.getName(), file.getSize(), file.getOriginalFilename(), file.getStorageDescription()); } } } return new MultipartParsingResult(multipartFiles, multipartParameters, null); }
From source file:lcn.module.oltp.web.common.base.MultipartResolver.java
/** * multipart? parsing? ./*from ww w .j a v a 2 s .co m*/ */ @SuppressWarnings("unchecked") @Override protected MultipartParsingResult parseFileItems(List fileItems, String encoding) { //? 3.0 MultiValueMap<String, MultipartFile> multipartFiles = new LinkedMultiValueMap<String, MultipartFile>(); // Map<String, String[]> multipartParameters = new HashMap<String, String[]>(); // Map multipartFiles = new HashMap(); Map multipartParameters = new HashMap(); // Extract multipart files and multipart parameters. for (Iterator it = fileItems.iterator(); it.hasNext();) { FileItem fileItem = (FileItem) it.next(); if (fileItem.isFormField()) { String value = null; if (encoding != null) { try { value = fileItem.getString(encoding); } catch (UnsupportedEncodingException ex) { if (logger.isWarnEnabled()) { logger.warn("Could not decode multipart item '" + fileItem.getFieldName() + "' with encoding '" + encoding + "': using platform default"); } value = fileItem.getString(); } } else { value = fileItem.getString(); } String[] curParam = (String[]) multipartParameters.get(fileItem.getFieldName()); if (curParam == null) { // simple form field multipartParameters.put(fileItem.getFieldName(), new String[] { value }); } else { // array of simple form fields String[] newParam = StringUtils.addStringToArray(curParam, value); multipartParameters.put(fileItem.getFieldName(), newParam); } } else { if (fileItem.getSize() > 0) { // multipart file field CommonsMultipartFile file = new CommonsMultipartFile(fileItem); //? 3.0 ? API? List<MultipartFile> fileList = new ArrayList<MultipartFile>(); fileList.add(file); if (multipartFiles.put(fileItem.getName(), fileList) != null) { // CHANGED!! throw new MultipartException("Multiple files for field name [" + file.getName() + "] found - not supported by MultipartResolver"); } if (logger.isDebugEnabled()) { logger.debug("Found multipart file [" + file.getName() + "] of size " + file.getSize() + " bytes with original filename [" + file.getOriginalFilename() + "], stored " + file.getStorageDescription()); } } } } return new MultipartParsingResult((MultiValueMap<String, MultipartFile>) multipartFiles, (Map<String, String[]>) multipartParameters, multipartParameters); // return new MultipartParsingResult(multipartFiles, multipartParameters); }
From source file:egovframework.asadal.asapro.com.cmm.web.AsaproEgovMultipartResolver.java
/** * multipart? parsing? ./*w w w. java2 s . co m*/ */ @SuppressWarnings("unchecked") @Override protected MultipartParsingResult parseFileItems(List fileItems, String encoding) { //? 3.0 MultiValueMap<String, MultipartFile> multipartFiles = new LinkedMultiValueMap<String, MultipartFile>(); Map<String, String[]> multipartParameters = new HashMap<String, String[]>(); // Extract multipart files and multipart parameters. for (Iterator it = fileItems.iterator(); it.hasNext();) { FileItem fileItem = (FileItem) it.next(); if (fileItem.isFormField()) { String value = null; if (encoding != null) { try { value = fileItem.getString(encoding); } catch (UnsupportedEncodingException ex) { if (logger.isWarnEnabled()) { logger.warn("Could not decode multipart item '" + fileItem.getFieldName() + "' with encoding '" + encoding + "': using platform default"); } value = fileItem.getString(); } } else { value = fileItem.getString(); } String[] curParam = (String[]) multipartParameters.get(fileItem.getFieldName()); if (curParam == null) { // simple form field multipartParameters.put(fileItem.getFieldName(), new String[] { value }); } else { // array of simple form fields String[] newParam = StringUtils.addStringToArray(curParam, value); multipartParameters.put(fileItem.getFieldName(), newParam); } } else { if (fileItem.getSize() > 0) { // multipart file field CommonsMultipartFile file = new CommonsMultipartFile(fileItem); //? 3.0 ? API? List<MultipartFile> fileList = new ArrayList<MultipartFile>(); fileList.add(file); if (!AsaproEgovWebUtil.checkAllowUploadFileExt(file.getOriginalFilename())) throw new MultipartException(" ? ? ."); if (multipartFiles.put(fileItem.getName(), fileList) != null) { // CHANGED!! throw new MultipartException("Multiple files for field name [" + file.getName() + "] found - not supported by MultipartResolver"); } if (logger.isDebugEnabled()) { logger.debug("Found multipart file [" + file.getName() + "] of size " + file.getSize() + " bytes with original filename [" + file.getOriginalFilename() + "], stored " + file.getStorageDescription()); } } } } return new MultipartParsingResult(multipartFiles, multipartParameters, null); }
From source file:egovframework.com.cmm.web.EgovMultipartResolver.java
/** * multipart? parsing? ./* w ww .jav a2 s.com*/ */ @SuppressWarnings("unchecked") @Override protected MultipartParsingResult parseFileItems(List fileItems, String encoding) { //? 3.0 MultiValueMap<String, MultipartFile> multipartFiles = new LinkedMultiValueMap<String, MultipartFile>(); Map<String, String[]> multipartParameters = new HashMap<String, String[]>(); // Extract multipart files and multipart parameters. for (Iterator it = fileItems.iterator(); it.hasNext();) { FileItem fileItem = (FileItem) it.next(); if (fileItem.isFormField()) { String value = null; if (encoding != null) { try { value = fileItem.getString(encoding); } catch (UnsupportedEncodingException ex) { if (logger.isWarnEnabled()) { logger.warn("Could not decode multipart item '" + fileItem.getFieldName() + "' with encoding '" + encoding + "': using platform default"); } value = fileItem.getString(); } } else { value = fileItem.getString(); } String[] curParam = (String[]) multipartParameters.get(fileItem.getFieldName()); if (curParam == null) { // simple form field multipartParameters.put(fileItem.getFieldName(), new String[] { value }); } else { // array of simple form fields String[] newParam = StringUtils.addStringToArray(curParam, value); multipartParameters.put(fileItem.getFieldName(), newParam); } } else { if (fileItem.getSize() > 0) { // multipart file field CommonsMultipartFile file = new CommonsMultipartFile(fileItem); //? 3.0 ? API? List<MultipartFile> fileList = new ArrayList<MultipartFile>(); fileList.add(file); if (multipartFiles.put(fileItem.getName(), fileList) != null) { // CHANGED!! throw new MultipartException("Multiple files for field name [" + file.getName() + "] found - not supported by MultipartResolver"); } if (logger.isDebugEnabled()) { logger.debug("Found multipart file [" + file.getName() + "] of size " + file.getSize() + " bytes with original filename [" + file.getOriginalFilename() + "], stored " + file.getStorageDescription()); } } } } return new MultipartParsingResult(multipartFiles, multipartParameters, null); }
From source file:org.cloudfoundry.identity.client.UaaContextFactory.java
/** * Adds a request enhancer to the provider. * Currently only two request parameters are being enhanced * 1. If the {@link TokenRequest} wants an id_token the <code>id_token token</code> values are added as a response_type parameter * 2. If the {@link TokenRequest} is a {@link org.cloudfoundry.identity.client.token.GrantType#PASSWORD_WITH_PASSCODE} * the <code>passcode</code> parameter will be added to the request * @param tokenRequest the token request, expected to be a password grant * @param provider the provider to enhance *///from w w w .ja v a 2s .com protected void enhanceRequestParameters(TokenRequest tokenRequest, OAuth2AccessTokenSupport provider) { provider.setTokenRequestEnhancer( //add id_token to the response type if requested. (AccessTokenRequest request, OAuth2ProtectedResourceDetails resource, MultiValueMap<String, String> form, HttpHeaders headers) -> { if (tokenRequest.wantsIdToken()) { form.put(OAuth2Utils.RESPONSE_TYPE, Arrays.asList("id_token token")); } if (tokenRequest.getGrantType() == PASSWORD_WITH_PASSCODE) { form.put("passcode", Arrays.asList(tokenRequest.getPasscode())); } }); }