summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorPrudence Au <prudence.au@amdocs.com>2018-09-10 14:07:42 -0400
committerPrudence Au <prudence.au@amdocs.com>2018-09-10 14:16:24 -0400
commit37901c75f865ce54a1a25686cd0287db22958e7e (patch)
tree4700b14972f61757e48f0545f2c62d542966ee6e /src/main
parent3b0cf71771ea4f4a08c19f24ee5e4b7614cb33d2 (diff)
Enhance error message
when any one of the context builders returns an error Change-Id: I15770a93ea4d36c9e9385e521cef48a1dfba67d7 Signed-off-by: Prudence Au <prudence.au@amdocs.com> Issue-ID: LOG-439
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/pomba/contextaggregator/rest/RestRequest.java28
-rw-r--r--src/main/java/org/onap/pomba/contextaggregator/service/ContextAggregatorProcessor.java2
2 files changed, 21 insertions, 9 deletions
diff --git a/src/main/java/org/onap/pomba/contextaggregator/rest/RestRequest.java b/src/main/java/org/onap/pomba/contextaggregator/rest/RestRequest.java
index 6ec63f7..0b2d3cb 100644
--- a/src/main/java/org/onap/pomba/contextaggregator/rest/RestRequest.java
+++ b/src/main/java/org/onap/pomba/contextaggregator/rest/RestRequest.java
@@ -59,16 +59,28 @@ public class RestRequest {
public static String getModelData(ContextBuilder builder, POAEvent event) {
RestClient restClient = createRestClient(builder);
- OperationResult result = restClient.get(generateUri(builder, event),
- generateHeaders(event.getxTransactionId(), builder), MediaType.APPLICATION_JSON_TYPE);
+ OperationResult result = null;
- if (result.wasSuccessful()) {
- log.debug("Retrieved model data for '" + builder.getContextName() + "': " + result.getResult());
- return result.getResult();
+ try {
+ result = restClient.get(generateUri(builder, event),
+ generateHeaders(event.getxTransactionId(), builder), MediaType.APPLICATION_JSON_TYPE);
+ } catch(Exception e) {
+ log.error("Error getting result from " + builder.getContextName() + " context builder. Reason - " + e.getMessage());
+ return null;
+ }
+
+ if(result != null) {
+ if(result.wasSuccessful()) {
+ log.debug("Retrieved model data for '" + builder.getContextName() + "': " + result.getResult());
+ return result.getResult();
+ } else {
+ // failed! return null
+ log.error(ContextAggregatorError.FAILED_TO_GET_MODEL_DATA.getMessage(builder.getContextName(),
+ result.getFailureCause()));
+ log.debug("Failed to retrieve model data for '" + builder.getContextName());
+ return null;
+ }
} else {
- // failed! return null
- log.error(ContextAggregatorError.FAILED_TO_GET_MODEL_DATA.getMessage(builder.getContextName(),
- result.getFailureCause()));
log.debug("Failed to retrieve model data for '" + builder.getContextName());
return null;
}
diff --git a/src/main/java/org/onap/pomba/contextaggregator/service/ContextAggregatorProcessor.java b/src/main/java/org/onap/pomba/contextaggregator/service/ContextAggregatorProcessor.java
index 5924b15..e2758ab 100644
--- a/src/main/java/org/onap/pomba/contextaggregator/service/ContextAggregatorProcessor.java
+++ b/src/main/java/org/onap/pomba/contextaggregator/service/ContextAggregatorProcessor.java
@@ -94,7 +94,7 @@ public class ContextAggregatorProcessor implements Callable<Void> {
String modelData = RestRequest.getModelData(builder, event);
if (modelData == null) {
// If one of the Context builder return error, Aggregator will not publish the event
- log.info("Error returned from one of the Context builder, no event will be published.");
+ log.info("Error returned from one of the Context builders, no event will be published.");
return;
} else {
retrievedModels.put(builder.getContextName(), modelData);