summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main
diff options
context:
space:
mode:
authorWojciech Sliwka <wojciech.sliwka@nokia.com>2018-11-06 09:53:54 +0100
committerWojciech Sliwka <wojciech.sliwka@nokia.com>2018-11-06 09:55:57 +0100
commit0ff46010362eed22971dc462ba6b112c2aea78ec (patch)
tree0a4bf522a848ff9e684076995dd78c995395d8b9 /vid-app-common/src/main
parent5a7cdb624c0abe6f2b7e80bcbbaa740c4ee35e39 (diff)
Fix reading entity
ensure that response is read only once Change-Id: Id456263f58f8d69ad1a484f26352db62b74a4f08 Issue-ID: VID-227 Signed-off-by: Wojciech Sliwka <wojciech.sliwka@nokia.com>
Diffstat (limited to 'vid-app-common/src/main')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java15
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 c1964c161..06e0f0174 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;