diff options
author | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2018-11-06 09:36:17 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-11-06 09:36:17 +0000 |
commit | b34d9a76dec996e285a70baef39d501de9fd7bed (patch) | |
tree | 571cd23202e481ec46ec3eadf40ee4b4de36bf7c /vid-app-common/src/main | |
parent | 1ff7d1ac31d35819cea29671f5146cefcbe2cdf1 (diff) | |
parent | 0ff46010362eed22971dc462ba6b112c2aea78ec (diff) |
Merge "Fix reading entity"
Diffstat (limited to 'vid-app-common/src/main')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java index c1964c16..06e0f017 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java @@ -413,9 +413,7 @@ public class AaiClient implements AaiClientInterface { } else { logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "getSubscribers() resp=" + resp.getStatusInfo().toString()); if (resp.getStatus() != HttpStatus.SC_OK) { - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "Invalid response from AAI"); - String rawData = resp.readEntity(String.class); - subscriberDataResponse = new AaiResponse<>(null, rawData, resp.getStatus()); + subscriberDataResponse = processFailureResponse(resp,responseBody); } else { subscriberDataResponse = processOkResponse(resp, classType, responseBody, omType, propagateExceptions); } @@ -423,6 +421,17 @@ public class AaiClient implements AaiClientInterface { return subscriberDataResponse; } + private AaiResponse processFailureResponse(Response resp, String responseBody) { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "Invalid response from AAI"); + String rawData; + if (responseBody != null) { + rawData = responseBody; + } else { + rawData = resp.readEntity(String.class); + } + return new AaiResponse<>(null, rawData, resp.getStatus()); + } + private AaiResponse processOkResponse(Response resp, Class classType, String responseBody, VidObjectMapperType omType, boolean propagateExceptions) { AaiResponse subscriberDataResponse; String finalResponse = null; |