summaryrefslogtreecommitdiffstats
path: root/appc-config/appc-config-adaptor
diff options
context:
space:
mode:
authorvmuthukrishnan <vmuthukrishnan@aarnanetworks.com>2019-08-13 17:44:22 +0000
committerTakamune Cho <takamune.cho@att.com>2019-08-30 23:40:59 +0000
commit35d8f73bfed6211b4d0e799880f991b001dbe0a6 (patch)
tree37511ceeca250948888432c28011046439dbdf17 /appc-config/appc-config-adaptor
parenta0c771eb01a35f907394582f3febb42d39f25799 (diff)
Updated jersey from com.sun.jersey to org.glassfish.jersey
ODL upgrade Change-Id: I1167ad7cdb429c9c3e2808db820e3fc26e605383 Signed-off-by: vmuthukrishnan <vmuthukrishnan@aarnanetworks.com> Issue-ID: APPC-1630
Diffstat (limited to 'appc-config/appc-config-adaptor')
-rw-r--r--appc-config/appc-config-adaptor/provider/pom.xml9
-rw-r--r--appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/ConfigComponentAdaptor.java35
-rw-r--r--appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/ConfigComponentAdaptorTest.java30
3 files changed, 44 insertions, 30 deletions
diff --git a/appc-config/appc-config-adaptor/provider/pom.xml b/appc-config/appc-config-adaptor/provider/pom.xml
index a0f681977..cb96a2e35 100644
--- a/appc-config/appc-config-adaptor/provider/pom.xml
+++ b/appc-config/appc-config-adaptor/provider/pom.xml
@@ -105,11 +105,16 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>com.sun.jersey</groupId>
+ <groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
- <version>1.17</version>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.glassfish.jersey.security</groupId>
+ <artifactId>oauth1-client</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt</artifactId>
diff --git a/appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/ConfigComponentAdaptor.java b/appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/ConfigComponentAdaptor.java
index f57f188d9..dd924229e 100644
--- a/appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/ConfigComponentAdaptor.java
+++ b/appc-config/appc-config-adaptor/provider/src/main/java/org/onap/appc/ccadaptor/ConfigComponentAdaptor.java
@@ -61,10 +61,16 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.core.util.Base64;
+import org.glassfish.jersey.oauth1.signature.Base64;
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.client.ClientProperties;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Feature;
public class ConfigComponentAdaptor implements SvcLogicAdaptor {
@@ -925,8 +931,7 @@ public class ConfigComponentAdaptor implements SvcLogicAdaptor {
private HttpResponse sendXmlRequest(String xmlRequest, String url, String user, String password) {
try {
Client client = getClient();
- client.setConnectTimeout(5000);
- WebResource webResource = client.resource(url);
+ WebTarget webResource = client.target(url);
log.info("SENDING...............");
if (log.isTraceEnabled()) {
@@ -943,15 +948,13 @@ public class ConfigComponentAdaptor implements SvcLogicAdaptor {
}
}
String authString = user + ":" + password;
- byte[] authEncBytes = Base64.encode(authString);
- String authStringEnc = new String(authEncBytes);
+ String authStringEnc = Base64.encode(authString.getBytes());
authString = "Basic " + authStringEnc;
- ClientResponse response = getClientResponse(webResource, authString, xmlRequest);
+ Response response = getClientResponse(webResource, authString, xmlRequest);
int code = response.getStatus();
- String message = null;
-
+ String message = response.getStatusInfo().getReasonPhrase();
log.info("RESPONSE...............");
log.info("HTTP response code: " + code);
log.info("HTTP response message: " + message);
@@ -1120,11 +1123,13 @@ public class ConfigComponentAdaptor implements SvcLogicAdaptor {
}
protected Client getClient() {
- return Client.create();
+ ClientConfig clientConfig = new ClientConfig();
+ clientConfig.property(ClientProperties.CONNECT_TIMEOUT, 5000);
+ return ClientBuilder.newClient(clientConfig);
}
- protected ClientResponse getClientResponse(WebResource webResource, String authString, String xmlRequest) {
- return webResource.header("Authorization", authString).accept("UTF-8").type("application/xml").post(
- ClientResponse.class, xmlRequest);
+ protected Response getClientResponse(WebTarget webResource, String authString, String xmlRequest) {
+ return webResource.request("UTF-8").header("Authorization", authString).header("Content-Type", "application/xml").post(
+ Entity.xml(xmlRequest),Response.class);
}
}
diff --git a/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/ConfigComponentAdaptorTest.java b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/ConfigComponentAdaptorTest.java
index c987bb2c9..772a0a14d 100644
--- a/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/ConfigComponentAdaptorTest.java
+++ b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/ConfigComponentAdaptorTest.java
@@ -29,9 +29,12 @@ package org.onap.appc.ccadaptor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.Response;
+
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@@ -333,12 +336,12 @@ public class ConfigComponentAdaptorTest {
@Test
public void testPrepare() {
Client mockClient = Mockito.mock(Client.class);
- WebResource mockWebResource = Mockito.mock(WebResource.class);
- ClientResponse mockClientResponse = Mockito.mock(ClientResponse.class);
+ WebTarget mockWebResource = Mockito.mock(WebTarget.class);
+ Response mockClientResponse = Response.ok().build();
ConfigComponentAdaptor cca = Mockito.spy(new ConfigComponentAdaptor(null));
Mockito.doReturn(mockClientResponse).when(cca).getClientResponse(Mockito.anyObject(),
Mockito.anyString(), Mockito.anyString());
- Mockito.doReturn(mockWebResource).when(mockClient).resource(Mockito.anyString());
+ Mockito.doReturn(mockWebResource).when(mockClient).target(Mockito.anyString());
Mockito.doReturn(mockClient).when(cca).getClient();
Map<String, String> parameters = new HashMap<>();
parameters.put("action", "prepare");
@@ -369,12 +372,12 @@ public class ConfigComponentAdaptorTest {
@Test
public void testPrepareComplexTemplate() {
Client mockClient = Mockito.mock(Client.class);
- WebResource mockWebResource = Mockito.mock(WebResource.class);
- ClientResponse mockClientResponse = Mockito.mock(ClientResponse.class);
+ WebTarget mockWebResource = Mockito.mock(WebTarget.class);
+ Response mockClientResponse = Response.ok().build();
ConfigComponentAdaptor cca = Mockito.spy(new ConfigComponentAdaptor(null));
Mockito.doReturn(mockClientResponse).when(cca).getClientResponse(Mockito.anyObject(),
Mockito.anyString(), Mockito.anyString());
- Mockito.doReturn(mockWebResource).when(mockClient).resource(Mockito.anyString());
+ Mockito.doReturn(mockWebResource).when(mockClient).target(Mockito.anyString());
Mockito.doReturn(mockClient).when(cca).getClient();
String complexTemplateString = cca.readFile("/prepare.xml");
Mockito.when(cca.readFile(Mockito.anyString())).thenReturn(complexTemplateString);
@@ -390,12 +393,13 @@ public class ConfigComponentAdaptorTest {
@Test
public void testAudit() {
Client mockClient = Mockito.mock(Client.class);
- WebResource mockWebResource = Mockito.mock(WebResource.class);
- ClientResponse mockClientResponse = Mockito.mock(ClientResponse.class);
+ WebTarget mockWebResource = Mockito.mock(WebTarget.class);
+ Response mockClientResponse = Response.ok().build();
+
ConfigComponentAdaptor cca = Mockito.spy(new ConfigComponentAdaptor(null));
Mockito.doReturn(mockClientResponse).when(cca).getClientResponse(Mockito.anyObject(),
Mockito.anyString(), Mockito.anyString());
- Mockito.doReturn(mockWebResource).when(mockClient).resource(Mockito.anyString());
+ Mockito.doReturn(mockWebResource).when(mockClient).target(Mockito.anyString());
Mockito.doReturn(mockClient).when(cca).getClient();
Map<String, String> parameters = new HashMap<>();
parameters.put("action", "audit");
@@ -408,7 +412,7 @@ public class ConfigComponentAdaptorTest {
@Test
public void testActivate() {
- ClientResponse mockClientResponse = Mockito.mock(ClientResponse.class);
+ Response mockClientResponse = Response.ok().build();
ConfigComponentAdaptor cca = Mockito.spy(new ConfigComponentAdaptor(null));
Mockito.doReturn(mockClientResponse).when(cca).getClientResponse(Mockito.anyObject(),
Mockito.anyString(), Mockito.anyString());