本文整理汇总了Java中org.springframework.util.MultiValueMap.getFirst方法的典型用法代码示例。如果您正苦于以下问题:Java MultiValueMap.getFirst方法的具体用法?Java MultiValueMap.getFirst怎么用?Java MultiValueMap.getFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.util.MultiValueMap
的用法示例。
在下文中一共展示了MultiValueMap.getFirst方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createServiceInfo
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
@Override
public VaultServiceInfo createServiceInfo(String id, String uri) {
UriComponents uriInfo = UriComponentsBuilder.fromUriString(uri).build();
String address = UriComponentsBuilder.newInstance() //
.scheme(uriInfo.getScheme()) //
.host(uriInfo.getHost()) //
.port(uriInfo.getPort()) //
.build().toString();
MultiValueMap<String, String> queryParams = uriInfo.getQueryParams();
String token = queryParams.getFirst("token");
Assert.hasText(token, "Token (token=…) must not be empty");
Map<String, String> backends = getBackends(queryParams, backendPattern);
Map<String, String> sharedBackends = getBackends(queryParams,
sharedBackendPattern);
return new VaultServiceInfo(id, address, token.toCharArray(), backends,
sharedBackends);
}
示例2: registerBeanDefinitions
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata metadata,
BeanDefinitionRegistry registry) {
MultiValueMap<String, Object> attributes = metadata
.getAllAnnotationAttributes(
EnableConfigService.class.getName(), false);
Object[] type = attributes == null ? null
: (Object[]) attributes.getFirst("converters");
if (type == null || type.length == 0) {
return;
}
List<Class<?>> types = collectClasses(attributes.get("converters"));
// for (Class<?> type : types) {
// String name = type.getName();
// if (!registry.containsBeanDefinition(name)) {
// registerBeanDefinition(registry, type, name);
// }
// }
registerConverters(registry, types);
}
示例3: findAllConnections
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void findAllConnections() {
connectionFactoryRegistry.addConnectionFactory(new TestTwitterConnectionFactory());
insertTwitterConnection();
insertFacebookConnection();
MultiValueMap<String, Connection<?>> connections = connectionRepository.findAllConnections();
assertEquals(2, connections.size());
Connection<TestFacebookApi> facebook = (Connection<TestFacebookApi>) connections.getFirst("facebook");
assertFacebookConnection(facebook);
Connection<TestTwitterApi> twitter = (Connection<TestTwitterApi>) connections.getFirst("twitter");
assertTwitterConnection(twitter);
}
示例4: fromRequestBody
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
@Override
public Credential fromRequestBody(@NotNull final MultiValueMap<String, String> requestBody) {
final String username = requestBody.getFirst("username");
final String password = requestBody.getFirst("password");
if(username == null || password == null) {
throw new BadRequestException("Invalid payload. 'username' and 'password' form fields are required.");
}
return new UsernamePasswordCredential(requestBody.getFirst("username"), requestBody.getFirst("password"));
}
示例5: fromRequestBody
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
@Override
public Credential fromRequestBody(final MultiValueMap<String, String> requestBody) {
final String username = requestBody.getFirst(USERNAME);
final String password = requestBody.getFirst(PASSWORD);
if (username == null || password == null) {
throw new BadRequestException("Invalid payload. 'username' and 'password' form fields are required.");
}
return new UsernamePasswordCredential(requestBody.getFirst(USERNAME),
requestBody.getFirst(PASSWORD));
}
示例6: fromRequestBody
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
@Override
public Credential fromRequestBody(final MultiValueMap<String, String> requestBody) {
final String cert = requestBody.getFirst(CERTIFICATE);
LOGGER.debug("Certificate in the request body: [{}]", cert);
if (StringUtils.isBlank(cert)) {
return super.fromRequestBody(requestBody);
}
final InputStream is = new ByteArrayInputStream(cert.getBytes());
final InputStreamSource iso = new InputStreamResource(is);
final X509Certificate certificate = CertUtils.readCertificate(iso);
final X509CertificateCredential credential = new X509CertificateCredential(new X509Certificate[]{certificate});
credential.setCertificate(certificate);
return credential;
}
示例7: registerBeanDefinitions
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
MultiValueMap<String, Object> attributes = metadata.getAllAnnotationAttributes(EnableMessageSource.class.getName(), false);
boolean fallbackToSystemLocale = (boolean) (attributes != null ? attributes.getFirst("fallbackToSystemLocale") : false);
String[] basenames = (String[]) (attributes != null ? attributes.getFirst("basenames") : null);
BeanDefinitionBuilder bean = BeanDefinitionBuilder.genericBeanDefinition(ConfigMessageSourceConfigurer.class);
bean.addPropertyValue("fallbackToSystemLocale", fallbackToSystemLocale);
if (basenames != null && basenames.length > 0) {
bean.addPropertyValue("basenames", basenames);
}
registry.registerBeanDefinition(ConfigMessageSourceConfigurer.class.getName(), bean.getBeanDefinition());
}
示例8: doPost
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
// Check that we have a file upload request
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if (!isMultipart) {
return;
}
try {
MultipartHttpServletRequest
multiRequest =
new CommonsMultipartResolver().resolveMultipart(request);
MultiValueMap<String, MultipartFile> fileMap = multiRequest.getMultiFileMap();
BlobstoreService blobstoreService = AppFactory.get().getBlobstoreService();
Map<String, String> names = new HashMap<>(1);
for (String fieldName : fileMap.keySet()) {
MultipartFile file = fileMap.getFirst(fieldName);
String fileName = file.getOriginalFilename();
String contentType = file.getContentType();
long sizeInBytes = file.getSize();
String
blobKey =
blobstoreService.store(fileName, contentType, sizeInBytes, file.getInputStream());
names.put(fieldName, blobKey);
}
request.getSession().setAttribute("blobs", names);
RequestDispatcher
dispatcher =
getServletContext().getRequestDispatcher(request.getParameter("ru"));
dispatcher.forward(multiRequest, response);
} catch (Exception ex) {
_logger.severe("Upload failed", ex);
}
}
示例9: doPost
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
// Check that we have a file upload request
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if (!isMultipart) {
return;
}
try {
MultipartHttpServletRequest
multiRequest =
new CommonsMultipartResolver().resolveMultipart(request);
MultiValueMap<String, MultipartFile> fileMap = multiRequest.getMultiFileMap();
BlobstoreService blobstoreService = AppFactory.get().getBlobstoreService();
Map<String, String> names = new HashMap<>(1);
for (String fieldName : fileMap.keySet()) {
MultipartFile file = fileMap.getFirst(fieldName);
String fileName = file.getOriginalFilename();
String contentType = file.getContentType();
long sizeInBytes = file.getSize();
String
blobKey =
blobstoreService.store(fileName, contentType, sizeInBytes, file.getInputStream());
names.put(fieldName, blobKey);
names.put("file", fileName);
}
response.getWriter().write(new Gson().toJson(names));
response.setStatus(HttpStatus.SC_CREATED);
} catch (Exception ex) {
_logger.severe("Upload failed", ex);
}
}
示例10: selectImports
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
@Override
public String[] selectImports(AnnotationMetadata metadata) {
MultiValueMap<String,Object> attributes = metadata.getAllAnnotationAttributes(EnableMenu.class.getName(),
false);
String pluginId = attributes == null ? null : (String) attributes.getFirst("pluginId");
if (StringUtils.isEmpty(pluginId)) {
return new String[0];
}
return new String[]{MenuPluginBeanRegistrar.class.getName()};
}
示例11: extract
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
@Override
public List<InstanceDai.Value> extract(WriteContext context, RefreshEntireValueApi.SubIdForm form, MultiValueMap<String, IntensionDai.Record> dict) {
List<InstanceDai.Value> instances = new ArrayList<>();
Date now = new Date();
Map<String, List<String>> map = form.getMap();
for (String field : map.keySet()) {
String dictField = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, field);
IntensionDai.Record record = dict.getFirst(dictField);
if (record == null) {
logger.warn("cannot find field [{}]", field);
continue;
}
String intId = record.getId();
String[] values = cleanUpValues(map.get(field).toArray(new RefreshPartialValueApi.Value[0]));
InstanceDai.Value value = ValueMapping.from(InstanceDai.Value.class, context, form);
value.setId(String.valueOf(setgen.born()));
value.setExtId(record.getExtId());
value.setIntId(intId);
value.setField(dictField);
value.setValues(values);
value.setBeginTime(now);
value.setCommit(HashTools.hashHex(value));
instances.add(value);
}
return instances;
}
示例12: submitDeployJob
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
public String submitDeployJob ( String requestedByUserid, ServiceInstance instance,
MultiValueMap<String, String> rebuildVariables, boolean isPerformStart,
boolean isForceDeploy ) {
String buildItem = "User: " + requestedByUserid + " service: " + instance.getServiceName_Port();
if ( getBuildList().size() == 0 ||
(getBuildList().size() > 0 && !getBuildList().contains( buildItem )) ) {
// update deploy file to reflect new schedule in progress.
try {
OutputFileMgr outputFm = new OutputFileMgr(
csapApp.getProcessingDir(), "/"
+ instance.getServiceName_Port() + DEPLOY_OP );
outputFm.print( "*** Scheduling Deployment" );
outputFm.close();
// do not to opComplete as UI polling will end
} catch (IOException e) {
// Emptying
}
}
if ( !instance.getServiceName().equals( INIT_COMPLETE ) ) {
buildItem = "User: " + requestedByUserid + " Service: " + instance.getServiceName();
getBuildList().add( buildItem );
String userName = Application.SYS_USER;
if ( rebuildVariables != null && rebuildVariables.containsKey( "scmUserid" ) ) {
userName = rebuildVariables.getFirst( "scmUserid" );
}
csapEventClient.generateEvent( CsapEventClient.CSAP_SVC_CATEGORY + "/" + instance.getServiceName(),
userName, "Deployment Queued",
"Timeout configured in cluster.js: "
+ instance.getDeployTimeOutSeconds() + ", Command: \n" + rebuildVariables );
}
serviceJobExecutor.submit( () -> deployServiceRunnable( requestedByUserid,
instance, rebuildVariables, isPerformStart, isForceDeploy ) );
return buildItem;
}
示例13: shouldInitiateCredentialFlow
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
@Test
public void shouldInitiateCredentialFlow() throws UnsupportedEncodingException {
final ResponseEntity<AcquisitionResponse> acquisitionResponse = post(
"/api/v1/connectors/test-provider/credentials", Collections.singletonMap("returnUrl", "/ui#state"),
AcquisitionResponse.class, tokenRule.validToken(), HttpStatus.ACCEPTED);
assertThat(acquisitionResponse.hasBody()).as("Should present a acquisition response in the HTTP body").isTrue();
final AcquisitionResponse response = acquisitionResponse.getBody();
assertThat(response.getType()).isEqualTo(Type.OAUTH2);
final String redirectUrl = response.getRedirectUrl();
assertThat(redirectUrl).as("Should redirect to Salesforce and containthe correct callback URL")
.startsWith("https://test/oauth2/authorize?client_id=testClientId&response_type=code&redirect_uri=")
.contains(encode("/api/v1/credentials/callback", "ASCII"));
final MultiValueMap<String, String> params = UriComponentsBuilder.fromHttpUrl(redirectUrl).build()
.getQueryParams();
final String state = params.getFirst("state");
assertThat(state).as("state parameter should be set").isNotEmpty();
final State responseStateInstruction = response.state();
assertThat(responseStateInstruction).as("acquisition response should contain the state instruction")
.isNotNull();
assertThat(responseStateInstruction.persist()).isEqualByComparingTo(State.Persist.COOKIE);
assertThat(responseStateInstruction.spec()).isNotEmpty();
final CredentialFlowState credentialFlowState = clientSideState
.restoreFrom(Cookie.valueOf(responseStateInstruction.spec()), CredentialFlowState.class);
final CredentialFlowState expected = new OAuth2CredentialFlowState.Builder().key("test-state")
.providerId("test-provider").build();
assertThat(credentialFlowState).as("The flow state should be as expected")
.isEqualToIgnoringGivenFields(expected, "returnUrl");
final URI returnUrl = credentialFlowState.getReturnUrl();
assertThat(returnUrl).isNotNull();
assertThat(returnUrl.isAbsolute()).isTrue();
assertThat(returnUrl.getPath()).isEqualTo("/ui");
assertThat(returnUrl.getFragment()).isEqualTo("state");
}
示例14: obtainCredential
import org.springframework.util.MultiValueMap; //导入方法依赖的package包/类
/**
* Obtain credential from the request. Could be overridden by subclasses.
*
* @param requestBody raw entity request body
* @return the credential instance
*/
protected Credential obtainCredential(final MultiValueMap<String, String> requestBody) {
return new UsernamePasswordCredential(requestBody.getFirst("username"), requestBody.getFirst("password"));
}