summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xaai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java57
1 files changed, 52 insertions, 5 deletions
diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java
index aa134cb4a..6eb537469 100755
--- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java
+++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIClientRESTExecutor.java
@@ -49,6 +49,8 @@ import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.ws.rs.HttpMethod;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.Response;
import org.apache.commons.codec.binary.Base64;
import org.onap.ccsdk.sli.adaptors.aai.AAIService.TransactionIdTracker;
@@ -248,13 +250,22 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface {
}
// Check for errors
- String responseMessage = con.getResponseMessage();
int responseCode = con.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
inputStream = con.getInputStream();
} else {
inputStream = con.getErrorStream();
}
+ String responseMessage = null;
+ try {
+ responseMessage = con.getResponseMessage();
+ } catch(Exception exc) {
+ Status status = Response.Status.fromStatusCode(responseCode) ;
+ if(status != null && status.getReasonPhrase() != null)
+ responseMessage = status.getReasonPhrase();
+ else
+ responseMessage = "NOT PROVIDED";
+ }
// Process the response
LOG.debug("HttpURLConnection result:" + responseCode + " : " + responseMessage);
@@ -382,13 +393,22 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface {
osw.flush();
// Check for errors
- String responseMessage = con.getResponseMessage();
int responseCode = con.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
inputStream = con.getInputStream();
} else {
inputStream = con.getErrorStream();
}
+ String responseMessage = null;
+ try {
+ responseMessage = con.getResponseMessage();
+ } catch(Exception exc) {
+ Status status = Response.Status.fromStatusCode(responseCode) ;
+ if(status != null && status.getReasonPhrase() != null)
+ responseMessage = status.getReasonPhrase();
+ else
+ responseMessage = "NOT PROVIDED";
+ }
LOG.debug("HttpURLConnection result:" + responseCode + " : " + responseMessage);
logMetricResponse(responseCode, responseMessage);
@@ -456,13 +476,22 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface {
conn.setDoOutput(true);
// Check for errors
- String responseMessage = conn.getResponseMessage();
int responseCode = conn.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
inputStream = conn.getInputStream();
} else {
inputStream = conn.getErrorStream();
}
+ String responseMessage = null;
+ try {
+ responseMessage = conn.getResponseMessage();
+ } catch(Exception exc) {
+ Status status = Response.Status.fromStatusCode(responseCode) ;
+ if(status != null && status.getReasonPhrase() != null)
+ responseMessage = status.getReasonPhrase();
+ else
+ responseMessage = "NOT PROVIDED";
+ }
// Process the response
LOG.debug("HttpURLConnection result:" + responseCode + " : " + responseMessage);
@@ -530,13 +559,22 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface {
logMetricRequest("GET "+requestUrl.getPath(), "", requestUrl.getPath());
// Check for errors
- String responseMessage = con.getResponseMessage();
int responseCode = con.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
inputStream = con.getInputStream();
} else {
inputStream = con.getErrorStream();
}
+ String responseMessage = null;
+ try {
+ responseMessage = con.getResponseMessage();
+ } catch(Exception exc) {
+ Status status = Response.Status.fromStatusCode(responseCode) ;
+ if(status != null && status.getReasonPhrase() != null)
+ responseMessage = status.getReasonPhrase();
+ else
+ responseMessage = "NOT PROVIDED";
+ }
logMetricResponse(responseCode, responseMessage);
ObjectMapper mapper = AAIService.getObjectMapper();
@@ -596,13 +634,22 @@ public class AAIClientRESTExecutor implements AAIExecutorInterface {
osw.flush();
// Check for errors
- String responseMessage = con.getResponseMessage();
int responseCode = con.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
inputStream = con.getInputStream();
} else {
inputStream = con.getErrorStream();
}
+ String responseMessage = null;
+ try {
+ responseMessage = con.getResponseMessage();
+ } catch(Exception exc) {
+ Status status = Response.Status.fromStatusCode(responseCode) ;
+ if(status != null && status.getReasonPhrase() != null)
+ responseMessage = status.getReasonPhrase();
+ else
+ responseMessage = "NOT PROVIDED";
+ }
LOG.info("HttpURLConnection result: " + responseCode + " : " + responseMessage);
logMetricResponse(responseCode, responseMessage);