summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);