Skip to content

Commit aebed72

Browse files
committed
migrated to jaxrs2.compiling, corsfilter fixed
1 parent 87d2fa2 commit aebed72

File tree

52 files changed

+1413
-1373
lines changed

Some content is hidden

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

52 files changed

+1413
-1373
lines changed

restcomm/pom.xml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@
102102
<servlet-api.version>7.0.50</servlet-api.version>
103103
<shirocore.version>1.2.0</shirocore.version>
104104
<shiroweb.version>1.2.0</shiroweb.version>
105-
<jersey.version>1.13</jersey.version>
106105
<httpclient.version>4.5.2</httpclient.version>
107106
<httpasyncclient.version>4.1.3</httpasyncclient.version>
108107
<gson.version>2.3.1</gson.version>
@@ -333,16 +332,12 @@
333332
</dependency>
334333

335334
<dependency>
336-
<groupId>com.sun.jersey</groupId>
337-
<artifactId>jersey-server</artifactId>
338-
<version>${jersey.version}</version>
335+
<groupId>org.glassfish.jersey.containers</groupId>
336+
<artifactId>jersey-container-servlet</artifactId>
337+
<version>2.25.1</version>
339338
</dependency>
340339

341-
<dependency>
342-
<groupId>com.sun.jersey</groupId>
343-
<artifactId>jersey-client</artifactId>
344-
<version>${jersey.version}</version>
345-
</dependency>
340+
346341

347342
<dependency>
348343
<groupId>stax</groupId>

restcomm/restcomm.application/src/main/webapp/WEB-INF/web.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77

88
<servlet>
99
<servlet-name>Jersey</servlet-name>
10-
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
10+
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
1111
<!-- Enable CORS request filter -->
1212
<init-param>
13-
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
14-
<param-value>org.restcomm.connect.http.cors.CorsFilter</param-value>
13+
<param-name>jersey.config.server.provider.packages</param-name>
14+
<param-value>org.restcomm.connect.http</param-value>
1515
</init-param>
16+
<init-param>
17+
<param-name>jersey.config.server.provider.classnames</param-name>
18+
<param-value>org.restcomm.connect.http.cors.CorsFilter</param-value>
19+
</init-param>
1620
</servlet>
1721

1822
<context-param>

restcomm/restcomm.extension.api/pom.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919
</properties>
2020

2121
<dependencies>
22-
<dependency>
23-
<groupId>com.sun.jersey</groupId>
24-
<artifactId>jersey-core</artifactId>
25-
<version>${jersey.version}</version>
26-
</dependency>
2722

23+
<dependency>
24+
<groupId>org.glassfish.jersey.containers</groupId>
25+
<artifactId>jersey-container-servlet</artifactId>
26+
</dependency>
2827
<dependency>
2928
<groupId>joda-time</groupId>
3029
<artifactId>joda-time</artifactId>

restcomm/restcomm.http/pom.xml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,16 @@
4848
<artifactId>httpasyncclient</artifactId>
4949
</dependency>
5050

51-
<dependency>
52-
<groupId>com.sun.jersey</groupId>
53-
<artifactId>jersey-server</artifactId>
54-
</dependency>
55-
56-
<dependency>
57-
<groupId>com.sun.jersey</groupId>
58-
<artifactId>jersey-client</artifactId>
59-
</dependency>
60-
61-
<dependency>
62-
<groupId>com.sun.jersey</groupId>
63-
<artifactId>jersey-servlet</artifactId>
64-
<version>${jersey.version}</version>
65-
</dependency>
66-
6751
<dependency>
6852
<groupId>com.thoughtworks.xstream</groupId>
6953
<artifactId>xstream</artifactId>
7054
</dependency>
7155

56+
<dependency>
57+
<groupId>org.glassfish.jersey.containers</groupId>
58+
<artifactId>jersey-container-servlet</artifactId>
59+
</dependency>
60+
7261
<dependency>
7362
<groupId>org.restcomm</groupId>
7463
<artifactId>restcomm-connect.commons</artifactId>

restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/AccountsEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import com.google.gson.Gson;
2323
import com.google.gson.GsonBuilder;
24-
import com.sun.jersey.core.util.MultivaluedMapImpl;
2524
import com.thoughtworks.xstream.XStream;
2625
import org.apache.commons.configuration.Configuration;
2726
import org.apache.shiro.crypto.hash.Md5Hash;
@@ -70,6 +69,7 @@
7069
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
7170
import static javax.ws.rs.core.MediaType.APPLICATION_XML;
7271
import static javax.ws.rs.core.MediaType.APPLICATION_XML_TYPE;
72+
import javax.ws.rs.core.MultivaluedHashMap;
7373
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
7474
import static javax.ws.rs.core.Response.Status.CONFLICT;
7575
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
@@ -409,7 +409,7 @@ protected Response putAccount(final MultivaluedMap<String, String> data, final M
409409
accountsDao.addAccount(account);
410410

411411
// Create default SIP client data
412-
MultivaluedMap<String, String> clientData = new MultivaluedMapImpl();
412+
MultivaluedMap<String, String> clientData = new MultivaluedHashMap();
413413
String username = data.getFirst("EmailAddress").split("@")[0];
414414
clientData.add("Login", username);
415415
clientData.add("Password", data.getFirst("Password"));

restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/cors/CorsFilter.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020

2121
package org.restcomm.connect.http.cors;
2222

23-
import com.sun.jersey.spi.container.ContainerRequest;
24-
import com.sun.jersey.spi.container.ContainerResponse;
25-
import com.sun.jersey.spi.container.ContainerResponseFilter;
23+
import javax.ws.rs.container.ContainerResponseContext;
24+
import javax.ws.rs.container.ContainerResponseFilter;
2625
import org.apache.commons.configuration.ConfigurationException;
2726
import org.apache.commons.configuration.XMLConfiguration;
2827
import org.apache.commons.lang.StringUtils;
@@ -33,11 +32,11 @@
3332
import org.restcomm.connect.commons.configuration.sources.ConfigurationSource;
3433

3534
import javax.servlet.ServletContext;
36-
import javax.servlet.ServletRequest;
37-
import javax.servlet.http.HttpServletRequest;
3835
import javax.ws.rs.core.Context;
3936
import javax.ws.rs.ext.Provider;
4037
import java.io.File;
38+
import java.io.IOException;
39+
import javax.ws.rs.container.ContainerRequestContext;
4140

4241
/**
4342
* @author otsakir@gmail.com - Orestis Tsakiridis
@@ -46,35 +45,37 @@
4645
public class CorsFilter implements ContainerResponseFilter {
4746
private final Logger logger = Logger.getLogger(CorsFilter.class);
4847

49-
@Context
50-
private HttpServletRequest servletRequest;
48+
/*@Context
49+
private HttpServletRequest servletRequest;*/
5150

5251
// we initialize this lazily upon first request since it can't be injected through the @Context annotation (it didn't work)
52+
@Context
5353
private ServletContext lazyServletContext;
5454

5555
String allowedOrigin;
5656

57+
58+
5759
// We return Access-* headers only in case allowedOrigin is present and equals to the 'Origin' header.
5860
@Override
59-
public ContainerResponse filter(ContainerRequest cres, ContainerResponse response) {
60-
initLazily(servletRequest);
61-
String requestOrigin = cres.getHeaderValue("Origin");
61+
public void filter(ContainerRequestContext cres, ContainerResponseContext response) throws IOException {
62+
initLazily();
63+
String requestOrigin = cres.getHeaderString("Origin");
6264
if (requestOrigin != null) { // is this is a cors request (ajax request that targets a different domain than the one the page was loaded from)
6365
if (allowedOrigin != null && allowedOrigin.startsWith(requestOrigin)) { // no cors allowances make are applied if allowedOrigins == null
6466
// only return the origin the client informed
65-
response.getHttpHeaders().add("Access-Control-Allow-Origin", requestOrigin);
66-
response.getHttpHeaders().add("Access-Control-Allow-Headers", "origin, content-type, accept, authorization");
67-
response.getHttpHeaders().add("Access-Control-Allow-Credentials", "true");
68-
response.getHttpHeaders().add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD");
69-
response.getHttpHeaders().add("Access-Control-Max-Age", "1209600");
67+
response.getHeaders().add("Access-Control-Allow-Origin", requestOrigin);
68+
response.getHeaders().add("Access-Control-Allow-Headers", "origin, content-type, accept, authorization");
69+
response.getHeaders().add("Access-Control-Allow-Credentials", "true");
70+
response.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD");
71+
response.getHeaders().add("Access-Control-Max-Age", "1209600");
7072
}
7173
}
72-
return response;
7374
}
7475

75-
private void initLazily(ServletRequest request) {
76-
if (lazyServletContext == null) {
77-
ServletContext context = request.getServletContext();
76+
private void initLazily() {
77+
if (allowedOrigin == null) {
78+
ServletContext context = lazyServletContext;
7879
String rootPath = context.getRealPath("/");
7980
rootPath = StringUtils.stripEnd(rootPath,"/"); // remove trailing "/" character
8081
String restcommXmlPath = rootPath + "/WEB-INF/conf/restcomm.xml";

restcomm/restcomm.identity/pom.xml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,10 @@
4545
<scope>provided</scope>
4646
</dependency>
4747

48-
<dependency>
49-
<groupId>com.sun.jersey</groupId>
50-
<artifactId>jersey-server</artifactId>
51-
</dependency>
52-
53-
<dependency>
54-
<groupId>com.sun.jersey</groupId>
55-
<artifactId>jersey-client</artifactId>
56-
</dependency>
57-
58-
<dependency>
59-
<groupId>com.sun.jersey</groupId>
60-
<artifactId>jersey-servlet</artifactId>
61-
<version>${jersey.version}</version>
62-
</dependency>
48+
<dependency>
49+
<groupId>org.glassfish.jersey.containers</groupId>
50+
<artifactId>jersey-container-servlet</artifactId>
51+
</dependency>
6352

6453
<dependency>
6554
<groupId>com.thoughtworks.xstream</groupId>

restcomm/restcomm.provisioning.number.voxbone/pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
<artifactId>mail</artifactId>
2929
</dependency>
3030

31-
<dependency>
32-
<groupId>com.sun.jersey</groupId>
33-
<artifactId>jersey-client</artifactId>
34-
</dependency>
35-
31+
<dependency>
32+
<groupId>org.glassfish.jersey.containers</groupId>
33+
<artifactId>jersey-container-servlet</artifactId>
34+
</dependency>
35+
3636
<dependency>
3737
<groupId>com.google.code.gson</groupId>
3838
<artifactId>gson</artifactId>

0 commit comments

Comments
 (0)