use of org.springframework.web.servlet.mvc.condition.ParamsRequestCondition in project spring-framework by spring-projects.
the class RequestMappingInfo method getMatchingCondition.
/**
* Checks if all conditions in this request mapping info match the provided request and returns
* a potentially new request mapping info with conditions tailored to the current request.
* <p>For example the returned instance may contain the subset of URL patterns that match to
* the current request, sorted with best matching patterns on top.
* @return a new instance in case all conditions match; or {@code null} otherwise
*/
@Override
public RequestMappingInfo getMatchingCondition(HttpServletRequest request) {
RequestMethodsRequestCondition methods = this.methodsCondition.getMatchingCondition(request);
ParamsRequestCondition params = this.paramsCondition.getMatchingCondition(request);
HeadersRequestCondition headers = this.headersCondition.getMatchingCondition(request);
ConsumesRequestCondition consumes = this.consumesCondition.getMatchingCondition(request);
ProducesRequestCondition produces = this.producesCondition.getMatchingCondition(request);
if (methods == null || params == null || headers == null || consumes == null || produces == null) {
return null;
}
PatternsRequestCondition patterns = this.patternsCondition.getMatchingCondition(request);
if (patterns == null) {
return null;
}
RequestConditionHolder custom = this.customConditionHolder.getMatchingCondition(request);
if (custom == null) {
return null;
}
return new RequestMappingInfo(this.name, patterns, methods, params, headers, consumes, produces, custom.getCondition());
}
use of org.springframework.web.servlet.mvc.condition.ParamsRequestCondition in project spring-security-oauth by spring-projects.
the class FrameworkEndpointHandlerMapping method getMappingForMethod.
@Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
RequestMappingInfo defaultMapping = super.getMappingForMethod(method, handlerType);
if (defaultMapping == null) {
return null;
}
Set<String> defaultPatterns = defaultMapping.getPatternsCondition().getPatterns();
String[] patterns = new String[defaultPatterns.size()];
int i = 0;
for (String pattern : defaultPatterns) {
patterns[i] = getPath(pattern);
paths.add(pattern);
i++;
}
PatternsRequestCondition patternsInfo = new PatternsRequestCondition(patterns, getUrlPathHelper(), getPathMatcher(), useSuffixPatternMatch(), useTrailingSlashMatch(), getFileExtensions());
ParamsRequestCondition paramsInfo = defaultMapping.getParamsCondition();
if (!approvalParameter.equals(OAuth2Utils.USER_OAUTH_APPROVAL) && defaultPatterns.contains("/oauth/authorize")) {
String[] params = new String[paramsInfo.getExpressions().size()];
Set<NameValueExpression<String>> expressions = paramsInfo.getExpressions();
i = 0;
for (NameValueExpression<String> expression : expressions) {
String param = expression.toString();
if (OAuth2Utils.USER_OAUTH_APPROVAL.equals(param)) {
params[i] = approvalParameter;
} else {
params[i] = param;
}
i++;
}
paramsInfo = new ParamsRequestCondition(params);
}
RequestMappingInfo mapping = new RequestMappingInfo(patternsInfo, defaultMapping.getMethodsCondition(), paramsInfo, defaultMapping.getHeadersCondition(), defaultMapping.getConsumesCondition(), defaultMapping.getProducesCondition(), defaultMapping.getCustomCondition());
return mapping;
}
use of org.springframework.web.servlet.mvc.condition.ParamsRequestCondition in project spring-framework by spring-projects.
the class RequestMappingInfo method combine.
/**
* Combines "this" request mapping info (i.e. the current instance) with another request mapping info instance.
* <p>Example: combine type- and method-level request mappings.
* @return a new request mapping info instance; never {@code null}
*/
@Override
public RequestMappingInfo combine(RequestMappingInfo other) {
String name = combineNames(other);
PatternsRequestCondition patterns = this.patternsCondition.combine(other.patternsCondition);
RequestMethodsRequestCondition methods = this.methodsCondition.combine(other.methodsCondition);
ParamsRequestCondition params = this.paramsCondition.combine(other.paramsCondition);
HeadersRequestCondition headers = this.headersCondition.combine(other.headersCondition);
ConsumesRequestCondition consumes = this.consumesCondition.combine(other.consumesCondition);
ProducesRequestCondition produces = this.producesCondition.combine(other.producesCondition);
RequestConditionHolder custom = this.customConditionHolder.combine(other.customConditionHolder);
return new RequestMappingInfo(name, patterns, methods, params, headers, consumes, produces, custom.getCondition());
}
Aggregations