本文整理汇总了Java中org.springframework.util.MultiValueMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java MultiValueMap.put方法的具体用法?Java MultiValueMap.put怎么用?Java MultiValueMap.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.util.MultiValueMap
的用法示例。
在下文中一共展示了MultiValueMap.put方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
private void send(String subject, String to, String toEmail, String body) {
final String url = "https://api.mailgun.net/v3/" +
env.getProperty("mailgun.domain") + "/messages";
final MultiValueMap<String, String> args = new LinkedMultiValueMap<>();
args.put("subject", singletonList(subject));
args.put("from", singletonList(env.getProperty("service.email.sitename") +
" <" + env.getProperty("service.email.sender") + ">"));
args.put("to", singletonList(to + " <" + toEmail + ">"));
args.put("html", singletonList(body));
final ResponseEntity<MailGunResponse> response =
mailgun.postForEntity(url, args, MailGunResponse.class);
if (!response.getStatusCode().is2xxSuccessful()) {
throw new RuntimeException(
"Error delivering mail. Message: " +
response.getBody().getMessage()
);
}
}
示例2: findAllConnections
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
@Override
public MultiValueMap<String, Connection<?>> findAllConnections() {
List<SocialUserConnection> socialUserConnections = socialUserConnectionRepository
.findAllByUserIdOrderByProviderIdAscRankAsc(userId);
List<Connection<?>> connections = socialUserConnectionsToConnections(socialUserConnections);
MultiValueMap<String, Connection<?>> connectionsByProviderId = new LinkedMultiValueMap<>();
Set<String> registeredProviderIds = connectionFactoryLocator.registeredProviderIds();
for (String registeredProviderId : registeredProviderIds) {
connectionsByProviderId.put(registeredProviderId, Collections.emptyList());
}
for (Connection<?> connection : connections) {
String providerId = connection.getKey().getProviderId();
if (connectionsByProviderId.get(providerId) == null || connectionsByProviderId.get(providerId).size() == 0) {
connectionsByProviderId.put(providerId, new LinkedList<>());
}
connectionsByProviderId.add(providerId, connection);
}
return connectionsByProviderId;
}
示例3: testDeleteUserSocialConnection
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
@Test
public void testDeleteUserSocialConnection() throws Exception {
// Setup
Connection<?> connection = createConnection("@LOGIN",
"[email protected]",
"FIRST_NAME",
"LAST_NAME",
"IMAGE_URL",
"PROVIDER");
socialService.createSocialUser(connection, "fr");
MultiValueMap<String, Connection<?>> connectionsByProviderId = new LinkedMultiValueMap<>();
connectionsByProviderId.put("PROVIDER", null);
when(mockConnectionRepository.findAllConnections()).thenReturn(connectionsByProviderId);
// Exercise
socialService.deleteUserSocialConnection("@LOGIN");
// Verify
verify(mockConnectionRepository, times(1)).removeConnections("PROVIDER");
}
示例4: findAllConnections
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
@Override
public MultiValueMap<String, Connection<?>> findAllConnections() {
List<SocialUserConnection> socialUserConnections = socialUserConnectionRepository.findAllByUserIdOrderByProviderIdAscRankAsc(userId);
List<Connection<?>> connections = socialUserConnectionsToConnections(socialUserConnections);
MultiValueMap<String, Connection<?>> connectionsByProviderId = new LinkedMultiValueMap<>();
Set<String> registeredProviderIds = connectionFactoryLocator.registeredProviderIds();
for (String registeredProviderId : registeredProviderIds) {
connectionsByProviderId.put(registeredProviderId, Collections.emptyList());
}
for (Connection<?> connection : connections) {
String providerId = connection.getKey().getProviderId();
if (connectionsByProviderId.get(providerId).size() == 0) {
connectionsByProviderId.put(providerId, new LinkedList<>());
}
connectionsByProviderId.add(providerId, connection);
}
return connectionsByProviderId;
}
示例5: testDeleteUserSocialConnection
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
@Test
public void testDeleteUserSocialConnection() throws Exception {
// Setup
Connection<?> connection = createConnection("@LOGIN",
"[email protected]",
"FIRST_NAME",
"LAST_NAME",
"PROVIDER");
socialService.createSocialUser(connection, "fr");
MultiValueMap<String, Connection<?>> connectionsByProviderId = new LinkedMultiValueMap<>();
connectionsByProviderId.put("PROVIDER", null);
when(mockConnectionRepository.findAllConnections()).thenReturn(connectionsByProviderId);
// Exercise
socialService.deleteUserSocialConnection("@LOGIN");
// Verify
verify(mockConnectionRepository, times(1)).removeConnections("PROVIDER");
}
示例6: encode
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
/**
* Encodes all URI components using their specific encoding rules, and returns the result as a new
* {@code UriComponents} instance.
* @param encoding the encoding of the values contained in this map
* @return the encoded uri components
* @throws UnsupportedEncodingException if the given encoding is not supported
*/
@Override
public HierarchicalUriComponents encode(String encoding) throws UnsupportedEncodingException {
Assert.hasLength(encoding, "Encoding must not be empty");
if (this.encoded) {
return this;
}
String encodedScheme = encodeUriComponent(getScheme(), encoding, Type.SCHEME);
String encodedUserInfo = encodeUriComponent(this.userInfo, encoding, Type.USER_INFO);
String encodedHost = encodeUriComponent(this.host, encoding, getHostType());
PathComponent encodedPath = this.path.encode(encoding);
MultiValueMap<String, String> encodedQueryParams =
new LinkedMultiValueMap<String, String>(this.queryParams.size());
for (Map.Entry<String, List<String>> entry : this.queryParams.entrySet()) {
String encodedName = encodeUriComponent(entry.getKey(), encoding, Type.QUERY_PARAM);
List<String> encodedValues = new ArrayList<String>(entry.getValue().size());
for (String value : entry.getValue()) {
String encodedValue = encodeUriComponent(value, encoding, Type.QUERY_PARAM);
encodedValues.add(encodedValue);
}
encodedQueryParams.put(encodedName, encodedValues);
}
String encodedFragment = encodeUriComponent(this.getFragment(), encoding, Type.FRAGMENT);
return new HierarchicalUriComponents(encodedScheme, encodedUserInfo, encodedHost, this.port, encodedPath,
encodedQueryParams, encodedFragment, true, false);
}
示例7: expandInternal
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
@Override
protected HierarchicalUriComponents expandInternal(UriTemplateVariables uriVariables) {
Assert.state(!this.encoded, "Cannot expand an already encoded UriComponents object");
String expandedScheme = expandUriComponent(getScheme(), uriVariables);
String expandedUserInfo = expandUriComponent(this.userInfo, uriVariables);
String expandedHost = expandUriComponent(this.host, uriVariables);
PathComponent expandedPath = this.path.expand(uriVariables);
MultiValueMap<String, String> expandedQueryParams =
new LinkedMultiValueMap<String, String>(this.queryParams.size());
for (Map.Entry<String, List<String>> entry : this.queryParams.entrySet()) {
String expandedName = expandUriComponent(entry.getKey(), uriVariables);
List<String> expandedValues = new ArrayList<String>(entry.getValue().size());
for (String value : entry.getValue()) {
String expandedValue = expandUriComponent(value, uriVariables);
expandedValues.add(expandedValue);
}
expandedQueryParams.put(expandedName, expandedValues);
}
String expandedFragment = expandUriComponent(this.getFragment(), uriVariables);
return new HierarchicalUriComponents(expandedScheme, expandedUserInfo, expandedHost, this.port, expandedPath,
expandedQueryParams, expandedFragment, false, false);
}
示例8: send
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
private void send(String subject, String to, String toEmail, String body) {
final String url = "https://api.mailgun.net/v3/" +
env.getProperty("mailgun.domain") + "/messages";
final MultiValueMap<String, String> args = new LinkedMultiValueMap<>();
args.put("subject", singletonList(subject));
args.put("from", singletonList(env.getProperty("service.email.sitename") +
" <" + env.getProperty("service.email.sender") + ">"));
args.put("to", singletonList(to + " <" + toEmail + ">"));
args.put("html", singletonList(body));
final ResponseEntity<MailGunResponse> response =
mailgun.postForEntity(url, args, MailGunResponse.class);
if (!response.getStatusCode().is2xxSuccessful()) {
throw new MailDeliveryException(
"Error delivering mail. Message: " +
response.getBody().getMessage()
);
}
}
示例9: getRequestParameters
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
private static MultiValueMap<String, String> getRequestParameters(NativeWebRequest request,
String... ignoredParameters) {
List<String> ignoredParameterList = asList(ignoredParameters);
MultiValueMap<String, String> convertedMap = new LinkedMultiValueMap<>();
for (Entry<String, String[]> entry : request.getParameterMap().entrySet()) {
if (!ignoredParameterList.contains(entry.getKey())) {
convertedMap.put(entry.getKey(), asList(entry.getValue()));
}
}
return convertedMap;
}
示例10: replaceRequestParamNames
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
/**
* 替换请求参数名
*
* @param webhook
* @param requestBody
* @return
*/
private Object replaceRequestParamNames(WebhookDetail webhook, Object requestBody) {
if (ContentType.FORM.equals(webhook.getContentType())) {
// 替换前的参数Map
MultiValueMap<String, Object> sourceParamMap = (MultiValueMap<String, Object>) requestBody;
// 替换后的参数Map
MultiValueMap<String, Object> targetParamMap = new LinkedMultiValueMap<>();
// 参数名映射
Map<String, String> paramMapping = webhook.getRequestParams();
String targetParamName = null;
List<Object> paramValue = null;
for (String sourceParamName : sourceParamMap.keySet()) {
targetParamName = paramMapping.get(sourceParamName);
if (StringUtils.isEmpty(targetParamName)) {
targetParamName = sourceParamName;
}
paramValue = sourceParamMap.get(sourceParamName);
targetParamMap.put(targetParamName, paramValue);
}
return targetParamMap;
} else {
return requestBody;
}
}
示例11: createResponse
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private <T> ResponseEntity<T> createResponse(Object instance, Response response) {
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
for (String key : response.headers().keySet()) {
headers.put(key, new LinkedList<>(response.headers().get(key)));
}
return new ResponseEntity<>((T) instance, headers, HttpStatus.valueOf(response.status()));
}
示例12: killRemoteRequests
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
public ObjectNode killRemoteRequests ( String auditUserid,
List<String> services, List<String> hosts,
String clean, String keepLogs,
String apiUserid,
String apiPass ) {
ObjectNode resultJson = jacksonMapper.createObjectNode();
ArrayNode servicesArray = resultJson.putArray( "services" );
services.forEach( servicesArray::add );
ArrayNode hostsArray = resultJson.putArray( "hosts" );
hosts.forEach( hostsArray::add );
if ( !Application.isJvmInManagerMode() ) {
resultJson
.put( "error",
"refer to /api/deploy/host/* to deploy on hosts" );
} else if ( hosts.size() == 0 || services.size() == 0 ) {
resultJson
.put( "error",
"missing cluster parameter" );
} else {
MultiValueMap<String, String> stopParameters = new LinkedMultiValueMap<String, String>();
stopParameters.set( "auditUserid", auditUserid );
stopParameters.put( "services", services );
stopParameters.put( "hosts", hosts );
;
if ( isPresent( clean ) ) {
stopParameters.set( "clean", clean );
}
if ( isPresent( keepLogs ) ) {
stopParameters.set( "keepLogs", keepLogs );
}
logger.debug( "* Stopping to: {}, params: {}", Arrays.asList( hosts ), stopParameters );
ObjectNode clusterResponse = serviceOsManager.remoteAgentsApi(
apiUserid,
apiPass,
hosts,
CsapCoreService.API_AGENT_URL + AgentApi.KILL_SERVICES_URL,
stopParameters );
logger.debug( "Results: {}", clusterResponse );
resultJson.set( "clusteredResults", clusterResponse );
csapApp.getHostStatusManager().refreshAndWaitForComplete( null);
}
return resultJson;
}
示例13: startRemoteRequests
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
public ObjectNode startRemoteRequests ( String auditUserid,
List<String> services, List<String> hosts,
String commandArguments,
String runtime, String hotDeploy,
String startClean, String noDeploy,
String apiUserid, String apiPass,
String deployId) {
ObjectNode resultJson = jacksonMapper.createObjectNode();
ArrayNode servicesArray = resultJson.putArray( "services" );
services.forEach( servicesArray::add );
ArrayNode hostsArray = resultJson.putArray( "hosts" );
hosts.forEach( hostsArray::add );
if ( !Application.isJvmInManagerMode() ) {
resultJson
.put( "error",
"refer to /api/deploy/host/* to deploy on hosts" );
} else if ( hosts.size() == 0 || services.size() == 0 ) {
resultJson
.put( "error",
"missing cluster parameter" );
} else {
MultiValueMap<String, String> startParameters = new LinkedMultiValueMap<String, String>();
startParameters.set( "auditUserid", auditUserid );
startParameters.put( "services", services );
startParameters.put( "hosts", hosts );
if ( isPresent( deployId ) ) {
startParameters.set( "deployId", deployId );
}
if ( isPresent( runtime ) ) {
startParameters.add( "runtime", runtime );
}
if ( isPresent( commandArguments ) ) {
startParameters.add( "commandArguments", commandArguments );
}
if ( isPresent( startClean ) ) {
startParameters.add( "startClean", startClean );
}
if ( isPresent( hotDeploy ) ) {
startParameters.add( "hotDeploy", hotDeploy );
}
if ( isPresent( noDeploy ) ) {
startParameters.add( "noDeploy", noDeploy );
}
logger.debug( "* Stopping to: {}, params: {}", Arrays.asList( hosts ), startParameters );
ObjectNode clusterResponse = serviceOsManager.remoteAgentsApi(
apiUserid,
apiPass,
hosts,
CsapCoreService.API_AGENT_URL + AgentApi.START_SERVICES_URL,
startParameters );
logger.debug( "Results: {}", clusterResponse );
resultJson.set( "clusteredResults", clusterResponse );
csapApp.getHostStatusManager().refreshAndWaitForComplete( null);
}
return resultJson;
}
示例14: purgeDeployCaches
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
@RequestMapping ( value = "/purgeDeployCache" , produces = MediaType.APPLICATION_JSON_VALUE )
public ObjectNode purgeDeployCaches (
@RequestParam ( CSAP.SERVICE_PORT_PARAM ) ArrayList<String> services,
@RequestParam ( CSAP.HOST_PARAM ) ArrayList<String> hosts,
@RequestParam ( value = "global" , required = false ) String global,
HttpServletRequest request ) {
String uiUser = securityConfig.getUserIdFromContext();
logger.info( "User: {}, services: {}, hosts:{}, global: {}",
uiUser, services, hosts, global );
ObjectNode resultsJson = jacksonMapper.createObjectNode();
if ( Application.isJvmInManagerMode() ) {
MultiValueMap<String, String> urlVariables = new LinkedMultiValueMap<String, String>();
urlVariables.put( CSAP.SERVICE_PORT_PARAM, services );
// }
urlVariables.add( "global", global );
String url = CsapCoreService.SERVICE_URL + "/purgeDeployCache";
resultsJson = serviceOsManager.remoteAgentsUsingUserCredentials(
hosts, url, urlVariables,
request );
return resultsJson;
}
for ( String service : services ) {
ArrayList<String> params = new ArrayList<String>();
if ( global != null ) {
// triggers complete empty of the maven and build
// folders
params.add( "-serviceName" );
params.add( "GLOBAL" ); // hardcoded in purge script
}
resultsJson.put( service,
serviceOsManager.runScript(
uiUser,
PURGE_FILE, service,
params, null, null ) );
}
return resultsJson;
}