use of org.springframework.web.context.request.RequestAttributes in project ORCID-Source by ORCID.
the class OrcidExceptionMapper method getApiSection.
private ApiSection getApiSection() {
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
ApiSection apiSection = (ApiSection) requestAttributes.getAttribute(ApiVersionFilter.API_SECTION_REQUEST_ATTRIBUTE_NAME, RequestAttributes.SCOPE_REQUEST);
return apiSection != null ? apiSection : ApiSection.V1;
}
use of org.springframework.web.context.request.RequestAttributes in project ORCID-Source by ORCID.
the class OrcidExceptionMapper method getApiVersion.
private String getApiVersion() {
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
String apiVersion = (String) requestAttributes.getAttribute(ApiVersionFilter.API_VERSION_REQUEST_ATTRIBUTE_NAME, RequestAttributes.SCOPE_REQUEST);
return apiVersion;
}
use of org.springframework.web.context.request.RequestAttributes in project ORCID-Source by ORCID.
the class OrcidValidationJaxbContextResolver method getApiVersion.
private String getApiVersion() {
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
String apiVersion = (String) requestAttributes.getAttribute(ApiVersionFilter.API_VERSION_REQUEST_ATTRIBUTE_NAME, RequestAttributes.SCOPE_REQUEST);
return apiVersion;
}
use of org.springframework.web.context.request.RequestAttributes in project ORCID-Source by ORCID.
the class ValidationManagerForLegacyApiVersionsImpl method doSchemaValidation.
@Override
protected void doSchemaValidation(OrcidMessage orcidMessage) {
// Hack to support legacy API versions
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
if (requestAttributes instanceof ServletRequestAttributes) {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) requestAttributes;
String contentType = servletRequestAttributes.getRequest().getContentType();
if (!StringUtils.containsIgnoreCase(contentType, "json")) {
super.doSchemaValidation(orcidMessage);
}
} else {
super.doSchemaValidation(orcidMessage);
}
}
use of org.springframework.web.context.request.RequestAttributes in project geode by apache.
the class ShellCommandsControllerJUnitTest method getControllerWebServiceEndpoints.
private List<String> getControllerWebServiceEndpoints() {
RequestAttributes requestAttrs = RequestContextHolder.getRequestAttributes();
HttpServletRequest servletRequest = ((ServletRequestAttributes) requestAttrs).getRequest();
String scheme = servletRequest.getScheme();
try {
Set<Class<?>> controllerClasses = scanPackageForClassesExtending("org.apache.geode.management.internal.web.controllers", AbstractCommandsController.class);
List<String> controllerWebServiceEndpoints = new ArrayList<>(controllerClasses.size());
for (Class<?> controllerClass : controllerClasses) {
if (!AbstractCommandsController.class.equals(controllerClass)) {
for (Method method : controllerClass.getMethods()) {
if (method.isAnnotationPresent(RequestMapping.class)) {
RequestMapping requestMappingAnnotation = method.getAnnotation(RequestMapping.class);
String webServiceEndpoint = String.format("%1$s %2$s", requestMappingAnnotation.method()[0], UriUtils.decode(controller.toUri(requestMappingAnnotation.value()[0], scheme).toString()));
String[] requestParameters = requestMappingAnnotation.params();
if (requestParameters.length > 0) {
webServiceEndpoint += "?".concat(StringUtils.join(requestParameters, "&"));
}
controllerWebServiceEndpoints.add(webServiceEndpoint);
}
}
}
}
return controllerWebServiceEndpoints;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations