From 2c789f6a45f50da129d05ff3ea20acd9f45774d0 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 17 Aug 2020 18:45:58 -0400 Subject: Remove event context from Operation post processor 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 --- .../onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java | 6 ++++-- .../org/onap/policy/controlloop/actor/aai/AaiGetOperation.java | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java index c8e087036..388959ddf 100644 --- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java +++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java @@ -193,8 +193,10 @@ public class AaiCustomQueryOperation extends HttpOperation { protected CompletableFuture 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); } diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java index c18d06c95..c91e2a0d6 100644 --- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java +++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java @@ -112,9 +112,10 @@ public class AaiGetOperation extends HttpOperation { 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); } -- cgit 1.2.3-korg