本文整理匯總了Java中org.springframework.util.MultiValueMap.add方法的典型用法代碼示例。如果您正苦於以下問題:Java MultiValueMap.add方法的具體用法?Java MultiValueMap.add怎麽用?Java MultiValueMap.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.util.MultiValueMap
的用法示例。
在下文中一共展示了MultiValueMap.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createRelease
import org.springframework.util.MultiValueMap; //導入方法依賴的package包/類
public ReleaseDTO createRelease(String appId, Env env, String clusterName, String namespace,
String releaseName, String releaseComment, String operator,
boolean isEmergencyPublish) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.parseMediaType(MediaType.APPLICATION_FORM_URLENCODED_VALUE + ";charset=UTF-8"));
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
parameters.add("name", releaseName);
parameters.add("comment", releaseComment);
parameters.add("operator", operator);
parameters.add("isEmergencyPublish", String.valueOf(isEmergencyPublish));
HttpEntity<MultiValueMap<String, String>> entity =
new HttpEntity<>(parameters, headers);
ReleaseDTO response = restTemplate.post(
env, "apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases", entity,
ReleaseDTO.class, appId, clusterName, namespace);
return response;
}
示例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).size() == 0) {
connectionsByProviderId.put(providerId, new LinkedList<>());
}
connectionsByProviderId.add(providerId, connection);
}
return connectionsByProviderId;
}
示例3: ableToUploadFile
import org.springframework.util.MultiValueMap; //導入方法依賴的package包/類
@Test
public void ableToUploadFile() throws IOException {
String file1Content = "hello world";
String file2Content = "bonjour";
String username = "mike";
MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
map.add("file1", new FileSystemResource(newFile(file1Content).getAbsolutePath()));
map.add("someFile", new FileSystemResource(newFile(file2Content).getAbsolutePath()));
map.add("name", username);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
String result = restTemplate.postForObject(
codeFirstUrl + "upload",
new HttpEntity<>(map, headers),
String.class);
assertThat(result, is(file1Content + file2Content + username));
}
示例4: updateCommunity
import org.springframework.util.MultiValueMap; //導入方法依賴的package包/類
/**
* Endpoint: Update Community
* Creates a community.
* Requires Scope: none
*
* @param credential OAuth token for a Twitch user (that as 2fa enabled)
* @param id Id of the community, which will be updated.
* @param name Community name. 3-25 characters, which can be alphanumerics, dashes (-), periods (.), underscores (_), and tildes (~). Cannot contain spaces.
* @param summary Short description of the community, shown in search results. Maximum: 160 characters.
* @param description Long description of the community, shown in the *about this community* box. Markdown syntax allowed. Maximum 1,572,864 characters (1.5 MB).
* @param rules Rules displayed when viewing a community page or searching for a community from the broadcaster dashboard. Markdown syntax allowed. Maximum 1,572,864 characters (1.5 MB)
* @param email Email address of the community owner.
*/
public void updateCommunity(OAuthCredential credential, String id, Optional<String> name, Optional<String> summary, Optional<String> description, Optional<String> rules, Optional<String> email) {
// Endpoint
String requestUrl = String.format("%s/communities/%s", Endpoints.API.getURL());
RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();
// Post Data
MultiValueMap<String, Object> postBody = new LinkedMultiValueMap<String, Object>();
postBody.add("summary", summary.orElse(""));
postBody.add("description", description.orElse(""));
postBody.add("rules", rules.orElse(""));
postBody.add("email", email.orElse(""));
// REST Request
try {
restTemplate.postForObject(requestUrl, postBody, CommunityCreate.class);
} catch (RestException restException) {
Logger.error(this, "RestException: " + restException.getRestError().toString());
} catch (Exception ex) {
Logger.error(this, "Request failed: " + ex.getMessage());
Logger.trace(this, ExceptionUtils.getStackTrace(ex));
}
return;
}
示例5: main
import org.springframework.util.MultiValueMap; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
RestTemplate template = new RestTemplate();
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
headers.add("X-Tenant-Name", "default");
RequestEntity<String> requestEntity = new RequestEntity<String>(headers, HttpMethod.GET,
new URI("http://127.0.0.1:9980/registry/v3/microservices"));
ResponseEntity<String> stringResponseEntity = template.exchange(requestEntity, String.class);
System.out.println(stringResponseEntity.getBody());
ResponseEntity<MicroserviceArray> microseriveResponseEntity = template
.exchange(requestEntity, MicroserviceArray.class);
MicroserviceArray microserives = microseriveResponseEntity.getBody();
System.out.println(microserives.getServices().get(1).getServiceId());
// instance
headers.add("X-ConsumerId", microserives.getServices().get(1).getServiceId());
requestEntity = new RequestEntity<String>(headers, HttpMethod.GET,
new URI("http://127.0.0.1:9980/registry/v3/microservices/" + microserives.getServices().get(1).getServiceId()
+ "/instances"));
ResponseEntity<String> microserviceInstanceResponseEntity = template.exchange(requestEntity, String.class);
System.out.println(microserviceInstanceResponseEntity.getBody());
}
示例6: getLocationIds
import org.springframework.util.MultiValueMap; //導入方法依賴的package包/類
@Override
public LocationResponseModel getLocationIds(ILocation location) {
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
headers.add("x-app-name", "logistimo");
LocationRequestModel model = convert(location);
GetLocationCommand locationCommand = new GetLocationCommand(restTemplate, model, headers);
return locationCommand.execute();
}
示例7: generate
import org.springframework.util.MultiValueMap; //導入方法依賴的package包/類
private void generate(Directory root, File pomFile) {
String name = StringUtils.getFilename(pomFile.getName());
String extension = StringUtils.getFilenameExtension(pomFile.getName());
String prefix = name.substring(0, name.length() - extension.length() - 1);
File[] files = pomFile.getParentFile().listFiles((f) -> include(f, prefix));
MultiValueMap<File, MavenCoordinates> coordinates = new LinkedMultiValueMap<>();
for (File file : files) {
String rootPath = StringUtils.cleanPath(root.getFile().getPath());
String relativePath = StringUtils.cleanPath(file.getPath())
.substring(rootPath.length() + 1);
coordinates.add(file.getParentFile(),
MavenCoordinates.fromPath(relativePath));
}
coordinates.forEach(this::writeMetadata);
}
示例8: buildRequestBody
import org.springframework.util.MultiValueMap; //導入方法依賴的package包/類
@Override
protected Object buildRequestBody(WebhookDetail webhook, HookConfigChangeEvent event) {
MultiValueMap<String, String> paramMap = new LinkedMultiValueMap<>();
paramMap.add("name", event.getConfigItem().getName());
paramMap.add("value", event.getConfigItem().getValue());
paramMap.add("description", event.getConfigItem().getDescription());
return paramMap;
}
示例9: enhance
import org.springframework.util.MultiValueMap; //導入方法依賴的package包/類
@Override
public void enhance(AccessTokenRequest request,
OAuth2ProtectedResourceDetails resource,
MultiValueMap<String, String> form,
HttpHeaders headers) {
form.add("public_key", keyPairManager.createJWK().toJSONString());
}
示例10: build
import org.springframework.util.MultiValueMap; //導入方法依賴的package包/類
public Client build() {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
//prepare ROPC request
MultiValueMap<String, String> params = new LinkedMultiValueMap();
params.add(CLIENT_ID_PARAM, clientId);
params.add(CLIENT_SECRET_PARAM, clientSecret);
params.add(GRANT_TYPE_PARAM, "password");
params.add(USERNAME_PARAM, username);
params.add(PASSWORD_PARAM, password);
System.out.println("PARAMS: " + params.toString());
RestTemplate restTemplate = new RestTemplate();
HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity(params, headers);
String tokenUrl = String.format("%s/oauth2/v1/token", baseUrl);
System.out.println("tokenURL: " + tokenUrl);
try {
//obtain access token and return client instance
Client client = restTemplate
.exchange(tokenUrl, HttpMethod.POST, entity, Client.class)
.getBody();
client.init(baseUrl);
return client;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
示例11: canBookFlightsWhenLoggedIn
import org.springframework.util.MultiValueMap; //導入方法依賴的package包/類
@Test
public void canBookFlightsWhenLoggedIn() {
HttpHeaders headers = headerWithCookieOfLoginSession();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
map.add("userid", customerId);
map.add("toFlightId", toFlight.getFlightId());
map.add("toFlightSegId", toFlight.getFlightSegmentId());
map.add("retFlightId", retFlight.getFlightId());
map.add("retFlightSegId", retFlight.getFlightSegmentId());
map.add("oneWayFlight", String.valueOf(oneWay));
ResponseEntity<BookingReceiptInfo> bookingInfoResponseEntity = restTemplate.exchange(
gatewayUrl + "/bookings/rest/api/bookings/bookflights",
POST,
new HttpEntity<>(map, headers),
BookingReceiptInfo.class
);
assertThat(bookingInfoResponseEntity.getStatusCode(), is(OK));
BookingReceiptInfo bookingInfo = bookingInfoResponseEntity.getBody();
assertThat(bookingInfo.isOneWay(), is(oneWay));
assertThat(bookingInfo.getDepartBookingId(), is(notNullValue()));
assertThat(bookingInfo.getReturnBookingId(), is(notNullValue()));
}
示例12: booksFlightWithUnderlyingService
import org.springframework.util.MultiValueMap; //導入方法依賴的package包/類
@Test
public void booksFlightWithUnderlyingService() {
when(bookingService.bookFlight(userId, toFlightSegId, toFlightId)).thenReturn(toBookingId);
when(bookingService.bookFlight(userId, retFlightSegId, retFlightId)).thenReturn(retBookingId);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
form.add("userid", userId);
form.add("toFlightId", toFlightId);
form.add("toFlightSegId", toFlightSegId);
form.add("retFlightId", retFlightId);
form.add("retFlightSegId", retFlightSegId);
form.add("oneWayFlight", String.valueOf(false));
ResponseEntity<BookingReceiptInfo> responseEntity = restTemplate.exchange(
"/rest/api/bookings/bookflights",
HttpMethod.POST,
new HttpEntity<>(form, headers),
BookingReceiptInfo.class
);
assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK));
BookingReceiptInfo receiptInfo = responseEntity.getBody();
assertThat(receiptInfo.getDepartBookingId(), is(toBookingId));
assertThat(receiptInfo.getReturnBookingId(), is(retBookingId));
assertThat(receiptInfo.isOneWay(), is(false));
}
示例13: ableToPostForm
import org.springframework.util.MultiValueMap; //導入方法依賴的package包/類
@Test
public void ableToPostForm() {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("a", "5");
params.add("b", "3");
HttpHeaders headers = new HttpHeaders();
headers.add(CONTENT_TYPE, APPLICATION_FORM_URLENCODED_VALUE);
int result = restTemplate
.postForObject(codeFirstUrl + "add", new HttpEntity<>(params, headers), Integer.class);
assertThat(result, is(8));
}
示例14: createBody
import org.springframework.util.MultiValueMap; //導入方法依賴的package包/類
/**
* Takes a secret and a response and creates a map pair
* @param secret A String containing a secret
* @param response A String with the response from client
* @return
*/
private MultiValueMap<String, String> createBody(String secret, String response) {
MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
form.add("secret", secret);
form.add("response", response);
return form;
}
示例15: createCommunity
import org.springframework.util.MultiValueMap; //導入方法依賴的package包/類
/**
* Endpoint: Create Community
* Creates a community.
* Requires Scope: none
*
* @param credential OAuth token for a Twitch user (that as 2fa enabled)
* @param name Community name. 3-25 characters, which can be alphanumerics, dashes (-), periods (.), underscores (_), and tildes (~). Cannot contain spaces.
* @param summary Short description of the community, shown in search results. Maximum: 160 characters.
* @param description Long description of the community, shown in the *about this community* box. Markdown syntax allowed. Maximum 1,572,864 characters (1.5 MB).
* @param rules Rules displayed when viewing a community page or searching for a community from the broadcaster dashboard. Markdown syntax allowed. Maximum 1,572,864 characters (1.5 MB)
* @return ID (String) of the created community
*/
public String createCommunity(OAuthCredential credential, String name, String summary, String description, String rules) {
// Endpoint
String requestUrl = String.format("%s/communities", Endpoints.API.getURL());
RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();
// Post Data
MultiValueMap<String, Object> postBody = new LinkedMultiValueMap<String, Object>();
postBody.add("name", name);
postBody.add("summary", summary);
postBody.add("description", description);
postBody.add("rules", rules);
// REST Request
try {
CommunityCreate responseObject = restTemplate.postForObject(requestUrl, postBody, CommunityCreate.class);
return responseObject.getId();
} catch (RestException restException) {
Logger.error(this, "RestException: " + restException.getRestError().toString());
} catch (Exception ex) {
Logger.error(this, "Request failed: " + ex.getMessage());
Logger.trace(this, ExceptionUtils.getStackTrace(ex));
}
return null;
}