Remove event context from Operation post processor 52/111352/1
authorJim Hahn <jrh3@att.com>
Mon, 17 Aug 2020 22:45:58 +0000 (18:45 -0400)
committerJim Hahn <jrh3@att.com>
Mon, 17 Aug 2020 22:48:11 +0000 (18:48 -0400)
Some operations, notably A&AI, post-process data by putting it into the
event context.  However, with the new strategy, the event context may
not be populated.  Modified the code to see if the context exists before
putting the data into it.

Issue-ID: POLICY-2746
Change-Id: Ie3b1bd13b4ac5ee59629daaebc05a62e6ef3c804
Signed-off-by: Jim Hahn <jrh3@att.com>
models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java
models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java

index c8e0870..388959d 100644 (file)
@@ -193,8 +193,10 @@ public class AaiCustomQueryOperation extends HttpOperation<String> {
     protected CompletableFuture<OperationOutcome> postProcessResponse(OperationOutcome outcome, String url,
                     Response rawResponse, String response) {
 
-        logger.info("{}: caching response for {}", getFullName(), params.getRequestId());
-        params.getContext().setProperty(AaiCqResponse.CONTEXT_KEY, new AaiCqResponse(response));
+        if (params.getContext() != null) {
+            logger.info("{}: caching response for {}", getFullName(), params.getRequestId());
+            params.getContext().setProperty(AaiCqResponse.CONTEXT_KEY, new AaiCqResponse(response));
+        }
 
         return super.postProcessResponse(outcome, url, rawResponse, response);
     }
index c18d06c..c91e2a0 100644 (file)
@@ -112,9 +112,10 @@ public class AaiGetOperation extends HttpOperation<StandardCoderObject> {
                     Response rawResponse, StandardCoderObject response) {
         String entity = params.getTargetEntity();
 
-        logger.info("{}: caching response of {} for {}", getFullName(), entity, params.getRequestId());
-
-        params.getContext().setProperty(propertyPrefix + entity, response);
+        if (params.getContext() != null) {
+            logger.info("{}: caching response of {} for {}", getFullName(), entity, params.getRequestId());
+            params.getContext().setProperty(propertyPrefix + entity, response);
+        }
 
         return super.postProcessResponse(outcome, url, rawResponse, response);
     }