Skip to content

Commit 65ac0c7

Browse files
authored
Merge pull request #6735 from ORCID/jersey-update-with-javax
Code that compiles with jersey 2.27 and loads the jersey context
2 parents b3a3481 + 3290a31 commit 65ac0c7

207 files changed

Lines changed: 2784 additions & 23645 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

orcid-api-common/pom.xml

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
<dependencies>
3434
<!-- Internal dependencies -->
35-
3635
<dependency>
3736
<groupId>${project.groupId}</groupId>
3837
<artifactId>orcid-core</artifactId>
@@ -58,15 +57,55 @@
5857
<groupId>org.springframework</groupId>
5958
<artifactId>spring-aop</artifactId>
6059
</dependency>
61-
<!-- http://mvnrepository.com/artifact/com.sun.jersey/jersey-server -->
60+
61+
<!-- Jersey Server -->
62+
<dependency>
63+
<groupId>org.glassfish.jersey.containers</groupId>
64+
<artifactId>jersey-container-servlet</artifactId>
65+
</dependency>
66+
<dependency>
67+
<groupId>org.glassfish.jersey.media</groupId>
68+
<artifactId>jersey-media-json-jackson</artifactId>
69+
</dependency>
6270
<dependency>
63-
<groupId>com.sun.jersey</groupId>
64-
<artifactId>jersey-server</artifactId>
65-
</dependency>
71+
<groupId>org.glassfish.jersey.core</groupId>
72+
<artifactId>jersey-server</artifactId>
73+
<version>${jersey.version}</version>
74+
</dependency>
6675
<dependency>
67-
<groupId>com.sun.jersey.contribs</groupId>
68-
<artifactId>jersey-spring</artifactId>
76+
<groupId>org.glassfish.jersey.ext</groupId>
77+
<artifactId>jersey-spring4</artifactId>
78+
<version>${jersey.version}</version>
6979
</dependency>
80+
<!-- Jersey client -->
81+
<dependency>
82+
<groupId>org.glassfish.jersey.core</groupId>
83+
<artifactId>jersey-client</artifactId>
84+
<version>${jersey.version}</version>
85+
</dependency>
86+
<dependency>
87+
<groupId>org.glassfish.jersey.inject</groupId>
88+
<artifactId>jersey-hk2</artifactId>
89+
<version>${jersey.version}</version>
90+
</dependency>
91+
<!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api -->
92+
<dependency>
93+
<groupId>javax.ws.rs</groupId>
94+
<artifactId>javax.ws.rs-api</artifactId>
95+
</dependency>
96+
<!-- https://mvnrepository.com/artifact/javax.inject/javax.inject -->
97+
<dependency>
98+
<groupId>javax.inject</groupId>
99+
<artifactId>javax.inject</artifactId>
100+
<version>1</version>
101+
</dependency>
102+
<!-- https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api -->
103+
<dependency>
104+
<groupId>javax.servlet</groupId>
105+
<artifactId>javax.servlet-api</artifactId>
106+
<scope>provided</scope>
107+
</dependency>
108+
70109
<dependency>
71110
<groupId>org.aspectj</groupId>
72111
<artifactId>aspectjrt</artifactId>
@@ -75,11 +114,7 @@
75114
<groupId>org.aspectj</groupId>
76115
<artifactId>aspectjweaver</artifactId>
77116
</dependency>
78-
79-
<dependency>
80-
<groupId>javax.servlet</groupId>
81-
<artifactId>javax.servlet-api</artifactId>
82-
</dependency>
117+
83118
<dependency>
84119
<groupId>javax.validation</groupId>
85120
<artifactId>validation-api</artifactId>
@@ -99,22 +134,16 @@
99134
<dependency>
100135
<groupId>org.apache.jena</groupId>
101136
<artifactId>jena-cmds</artifactId>
102-
</dependency>
103-
<dependency>
104-
<groupId>io.swagger</groupId>
105-
<artifactId>swagger-jersey-jaxrs</artifactId>
106-
<version>${swagger.version}</version>
107-
</dependency>
137+
</dependency>
108138

109139
<!-- citeproc support -->
110140
<dependency>
111141
<groupId>de.undercouch</groupId>
112142
<artifactId>citeproc-java</artifactId>
113143
<version>0.6</version>
114144
</dependency>
115-
145+
116146
<!-- Test dependencies -->
117-
118147
<dependency>
119148
<groupId>${project.groupId}</groupId>
120149
<artifactId>orcid-test</artifactId>
@@ -138,8 +167,8 @@
138167
<artifactId>maven-compiler-plugin</artifactId>
139168
<inherited>false</inherited>
140169
<configuration>
141-
<source>1.8</source>
142-
<target>1.8</target>
170+
<source>11</source>
171+
<target>11</target>
143172
</configuration>
144173
</plugin>
145174

orcid-api-common/src/main/java/org/orcid/api/common/analytics/APIEndpointParser.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
import java.util.List;
44

5-
import javax.ws.rs.core.PathSegment;
65

7-
import com.sun.jersey.spi.container.ContainerRequest;
6+
import org.glassfish.jersey.server.ContainerRequest;
7+
8+
import javax.ws.rs.core.PathSegment;
89

910
public class APIEndpointParser {
1011

@@ -33,7 +34,7 @@ public APIEndpointParser(ContainerRequest request) {
3334
}
3435

3536
private void parse(ContainerRequest request) {
36-
List<PathSegment> path = request.getPathSegments(true);
37+
List<PathSegment> path = request.getUriInfo().getPathSegments(true);
3738
int categoryIndex = 2;
3839
if (path.get(0).toString().matches(API_VERSION_REGEX)) {
3940
// found api version

orcid-api-common/src/main/java/org/orcid/api/common/analytics/AnalyticsProcess.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import org.orcid.persistence.jpa.entities.ProfileEntity;
1010
import org.springframework.http.HttpMethod;
1111

12-
import com.sun.jersey.spi.container.ContainerRequest;
13-
import com.sun.jersey.spi.container.ContainerResponse;
12+
import org.glassfish.jersey.server.ContainerRequest;
13+
import org.glassfish.jersey.server.ContainerResponse;
1414

1515
public class AnalyticsProcess implements Runnable {
1616

@@ -97,7 +97,7 @@ private AnalyticsData getAnalyticsData() {
9797
analyticsData.setClientId(clientDetailsId != null ? clientDetailsId : ip);
9898
analyticsData.setMethod(request.getMethod());
9999
analyticsData.setContentType(getContentType());
100-
analyticsData.setUserAgent(request.getHeaderValue(HttpHeaders.USER_AGENT));
100+
analyticsData.setUserAgent(request.getHeaderString(HttpHeaders.USER_AGENT));
101101
analyticsData.setResponseCode(response.getStatus());
102102
analyticsData.setIpAddress(ip);
103103
analyticsData.setCategory(parser.getCategory());
@@ -107,7 +107,7 @@ private AnalyticsData getAnalyticsData() {
107107

108108
private String getContentType() {
109109
if (HttpMethod.GET.name().equals(request.getMethod())) {
110-
String accept = request.getHeaderValue(HttpHeaders.ACCEPT);
110+
String accept = request.getHeaderString(HttpHeaders.ACCEPT);
111111
if (accept != null && !accept.isEmpty()) {
112112
return accept;
113113
}
@@ -116,7 +116,7 @@ private String getContentType() {
116116
// If accept header not set for GETs content type will be used - see
117117
// AcceptFilter.
118118
// For other methods content type will be used anyway
119-
String contentType = request.getHeaderValue(HttpHeaders.CONTENT_TYPE);
119+
String contentType = request.getHeaderString(HttpHeaders.CONTENT_TYPE);
120120
if (contentType != null && !contentType.isEmpty()) {
121121
return contentType;
122122
}

orcid-api-common/src/main/java/org/orcid/api/common/exception/JSONInputValidator.java

Lines changed: 2 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -32,48 +32,7 @@ public class JSONInputValidator {
3232
static {
3333
SCHEMA_LOCATIONS = new HashMap<>();
3434

35-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.record.Work.class, "/record_3.0_rc1/work-3.0_rc1.xsd");
36-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.record.Funding.class, "/record_3.0_rc1/funding-3.0_rc1.xsd");
37-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.record.Education.class, "/record_3.0_rc1/education-3.0_rc1.xsd");
38-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.record.Employment.class, "/record_3.0_rc1/employment-3.0_rc1.xsd");
39-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.record.PeerReview.class, "/record_3.0_rc1/peer-review-3.0_rc1.xsd");
40-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.groupid.GroupIdRecord.class, "/group-id-3.0_rc1/group-id-3.0_rc1.xsd");
41-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.notification.permission.NotificationPermission.class,
42-
"/notification_3.0_rc1/notification-permission-3.0_rc1.xsd");
43-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.record.ResearcherUrl.class, "/record_3.0_rc1/researcher-url-3.0_rc1.xsd");
44-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.record.OtherName.class, "/record_3.0_rc1/other-name-3.0_rc1.xsd");
45-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.record.PersonExternalIdentifier.class, "/record_3.0_rc1/person-external-identifier-3.0_rc1.xsd");
46-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.record.Keyword.class, "/record_3.0_rc1/keyword-3.0_rc1.xsd");
47-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.record.Address.class, "/record_3.0_rc1/address-3.0_rc1.xsd");
48-
49-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.record.Distinction.class, "/record_3.0_rc1/distinction-3.0_rc1.xsd");
50-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.record.InvitedPosition.class, "/record_3.0_rc1/invited-position-3.0_rc1.xsd");
51-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.record.Membership.class, "/record_3.0_rc1/membership-3.0_rc1.xsd");
52-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.record.Qualification.class, "/record_3.0_rc1/qualification-3.0_rc1.xsd");
53-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.record.Service.class, "/record_3.0_rc1/service-3.0_rc1.xsd");
54-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc1.record.ResearchResource.class, "/record_3.0_rc1/research-resource-3.0_rc1.xsd");
55-
56-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.record.Work.class, "/record_3.0_rc2/work-3.0_rc2.xsd");
57-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.record.Funding.class, "/record_3.0_rc2/funding-3.0_rc2.xsd");
58-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.record.Education.class, "/record_3.0_rc2/education-3.0_rc2.xsd");
59-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.record.Employment.class, "/record_3.0_rc2/employment-3.0_rc2.xsd");
60-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.record.PeerReview.class, "/record_3.0_rc2/peer-review-3.0_rc2.xsd");
61-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.groupid.GroupIdRecord.class, "/group-id-3.0_rc2/group-id-3.0_rc2.xsd");
62-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.notification.permission.NotificationPermission.class,
63-
"/notification_3.0_rc2/notification-permission-3.0_rc2.xsd");
64-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.record.ResearcherUrl.class, "/record_3.0_rc2/researcher-url-3.0_rc2.xsd");
65-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.record.OtherName.class, "/record_3.0_rc2/other-name-3.0_rc2.xsd");
66-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.record.PersonExternalIdentifier.class, "/record_3.0_rc2/person-external-identifier-3.0_rc2.xsd");
67-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.record.Keyword.class, "/record_3.0_rc2/keyword-3.0_rc2.xsd");
68-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.record.Address.class, "/record_3.0_rc2/address-3.0_rc2.xsd");
69-
70-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.record.Distinction.class, "/record_3.0_rc2/distinction-3.0_rc2.xsd");
71-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.record.InvitedPosition.class, "/record_3.0_rc2/invited-position-3.0_rc2.xsd");
72-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.record.Membership.class, "/record_3.0_rc2/membership-3.0_rc2.xsd");
73-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.record.Qualification.class, "/record_3.0_rc2/qualification-3.0_rc2.xsd");
74-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.record.Service.class, "/record_3.0_rc2/service-3.0_rc2.xsd");
75-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.rc2.record.ResearchResource.class, "/record_3.0_rc2/research-resource-3.0_rc2.xsd");
76-
35+
7736
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.release.record.Work.class, "/record_3.0/work-3.0.xsd");
7837
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.release.record.Funding.class, "/record_3.0/funding-3.0.xsd");
7938
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.v3.release.record.Education.class, "/record_3.0/education-3.0.xsd");
@@ -107,54 +66,7 @@ public class JSONInputValidator {
10766
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier.class, "/record_2.0/person-external-identifier-2.0.xsd");
10867
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_v2.Keyword.class, "/record_2.0/keyword-2.0.xsd");
10968
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_v2.Address.class, "/record_2.0/address-2.0.xsd");
110-
111-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc4.Work.class, "/record_2.0_rc4/work-2.0_rc4.xsd");
112-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc4.Funding.class, "/record_2.0_rc4/funding-2.0_rc4.xsd");
113-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc4.Education.class, "/record_2.0_rc4/education-2.0_rc4.xsd");
114-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc4.Employment.class, "/record_2.0_rc4/employment-2.0_rc4.xsd");
115-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc4.PeerReview.class, "/record_2.0_rc4/peer-review-2.0_rc4.xsd");
116-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.groupid_rc4.GroupIdRecord.class, "/group-id-2.0_rc4/group-id-2.0_rc4.xsd");
117-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.notification.permission_rc4.NotificationPermission.class, "/notification_2.0_rc4/notification-permission-2.0_rc4.xsd");
118-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc4.ResearcherUrl.class, "/record_2.0_rc4/researcher-url-2.0_rc4.xsd");
119-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc4.OtherName.class, "/record_2.0_rc4/other-name-2.0_rc4.xsd");
120-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier.class, "/record_2.0_rc4/person-external-identifier-2.0_rc4.xsd");
121-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc4.Keyword.class, "/record_2.0_rc4/keyword-2.0_rc4.xsd");
122-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc4.Address.class, "/record_2.0_rc4/address-2.0_rc4.xsd");
123-
124-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc3.Work.class, "/record_2.0_rc3/work-2.0_rc3.xsd");
125-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc3.Funding.class, "/record_2.0_rc3/funding-2.0_rc3.xsd");
126-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc3.Education.class, "/record_2.0_rc3/education-2.0_rc3.xsd");
127-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc3.Employment.class, "/record_2.0_rc3/employment-2.0_rc3.xsd");
128-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc3.PeerReview.class, "/record_2.0_rc3/peer-review-2.0_rc3.xsd");
129-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.groupid_rc3.GroupIdRecord.class, "/group-id-2.0_rc3/group-id-2.0_rc3.xsd");
130-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.notification.permission_rc3.NotificationPermission.class, "/notification_2.0_rc3/notification-permission-2.0_rc3.xsd");
131-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc3.ResearcherUrl.class, "/record_2.0_rc3/researcher-url-2.0_rc3.xsd");
132-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc3.OtherName.class, "/record_2.0_rc3/other-name-2.0_rc3.xsd");
133-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc3.PersonExternalIdentifier.class, "/record_2.0_rc3/person-external-identifier-2.0_rc3.xsd");
134-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc3.Keyword.class, "/record_2.0_rc3/keyword-2.0_rc3.xsd");
135-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc3.Address.class, "/record_2.0_rc3/address-2.0_rc3.xsd");
136-
137-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc2.Work.class, "/record_2.0_rc2/work-2.0_rc2.xsd");
138-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc2.Funding.class, "/record_2.0_rc2/funding-2.0_rc2.xsd");
139-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc2.Education.class, "/record_2.0_rc2/education-2.0_rc2.xsd");
140-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc2.Employment.class, "/record_2.0_rc2/employment-2.0_rc2.xsd");
141-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc2.PeerReview.class, "/record_2.0_rc2/peer-review-2.0_rc2.xsd");
142-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.groupid_rc2.GroupIdRecord.class, "/group-id-2.0_rc2/group-id-2.0_rc2.xsd");
143-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.notification.permission_rc2.NotificationPermission.class, "/notification_2.0_rc2/notification-permission-2.0_rc2.xsd");
144-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc2.ResearcherUrl.class, "/record_2.0_rc2/researcher-url-2.0_rc2.xsd");
145-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc2.OtherName.class, "/record_2.0_rc2/other-name-2.0_rc2.xsd");
146-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier.class, "/record_2.0_rc2/person-external-identifier-2.0_rc2.xsd");
147-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc2.Keyword.class, "/record_2.0_rc2/keyword-2.0_rc2.xsd");
148-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc2.Address.class, "/record_2.0_rc2/address-2.0_rc2.xsd");
149-
150-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc1.Work.class, "/record_2.0_rc1/work-2.0_rc1.xsd");
151-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc1.Funding.class, "/record_2.0_rc1/funding-2.0_rc1.xsd");
152-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc1.Education.class, "/record_2.0_rc1/education-2.0_rc1.xsd");
153-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc1.Employment.class, "/record_2.0_rc1/employment-2.0_rc1.xsd");
154-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.record_rc1.PeerReview.class, "/record_2.0_rc1/peer-review-2.0_rc1.xsd");
155-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.groupid_rc1.GroupIdRecord.class, "/group-id-2.0_rc1/group-id-2.0_rc1.xsd");
156-
SCHEMA_LOCATIONS.put(org.orcid.jaxb.model.notification.permission_rc1.NotificationPermission.class, "/notification_2.0_rc1/notification-permission-2.0_rc1.xsd");
157-
69+
15870
VALIDATORS = new HashMap<Class<?>, Validator>();
15971
CONTEXTS = new HashMap<Class<?>, JAXBContext>();
16072
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

orcid-api-common/src/main/java/org/orcid/api/common/filter/ApiVersionCheckFilter.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import java.util.regex.Pattern;
55

66
import javax.servlet.http.HttpServletRequest;
7+
import javax.ws.rs.container.ContainerRequestContext;
8+
import javax.ws.rs.container.ContainerRequestFilter;
79
import javax.ws.rs.core.Context;
810
import javax.ws.rs.ext.Provider;
911

@@ -12,16 +14,18 @@
1214
import org.orcid.core.manager.impl.OrcidUrlManager;
1315
import org.orcid.pojo.ajaxForm.PojoUtil;
1416
import org.orcid.core.utils.OrcidStringUtils;
17+
import org.springframework.beans.factory.annotation.Autowired;
1518
import org.springframework.web.bind.annotation.RequestMethod;
1619

17-
import com.sun.jersey.api.core.InjectParam;
18-
import com.sun.jersey.spi.container.ContainerRequest;
19-
import com.sun.jersey.spi.container.ContainerRequestFilter;
20+
21+
import javax.inject.Inject;
22+
import javax.inject.Named;
23+
2024

2125
@Provider
22-
public class ApiVersionCheckFilter implements ContainerRequestFilter {
26+
public class ApiVersionCheckFilter implements ContainerRequestFilter{
2327

24-
@InjectParam("localeManager")
28+
@Autowired
2529
private LocaleManager localeManager;
2630

2731
@Context private HttpServletRequest httpRequest;
@@ -43,15 +47,14 @@ public ApiVersionCheckFilter(LocaleManager locale, HttpServletRequest req) {
4347
}
4448

4549
@Override
46-
public ContainerRequest filter(ContainerRequest request) {
47-
String path = request.getPath();
50+
public void filter(ContainerRequestContext request) {
51+
String path = request.getUriInfo().getPath();
4852
String method = request.getMethod() == null ? null : request.getMethod().toUpperCase();
4953
Matcher matcher = VERSION_PATTERN.matcher(path);
5054
String version = null;
5155
if (matcher.lookingAt()) {
5256
version = matcher.group(1);
5357
}
54-
5558
if(PojoUtil.isEmpty(version) && !PojoUtil.isEmpty(method) && !"oauth/token".equals(path) && !path.matches(WEBHOOKS_PATH_PATTERN)) {
5659
if(!RequestMethod.GET.name().equals(method)) {
5760
Object params[] = {method};
@@ -67,6 +70,6 @@ public ContainerRequest filter(ContainerRequest request) {
6770
}
6871
}
6972

70-
return request;
73+
return;
7174
}
7275
}

0 commit comments

Comments
 (0)