use of org.orcid.core.version.ApiSection 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.orcid.core.version.ApiSection in project ORCID-Source by ORCID.
the class ApiVersionFilter method checkSection.
private void checkSection(HttpServletRequest httpRequest, String version) {
String path = httpRequest.getServletPath();
Matcher notifcationsMatcher = NOTIFICATIONS_PATTERN.matcher(path);
ApiSection section = ApiSection.V1;
if (notifcationsMatcher.find()) {
section = ApiSection.NOTIFICATIONS;
} else if (version != null && version.startsWith("2.")) {
section = ApiSection.V2;
} else if (version != null && version.startsWith("3.")) {
section = ApiSection.V3;
}
httpRequest.setAttribute(API_SECTION_REQUEST_ATTRIBUTE_NAME, section);
}
Aggregations