Java Code Examples for org.springframework.util.MultiValueMap#keySet()

The following examples show how to use org.springframework.util.MultiValueMap#keySet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DocumentSecurityServiceImpl.java    From rice with Educational Community License v2.0 6 votes vote down vote up
protected MultiValueMap<PartitionKey, Document> partitionDocumentsForSecurity(List<Document> documents,
        SecuritySession securitySession) {
    MultiValueMap<PartitionKey, Document> partitions = new LinkedMultiValueMap<PartitionKey, Document>();
    for (Document document : documents) {
        DocumentTypeSecurity security = getDocumentTypeSecurity(document.getDocumentTypeName(), securitySession);
        MultiValueMap<String, ExtensionDefinition> securityAttributeExtensionDefinitions = loadExtensionDefinitions(
                security, securitySession);
        for (String applicationId : securityAttributeExtensionDefinitions.keySet()) {
            List<ExtensionDefinition> extensionDefinitions = securityAttributeExtensionDefinitions.get(
                    applicationId);
            PartitionKey key = new PartitionKey(applicationId, extensionDefinitions);
            partitions.add(key, document);
        }
    }
    return partitions;
}
 
Example 2
Source File: AbstractFlashMapManager.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Whether the given FlashMap matches the current request.
 * Uses the expected request path and query parameters saved in the FlashMap.
 */
protected boolean isFlashMapForRequest(FlashMap flashMap, HttpServletRequest request) {
	String expectedPath = flashMap.getTargetRequestPath();
	if (expectedPath != null) {
		String requestUri = getUrlPathHelper().getOriginatingRequestUri(request);
		if (!requestUri.equals(expectedPath) && !requestUri.equals(expectedPath + "/")) {
			return false;
		}
	}
	MultiValueMap<String, String> actualParams = getOriginatingRequestParams(request);
	MultiValueMap<String, String> expectedParams = flashMap.getTargetRequestParams();
	for (String expectedName : expectedParams.keySet()) {
		List<String> actualValues = actualParams.get(expectedName);
		if (actualValues == null) {
			return false;
		}
		for (String expectedValue : expectedParams.get(expectedName)) {
			if (!actualValues.contains(expectedValue)) {
				return false;
			}
		}
	}
	return true;
}
 
Example 3
Source File: AbstractFlashMapManager.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Whether the given FlashMap matches the current request.
 * Uses the expected request path and query parameters saved in the FlashMap.
 */
protected boolean isFlashMapForRequest(FlashMap flashMap, HttpServletRequest request) {
	String expectedPath = flashMap.getTargetRequestPath();
	if (expectedPath != null) {
		String requestUri = getUrlPathHelper().getOriginatingRequestUri(request);
		if (!requestUri.equals(expectedPath) && !requestUri.equals(expectedPath + "/")) {
			return false;
		}
	}
	UriComponents uriComponents = ServletUriComponentsBuilder.fromRequest(request).build();
	MultiValueMap<String, String> actualParams = uriComponents.getQueryParams();
	MultiValueMap<String, String> expectedParams = flashMap.getTargetRequestParams();
	for (String expectedName : expectedParams.keySet()) {
		List<String> actualValues = actualParams.get(expectedName);
		if (actualValues == null) {
			return false;
		}
		for (String expectedValue : expectedParams.get(expectedName)) {
			if (!actualValues.contains(expectedValue)) {
				return false;
			}
		}
	}
	return true;
}
 
Example 4
Source File: WebMvcStompEndpointRegistry.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Return a handler mapping with the mapped ViewControllers; or {@code null}
 * in case of no registrations.
 */
public AbstractHandlerMapping getHandlerMapping() {
	Map<String, Object> urlMap = new LinkedHashMap<String, Object>();
	for (WebMvcStompWebSocketEndpointRegistration registration : this.registrations) {
		MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
		for (HttpRequestHandler httpHandler : mappings.keySet()) {
			for (String pattern : mappings.get(httpHandler)) {
				urlMap.put(pattern, httpHandler);
			}
		}
	}
	WebSocketHandlerMapping hm = new WebSocketHandlerMapping();
	hm.setUrlMap(urlMap);
	hm.setOrder(this.order);
	if (this.urlPathHelper != null) {
		hm.setUrlPathHelper(this.urlPathHelper);
	}
	return hm;
}
 
Example 5
Source File: ServletWebSocketHandlerRegistry.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Return a {@link HandlerMapping} with mapped {@link HttpRequestHandler}s.
 */
public AbstractHandlerMapping getHandlerMapping() {
	Map<String, Object> urlMap = new LinkedHashMap<String, Object>();
	for (ServletWebSocketHandlerRegistration registration : this.registrations) {
		MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
		for (HttpRequestHandler httpHandler : mappings.keySet()) {
			for (String pattern : mappings.get(httpHandler)) {
				urlMap.put(pattern, httpHandler);
			}
		}
	}
	WebSocketHandlerMapping hm = new WebSocketHandlerMapping();
	hm.setUrlMap(urlMap);
	hm.setOrder(this.order);
	if (this.urlPathHelper != null) {
		hm.setUrlPathHelper(this.urlPathHelper);
	}
	return hm;
}
 
Example 6
Source File: AbstractFlashMapManager.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Whether the given FlashMap matches the current request.
 * Uses the expected request path and query parameters saved in the FlashMap.
 */
protected boolean isFlashMapForRequest(FlashMap flashMap, HttpServletRequest request) {
	String expectedPath = flashMap.getTargetRequestPath();
	if (expectedPath != null) {
		String requestUri = getUrlPathHelper().getOriginatingRequestUri(request);
		if (!requestUri.equals(expectedPath) && !requestUri.equals(expectedPath + "/")) {
			return false;
		}
	}
	MultiValueMap<String, String> actualParams = getOriginatingRequestParams(request);
	MultiValueMap<String, String> expectedParams = flashMap.getTargetRequestParams();
	for (String expectedName : expectedParams.keySet()) {
		List<String> actualValues = actualParams.get(expectedName);
		if (actualValues == null) {
			return false;
		}
		for (String expectedValue : expectedParams.get(expectedName)) {
			if (!actualValues.contains(expectedValue)) {
				return false;
			}
		}
	}
	return true;
}
 
Example 7
Source File: AuthorizationServerInfo.java    From spring-boot-demo with MIT License 6 votes vote down vote up
public HttpHeaders postForHeaders(String path, MultiValueMap<String, String> formData, final HttpHeaders headers) {
    RequestCallback requestCallback = new NullRequestCallback();
    if (headers != null) {
        requestCallback = request -> request.getHeaders().putAll(headers);
    }
    StringBuilder builder = new StringBuilder(getUrl(path));
    if (!path.contains("?")) {
        builder.append("?");
    } else {
        builder.append("&");
    }
    for (String key : formData.keySet()) {
        for (String value : formData.get(key)) {
            builder.append(key).append("=").append(value);
            builder.append("&");
        }
    }
    builder.deleteCharAt(builder.length() - 1);

    return client.execute(builder.toString(), HttpMethod.POST, requestCallback,
        HttpMessage::getHeaders);
}
 
Example 8
Source File: DubboProxyService.java    From bird-java with MIT License 6 votes vote down vote up
private Map<String, Object> resolveParam(ServerWebExchange exchange) {
    JSONObject param = new JSONObject();

    MultiValueMap<String, String> pathParams = exchange.getRequest().getQueryParams();
    for (String key : pathParams.keySet()) {
        param.put(key, pathParams.getFirst(key));
    }

    String base64 = exchange.getRequest().getHeaders().getFirst(GatewayConstant.DUBBO_PARAM_HEADER);
    if(StringUtils.isNotBlank(base64)){
        String body = null ;
        try {
            body = new String(Base64.getDecoder().decode(base64),"utf-8");
            param.put("body", GenericJsonDeserializer.parse(body));
        } catch (UnsupportedEncodingException e) {
            log.error("dubbo参数解析失败");
        }
    }
    return param;
}
 
Example 9
Source File: FlashMap.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Provide request parameters identifying the request for this FlashMap.
 * @param params a Map with the names and values of expected parameters
 */
public FlashMap addTargetRequestParams(MultiValueMap<String, String> params) {
	if (params != null) {
		for (String key : params.keySet()) {
			for (String value : params.get(key)) {
				addTargetRequestParam(key, value);
			}
		}
	}
	return this;
}
 
Example 10
Source File: FlashMap.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Provide request parameters identifying the request for this FlashMap.
 * @param params a Map with the names and values of expected parameters
 */
public FlashMap addTargetRequestParams(MultiValueMap<String, String> params) {
	if (params != null) {
		for (String key : params.keySet()) {
			for (String value : params.get(key)) {
				addTargetRequestParam(key, value);
			}
		}
	}
	return this;
}
 
Example 11
Source File: NativeMessageHeaderAccessor.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public void addNativeHeaders(MultiValueMap<String, String> headers) {
	if (headers == null) {
		return;
	}
	for (String header : headers.keySet()) {
		for (String value : headers.get(header)) {
			addNativeHeader(header, value);
		}
	}
}
 
Example 12
Source File: FunctionController.java    From spring-cloud-function with Apache License 2.0 5 votes vote down vote up
private MultiValueMap<String, String> multi(MultiValueMap<String, Part> body) {
	MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
	for (String key : body.keySet()) {
		for (Part part : body.get(key)) {
			if (part instanceof FormFieldPart) {
				FormFieldPart form = (FormFieldPart) part;
				map.add(key, form.value());
			}
		}
	}
	return map;
}
 
Example 13
Source File: APIMigrationTest.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
@Test
@Ignore
public void getRecommendationTest() {
	try {
		MultiValueMap<String, String> k = migrationService.recommendsSnippet(
				"org.sonarsource.sonarqube:sonar-plugin-api:5.6", "org.sonarsource.sonarqube:sonar-plugin-api:6.2",
				"/Users/juri/development/git/aethereal/aethereal/dataset/sonar-plugin-api6.2/org/sonarsource/java/java-frontend/4.5.0.8398/java-frontend-4.5.0.8398.jar.m3");
		for (String clientLoc : k.keySet())
			for (String snippet : k.get(clientLoc))
				logger.info("{} -> \n{} ", clientLoc, snippet);

	} catch (Exception e) {
		logger.error("Error in recommendation calculation: {}", e.getMessage());
	}
}
 
Example 14
Source File: FormHttpMessageConverter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private boolean isMultipart(MultiValueMap<String, ?> map, MediaType contentType) {
	if (contentType != null) {
		return MediaType.MULTIPART_FORM_DATA.includes(contentType);
	}
	for (String name : map.keySet()) {
		for (Object value : map.get(name)) {
			if (value != null && !(value instanceof String)) {
				return true;
			}
		}
	}
	return false;
}
 
Example 15
Source File: UrlPathHelper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Decode the given matrix variables via
 * {@link #decodeRequestString(HttpServletRequest, String)} unless
 * {@link #setUrlDecode(boolean)} is set to {@code true} in which case it is
 * assumed the URL path from which the variables were extracted is already
 * decoded through a call to
 * {@link #getLookupPathForRequest(HttpServletRequest)}.
 * @param request current HTTP request
 * @param vars URI variables extracted from the URL path
 * @return the same Map or a new Map instance
 */
public MultiValueMap<String, String> decodeMatrixVariables(HttpServletRequest request, MultiValueMap<String, String> vars) {
	if (this.urlDecode) {
		return vars;
	}
	else {
		MultiValueMap<String, String> decodedVars = new LinkedMultiValueMap	<String, String>(vars.size());
		for (String key : vars.keySet()) {
			for (String value : vars.get(key)) {
				decodedVars.add(key, decodeInternal(request, value));
			}
		}
		return decodedVars;
	}
}
 
Example 16
Source File: UrlPathHelper.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Decode the given matrix variables via
 * {@link #decodeRequestString(HttpServletRequest, String)} unless
 * {@link #setUrlDecode(boolean)} is set to {@code true} in which case it is
 * assumed the URL path from which the variables were extracted is already
 * decoded through a call to
 * {@link #getLookupPathForRequest(HttpServletRequest)}.
 * @param request current HTTP request
 * @param vars URI variables extracted from the URL path
 * @return the same Map or a new Map instance
 */
public MultiValueMap<String, String> decodeMatrixVariables(HttpServletRequest request, MultiValueMap<String, String> vars) {
	if (this.urlDecode) {
		return vars;
	}
	else {
		MultiValueMap<String, String> decodedVars = new LinkedMultiValueMap	<String, String>(vars.size());
		for (String key : vars.keySet()) {
			for (String value : vars.get(key)) {
				decodedVars.add(key, decodeInternal(request, value));
			}
		}
		return decodedVars;
	}
}
 
Example 17
Source File: FormHttpMessageConverter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private boolean isMultipart(MultiValueMap<String, ?> map, MediaType contentType) {
	if (contentType != null) {
		return MediaType.MULTIPART_FORM_DATA.includes(contentType);
	}
	for (String name : map.keySet()) {
		for (Object value : map.get(name)) {
			if (value != null && !(value instanceof String)) {
				return true;
			}
		}
	}
	return false;
}
 
Example 18
Source File: FormHttpMessageConverter.java    From java-technology-stack with MIT License 5 votes vote down vote up
private boolean isMultipart(MultiValueMap<String, ?> map, @Nullable MediaType contentType) {
	if (contentType != null) {
		return MediaType.MULTIPART_FORM_DATA.includes(contentType);
	}
	for (String name : map.keySet()) {
		for (Object value : map.get(name)) {
			if (value != null && !(value instanceof String)) {
				return true;
			}
		}
	}
	return false;
}
 
Example 19
Source File: FormHttpMessageConverter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private boolean isMultipart(MultiValueMap<String, ?> map, @Nullable MediaType contentType) {
	if (contentType != null) {
		return MediaType.MULTIPART_FORM_DATA.includes(contentType);
	}
	for (String name : map.keySet()) {
		for (Object value : map.get(name)) {
			if (value != null && !(value instanceof String)) {
				return true;
			}
		}
	}
	return false;
}
 
Example 20
Source File: AbstractPagingController.java    From taskana with Apache License 2.0 4 votes vote down vote up
protected void validateNoInvalidParameterIsLeft(MultiValueMap<String, String> params)
    throws InvalidArgumentException {
  if (!params.isEmpty()) {
    throw new InvalidArgumentException("Invalid parameter specified: " + params.keySet());
  }
}