summaryrefslogtreecommitdiffstats
path: root/aai-core/src/main/java
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-09-16 16:52:32 +0200
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-09-17 11:36:04 +0200
commit9817670cf1b469b887e16e0a80dc855cf97e859f (patch)
treec0f75d6e63e884c1c47d20e9cde22a83e50062b6 /aai-core/src/main/java
parent089252de752d987756ae339b4a719ad689d02aa9 (diff)
Migrate remnants of jersey 1 to 2 in aai-common
- use org.glassfish.jersey instead of com.sun.jersey Issue-ID: AAI-3990 Change-Id: Ice5731a241be3adf03a64a66fe6f595e5970c7c0 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'aai-core/src/main/java')
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java49
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/HttpsAuthExternalClient.java91
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/RestController.java162
3 files changed, 151 insertions, 151 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java b/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java
index f8f0b65e..b31bfcb8 100644
--- a/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java
+++ b/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java
@@ -20,13 +20,6 @@
package org.onap.aai.util;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.api.json.JSONConfiguration;
-import com.sun.jersey.client.urlconnection.HTTPSProperties;
-
import java.io.FileInputStream;
import java.io.IOException;
import java.security.KeyManagementException;
@@ -41,8 +34,16 @@ import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
-
-import org.onap.aai.aailog.filter.RestControllerClientLoggingInterceptor;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.commons.configuration2.JSONConfiguration;
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.client.ClientProperties;
+import org.onap.aai.aailog.filter.RestControllerClientRequestLoggingInterceptor;
+import org.onap.aai.aailog.filter.RestControllerClientResponseLoggingInterceptor;
import org.onap.aai.exceptions.AAIException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,12 +63,10 @@ public class HttpsAuthClient {
System.out.println("Making Jersey https call...");
Client client = HttpsAuthClient.getClient();
- ClientResponse res = client.resource(url).accept("application/json").header("X-TransactionId", "PROV001")
- .header("X-FromAppId", "AAI").type("application/json").get(ClientResponse.class);
-
- // System.out.println("Jersey result: ");
- // System.out.println(res.getEntity(String.class).toString());
-
+ Response res = client.target(url)
+ .request(MediaType.APPLICATION_JSON)
+ .header("X-TransactionId", "PROV001")
+ .header("X-FromAppId", "AAI").get();
} catch (KeyManagementException e) {
logger.debug("HttpsAuthClient KeyManagement error : {}", e.getMessage());
} catch (Exception e) {
@@ -89,9 +88,9 @@ public class HttpsAuthClient {
String keystorePassword) throws KeyManagementException, UnrecoverableKeyException, CertificateException,
NoSuchAlgorithmException, KeyStoreException, IOException {
- ClientConfig config = new DefaultClientConfig();
- config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
- config.getClasses().add(org.onap.aai.restcore.CustomJacksonJaxBJsonProvider.class);
+ ClientConfig config = new ClientConfig();
+ config.register(org.onap.aai.restcore.CustomJacksonJaxBJsonProvider.class);
+
SSLContext ctx = null;
try {
System.setProperty("javax.net.ssl.trustStore", truststorePath);
@@ -117,20 +116,16 @@ public class HttpsAuthClient {
}
ctx.init(kmf.getKeyManagers(), null, null);
- config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
- new HTTPSProperties(new HostnameVerifier() {
- @Override
- public boolean verify(String s, SSLSession sslSession) {
- return true;
- }
- }, ctx));
+ config.property("jersey.config.client.ssl.context", ctx);
+ config.property("jersey.config.client.hostname.verifier", (HostnameVerifier) (s, sslSession) -> true);
} catch (Exception e) {
System.out.println("Error setting up config: exiting " + e.getMessage());
throw e;
}
- Client client = Client.create(config);
- client.addFilter(new RestControllerClientLoggingInterceptor());
+ Client client = ClientBuilder.newClient(config);
+ client.register(new RestControllerClientRequestLoggingInterceptor());
+ client.register(new RestControllerClientResponseLoggingInterceptor());
// uncomment this line to get more logging for the request/response
// client.addFilter(new LoggingFilter(System.out));
diff --git a/aai-core/src/main/java/org/onap/aai/util/HttpsAuthExternalClient.java b/aai-core/src/main/java/org/onap/aai/util/HttpsAuthExternalClient.java
index 53e2d958..1ace66c7 100644
--- a/aai-core/src/main/java/org/onap/aai/util/HttpsAuthExternalClient.java
+++ b/aai-core/src/main/java/org/onap/aai/util/HttpsAuthExternalClient.java
@@ -20,21 +20,16 @@
package org.onap.aai.util;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.api.json.JSONConfiguration;
-import com.sun.jersey.client.urlconnection.HTTPSProperties;
-
import java.io.FileInputStream;
-import java.security.KeyStore;
+
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.SslConfigurator;
import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
-import javax.net.ssl.TrustManagerFactory;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
public class HttpsAuthExternalClient {
@@ -48,63 +43,45 @@ public class HttpsAuthExternalClient {
*/
public static Client getClient(String keystoreFileName, String keystorePassword) throws Exception {
- ClientConfig config = new DefaultClientConfig();
- config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
- config.getClasses().add(org.onap.aai.restcore.CustomJacksonJaxBJsonProvider.class);
- Client client = null;
- SSLContext ctx = null;
- String truststore_path = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_FILENAME);
- try (FileInputStream tin = new FileInputStream(truststore_path)) {
- String truststore_password = AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_PASSWD);
- String keystore_path = AAIConstants.AAI_HOME_ETC_AUTH + keystoreFileName;
- String keystore_password = keystorePassword;
- // System.setProperty("javax.net.ssl.trustStore", truststore_path);
- // System.setProperty("javax.net.ssl.trustStorePassword", truststore_password);
- HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
- public boolean verify(String string, SSLSession ssls) {
- return true;
- }
- });
+ ClientConfig config = new ClientConfig();
+ config.register(org.onap.aai.restcore.CustomJacksonJaxBJsonProvider.class);
- ctx = SSLContext.getInstance("TLS");
- KeyManagerFactory kmf = null;
+ SSLContext sslContext = null;
+ String truststorePath = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_FILENAME);
+ try (FileInputStream tin = new FileInputStream(truststorePath)) {
+ String truststorePassword = AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_PASSWD);
+ String keystorePath = AAIConstants.AAI_HOME_ETC_AUTH + keystoreFileName;
- /****
- * kmf = KeyManagerFactory.getInstance("SunX509");
- * FileInputStream fin = new FileInputStream(keystore_path);
- * KeyStore ks = KeyStore.getInstance("PKCS12");
- * char[] pwd = keystore_password.toCharArray();
- * ks.load(fin, pwd);
- * kmf.init(ks, pwd);
- ***/
+ SslConfigurator sslConfig = SslConfigurator.newInstance()
+ .trustStoreFile(truststorePath)
+ .trustStorePassword(truststorePassword)
+ .keyStoreFile(keystorePath)
+ .keyStorePassword(keystorePassword);
- String alg = TrustManagerFactory.getDefaultAlgorithm();
- TrustManagerFactory tmf = TrustManagerFactory.getInstance(alg);
+ sslContext = sslConfig.createSSLContext();
- KeyStore ts = KeyStore.getInstance("PKCS12");
- char[] tpwd = truststore_password.toCharArray();
- ts.load(tin, tpwd);
- tmf.init(ts);
+ HostnameVerifier hostnameVerifier = new HostnameVerifier() {
+ @Override
+ public boolean verify(String s, SSLSession sslSession) {
+ return true;
+ }
+ };
- // ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
- // Updating key manager to null, to disable two way SSL
- ctx.init(null, tmf.getTrustManagers(), null);
+ Client client = ClientBuilder.newBuilder()
+ .withConfig(config)
+ .sslContext(sslContext)
+ .hostnameVerifier(hostnameVerifier)
+ .build();
- config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
- new HTTPSProperties(new HostnameVerifier() {
- @Override
- public boolean verify(String s, SSLSession sslSession) {
- return true;
- }
- }, ctx));
+ // Uncomment this line to get more logging for the request/response
+ // client.register(new
+ // LoggingFeature(Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME),
+ // Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 8192));
- client = Client.create(config);
- // uncomment this line to get more logging for the request/response
- // client.addFilter(new LoggingFilter(System.out));
+ return client;
} catch (Exception e) {
throw e;
}
- return client;
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/util/RestController.java b/aai-core/src/main/java/org/onap/aai/util/RestController.java
index 1b050829..b72b5af5 100644
--- a/aai-core/src/main/java/org/onap/aai/util/RestController.java
+++ b/aai-core/src/main/java/org/onap/aai/util/RestController.java
@@ -22,9 +22,8 @@ package org.onap.aai.util;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientHandlerException;
-import com.sun.jersey.api.client.ClientResponse;
+
+import javax.ws.rs.client.Entity;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
@@ -37,6 +36,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
+import javax.ws.rs.ClientErrorException;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
import org.onap.aai.exceptions.AAIException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -69,8 +73,7 @@ public class RestController implements RestControllerInterface {
public static final String REST_APIPATH_CLOUDREGION = "cloud-infrastructure/cloud-regions/cloud-region/";
public static final String REST_APIPATH_TENANT = "cloud-infrastructure/tenants/tenant/";
- public static final String REST_APIPATH_VIRTUAL_DATA_CENTER =
- "cloud-infrastructure/virtual-data-centers/virtual-data-center/";
+ public static final String REST_APIPATH_VIRTUAL_DATA_CENTER = "cloud-infrastructure/virtual-data-centers/virtual-data-center/";
public static final String REST_APIPATH_VIRTUAL_DATA_CENTERS = "cloud-infrastructure/virtual-data-centers/";
public static final String REST_APIPATH_GENERIC_VNF = "network/generic-vnfs/generic-vnf/";
public static final String REST_APIPATH_GENERIC_VNFS = "network/generic-vnfs";
@@ -173,8 +176,8 @@ public class RestController implements RestControllerInterface {
url = AAIConfig.get(AAIConstants.AAI_OLDSERVER_URL) + path;
} else {
if (overrideLocalHost == null) {
- overrideLocalHost =
- AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT);
+ overrideLocalHost = AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE,
+ AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT);
}
if (AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost)) {
url = String.format(AAIConstants.AAI_LOCAL_REST, port,
@@ -185,21 +188,26 @@ public class RestController implements RestControllerInterface {
}
}
LOGGER.debug(url + " for the get REST API");
- ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId)
- .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json")
- .get(ClientResponse.class);
+ Response response = client.target(url)
+ .request(MediaType.APPLICATION_JSON)
+ .header("X-TransactionId", transId)
+ .header("X-FromAppId", sourceID)
+ .header("Real-Time", "true")
+ .get();
- // System.out.println("cres.EntityInputSream()="+cres.getEntityInputStream().toString());
- // System.out.println("cres.tostring()="+cres.toString());
+ // System.out.println("response.EntityInputSream()="+response.getEntityInputStream().toString());
+ // System.out.println("response.tostring()="+response.toString());
- if (cres.getStatus() == 200) {
+ if (response.getStatus() == 200) {
// System.out.println(methodName + ": url=" + url);
- t = (T) cres.getEntity(t.getClass());
+ T entity = response.readEntity((Class<T>) t.getClass());
+ restObject.set(entity);
restObject.set(t);
LOGGER.debug(methodName + "REST api GET was successfull!");
} else {
- // System.out.println(methodName + ": url=" + url + " failed with status=" + cres.getStatus());
- throw new AAIException("AAI_7116", methodName + " with status=" + cres.getStatus() + ", url=" + url);
+ // System.out.println(methodName + ": url=" + url + " failed with status=" +
+ // response.getStatus());
+ throw new AAIException("AAI_7116", methodName + " with status=" + response.getStatus() + ", url=" + url);
}
}
@@ -229,21 +237,25 @@ public class RestController implements RestControllerInterface {
url = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE) + apiVersion + "/" + path;
LOGGER.debug(url + " for the get REST API");
- ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId)
- .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json")
- .get(ClientResponse.class);
+ Response response = client.target(url)
+ .request(MediaType.APPLICATION_JSON)
+ .header("X-TransactionId", transId)
+ .header("X-FromAppId", sourceID)
+ .header("Real-Time", "true")
+ .get();
- // System.out.println("cres.EntityInputSream()="+cres.getEntityInputStream().toString());
- // System.out.println("cres.tostring()="+cres.toString());
+ // System.out.println("response.EntityInputSream()="+response.getEntityInputStream().toString());
+ // System.out.println("response.tostring()="+response.toString());
- if (cres.getStatus() == 200) {
+ if (response.getStatus() == 200) {
// System.out.println(methodName + ": url=" + url);
- t = (T) cres.getEntity(t.getClass());
- restObject.set(t);
+ T entity = response.readEntity((Class<T>) t.getClass());
+ restObject.set(entity);
LOGGER.debug(methodName + "REST api GET was successfull!");
} else {
- // System.out.println(methodName + ": url=" + url + " failed with status=" + cres.getStatus());
- throw new AAIException("AAI_7116", methodName + " with status=" + cres.getStatus() + ", url=" + url);
+ // System.out.println(methodName + ": url=" + url + " failed with status=" +
+ // response.getStatus());
+ throw new AAIException("AAI_7116", methodName + " with status=" + response.getStatus() + ", url=" + url);
}
}
@@ -318,8 +330,8 @@ public class RestController implements RestControllerInterface {
url = AAIConfig.get(AAIConstants.AAI_OLDSERVER_URL) + path;
} else {
if (overrideLocalHost == null) {
- overrideLocalHost =
- AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT);
+ overrideLocalHost = AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE,
+ AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT);
}
if (AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost)) {
url = String.format(AAIConstants.AAI_LOCAL_REST, port,
@@ -330,18 +342,21 @@ public class RestController implements RestControllerInterface {
}
}
- ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId)
- .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json").entity(t)
- .put(ClientResponse.class);
+ Response response = client.target(url)
+ .request(MediaType.APPLICATION_JSON)
+ .header("X-TransactionId", transId)
+ .header("X-FromAppId", sourceID)
+ .header("Real-Time", "true")
+ .put(Entity.entity(t, MediaType.APPLICATION_JSON));
- // System.out.println("cres.tostring()="+cres.toString());
+ // System.out.println("response.tostring()="+response.toString());
- int statuscode = cres.getStatus();
+ int statuscode = response.getStatus();
if (statuscode >= 200 && statuscode <= 299) {
LOGGER.debug(methodName + ": url=" + url + ", request=" + path);
} else {
throw new AAIException("AAI_7116", methodName + " with status=" + statuscode + ", url=" + url + ", msg="
- + cres.getEntity(String.class));
+ + response.readEntity(String.class));
}
}
@@ -365,18 +380,21 @@ public class RestController implements RestControllerInterface {
url = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE) + apiVersion + "/" + path;
- ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId)
- .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json").entity(t)
- .put(ClientResponse.class);
+ Response response = client.target(url)
+ .request(MediaType.APPLICATION_JSON)
+ .header("X-TransactionId", transId)
+ .header("X-FromAppId", sourceID)
+ .header("Real-Time", "true")
+ .put(Entity.entity(t, MediaType.APPLICATION_JSON));
- // System.out.println("cres.tostring()="+cres.toString());
+ // System.out.println("response.tostring()="+response.toString());
- int statuscode = cres.getStatus();
+ int statuscode = response.getStatus();
if (statuscode >= 200 && statuscode <= 299) {
LOGGER.debug(methodName + ": url=" + url + ", request=" + path);
} else {
throw new AAIException("AAI_7116", methodName + " with status=" + statuscode + ", url=" + url + ", msg="
- + cres.getEntity(String.class));
+ + response.getEntity());
}
}
@@ -410,16 +428,20 @@ public class RestController implements RestControllerInterface {
url = String.format(AAIConstants.AAI_LOCAL_REST_OVERRIDE, overrideLocalHost,
AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path;
}
- ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId)
- .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json").entity(request)
- .delete(ClientResponse.class);
-
- if (cres.getStatus() == 404) { // resource not found
- LOGGER.info("Resource does not exist...: " + cres.getStatus() + ":" + cres.getEntity(String.class));
- } else if (cres.getStatus() == 200 || cres.getStatus() == 204) {
+ Response response = client.target(url)
+ .request(MediaType.APPLICATION_JSON)
+ .header("X-TransactionId", transId)
+ .header("X-FromAppId", sourceID)
+ .header("Real-Time", "true")
+ .delete();
+
+ if (response.getStatus() == 404) { // resource not found
+ LOGGER.info(
+ "Resource does not exist...: " + response.getStatus() + ":" + response.readEntity(String.class));
+ } else if (response.getStatus() == 200 || response.getStatus() == 204) {
LOGGER.info("Resource " + url + " deleted");
} else {
- LOGGER.error("Deleting Resource failed: " + cres.getStatus() + ":" + cres.getEntity(String.class));
+ LOGGER.error("Deleting Resource failed: " + response.getStatus() + ":" + response.readEntity(String.class));
throw new AAIException("AAI_7116", "Error during DELETE");
}
}
@@ -451,17 +473,20 @@ public class RestController implements RestControllerInterface {
url = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE) + apiVersion + "/" + path;
- ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId)
- .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json").entity(t)
- .post(ClientResponse.class);
+ Response response = client.target(url)
+ .request(MediaType.APPLICATION_JSON)
+ .header("X-TransactionId", transId)
+ .header("X-FromAppId", sourceID)
+ .header("Real-Time", "true")
+ .post(Entity.entity(t, MediaType.APPLICATION_JSON));
- int statuscode = cres.getStatus();
+ int statuscode = response.getStatus();
if (statuscode >= 200 && statuscode <= 299) {
LOGGER.debug(methodName + "REST api POST was successful!");
- return cres.getEntity(String.class);
+ return response.readEntity(String.class);
} else {
throw new AAIException("AAI_7116", methodName + " with status=" + statuscode + ", url=" + url + ", msg="
- + cres.getEntity(String.class));
+ + response.readEntity(String.class));
}
} catch (AAIException e) {
@@ -503,17 +528,17 @@ public class RestController implements RestControllerInterface {
*/
/*
* DoesResourceExist
- *
+ *
* To check whether a resource exist or get a copy of the existing version of the resource
- *
+ *
* Resourcepath: should contain the qualified resource path (including encoded unique key identifier value),
* resourceClassName: is the canonical name of the resource class name,
* fromAppId:
* transId:
- *
+ *
* Will return null (if the resource doesn’t exist) (or)
* Will return the specified resource from the Graph.
- *
+ *
* Example:
* LogicalLink llink = new LogicalLink();
* String resourceClassName = llink.getClass().getCanonicalName();
@@ -536,7 +561,7 @@ public class RestController implements RestControllerInterface {
} catch (AAIException e) {
- } catch (ClientHandlerException che) {
+ } catch (ClientErrorException che) {
} catch (Exception e) {
@@ -560,13 +585,13 @@ public class RestController implements RestControllerInterface {
transId += ":" + UUID.randomUUID().toString();
int numRetries = 5;
- ClientResponse cres = null;
+ Response response = null;
int statusCode = -1;
try {
if (overrideLocalHost == null) {
- overrideLocalHost =
- AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT);
+ overrideLocalHost = AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE,
+ AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT);
}
if (AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost)) {
url = String.format(AAIConstants.AAI_LOCAL_REST, AAIConstants.AAI_RESOURCES_PORT,
@@ -578,11 +603,14 @@ public class RestController implements RestControllerInterface {
do {
- cres = client.resource(url).accept("application/json").header("X-TransactionId", transId)
- .header("X-FromAppId", sourceID).header("X-HTTP-Method-Override", "PATCH")
- .type("application/merge-patch+json").entity(t).post(ClientResponse.class);
+ response = client.target(url)
+ .request(MediaType.APPLICATION_JSON)
+ .header("X-TransactionId", transId)
+ .header("X-FromAppId", sourceID)
+ .header("X-HTTP-Method-Override", "PATCH")
+ .post(Entity.entity(t, "application/merge-patch+json"));
- statusCode = cres.getStatus();
+ statusCode = response.getStatus();
if (statusCode >= 200 && statusCode <= 299) {
LOGGER.debug(methodName + "REST api PATCH was successful!");
@@ -598,7 +626,7 @@ public class RestController implements RestControllerInterface {
LOGGER.debug(methodName + "Unable to make the patch request to url " + url + " even after trying = "
+ numRetries + " times.");
throw new AAIException("AAI_7116", methodName + " with status=" + statusCode + ", url=" + url + ", msg="
- + cres.getEntity(String.class));
+ + response.readEntity(String.class));
} catch (AAIException e) {
throw new AAIException("AAI_7116", methodName + " with url=" + url + ", Exception: " + e.toString());