summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorburdziak <olaf.burdziakowski@nokia.com>2018-04-16 15:22:39 +0200
committerburdziak <olaf.burdziakowski@nokia.com>2018-04-16 15:22:39 +0200
commite69a4ce4d1bcf567b2998061752c50da140d48e9 (patch)
treeed4c67b46c8bea45dd2287f6d6d41780adf1d350
parent07fee440187553d183bf36ef2b523aa38ab14f3e (diff)
Fixes in RestClient
Change-Id: I6409dbac1cb8640e406830f36c0ad3ce152638ed Issue-ID: AAI-1032 Signed-off-by: burdziak <olaf.burdziakowski@nokia.com>
-rw-r--r--src/main/java/org/onap/aai/restclient/client/RestClient.java75
1 files changed, 45 insertions, 30 deletions
diff --git a/src/main/java/org/onap/aai/restclient/client/RestClient.java b/src/main/java/org/onap/aai/restclient/client/RestClient.java
index 64b52fb..cfeeb27 100644
--- a/src/main/java/org/onap/aai/restclient/client/RestClient.java
+++ b/src/main/java/org/onap/aai/restclient/client/RestClient.java
@@ -623,43 +623,58 @@ public class RestClient {
private void debugRequest(String url, String payload, Map<String, List<String>> headers,
MediaType responseType) {
- if (logger.isDebugEnabled()) {
- StringBuilder debugRequest = new StringBuilder("REQUEST:\n");
- debugRequest.append("URL: ").append(url).append("\n");
- debugRequest.append("Payload: ").append(payload).append("\n");
- debugRequest.append("Response Type: ").append(responseType).append("\n");
- if (headers != null) {
- debugRequest.append("Headers: ");
- for (Entry<String, List<String>> header : headers.entrySet()) {
- debugRequest.append("\n\t").append(header.getKey()).append(":");
- for (String headerEntry : header.getValue()) {
- debugRequest.append("\"").append(headerEntry).append("\" ");
- }
- }
- }
+ if (!logger.isDebugEnabled()) {
+ return;
+ }
+
+ StringBuilder debugRequest = new StringBuilder("REQUEST:\n");
+ debugRequest.append("URL: ").append(url).append("\n");
+ debugRequest.append("Payload: ").append(payload).append("\n");
+ debugRequest.append("Response Type: ").append(responseType).append("\n");
+
+ if (headers == null) {
logger.debug(debugRequest.toString());
+ return;
+ }
+
+ debugRequest.append("Headers: ");
+ for (Entry<String, List<String>> header : headers.entrySet()) {
+ debugRequest.append("\n\t").append(header.getKey()).append(":");
+ for (String headerEntry : header.getValue()) {
+ debugRequest.append("\"").append(headerEntry).append("\" ");
+ }
}
+
+ logger.debug(debugRequest.toString());
+
}
private void debugResponse(OperationResult operationResult,
MultivaluedMap<String, String> headers) {
- if (logger.isDebugEnabled()) {
- StringBuilder debugResponse = new StringBuilder("RESPONSE:\n");
- debugResponse.append("Result: ").append(operationResult.getResultCode()).append("\n");
- debugResponse.append("Failure Cause: ").append(operationResult.getFailureCause())
- .append("\n");
- debugResponse.append("Payload: ").append(operationResult.getResult()).append("\n");
- if (headers != null) {
- debugResponse.append("Headers: ");
- for (Entry<String, List<String>> header : headers.entrySet()) {
- debugResponse.append("\n\t").append(header.getKey()).append(":");
- for (String headerEntry : header.getValue()) {
- debugResponse.append("\"").append(headerEntry).append("\" ");
- }
- }
- }
+
+ if (!logger.isDebugEnabled()) {
+ return;
+ }
+
+ StringBuilder debugResponse = new StringBuilder("RESPONSE:\n");
+ debugResponse.append("Result: ").append(operationResult.getResultCode()).append("\n");
+ debugResponse.append("Failure Cause: ").append(operationResult.getFailureCause()).append("\n");
+ debugResponse.append("Payload: ").append(operationResult.getResult()).append("\n");
+
+ if (headers == null) {
logger.debug(debugResponse.toString());
+ return;
+ }
+
+ debugResponse.append("Headers: ");
+ for (Entry<String, List<String>> header : headers.entrySet()) {
+ debugResponse.append("\n\t").append(header.getKey()).append(":");
+ for (String headerEntry : header.getValue()) {
+ debugResponse.append("\"").append(headerEntry).append("\" ");
+ }
}
+
+ logger.debug(debugResponse.toString());
}
/**
@@ -708,7 +723,7 @@ public class RestClient {
try {
initClient.setClient(clientBuilder.getClient());
- } catch ( Throwable error ) {
+ } catch ( Exception error) {
initClient.setCaughtException(error);
}