diff options
author | Adam Wudzinski <adam.wudzinski@nokia.com> | 2019-03-07 16:46:28 +0100 |
---|---|---|
committer | awudzins <adam.wudzinski@nokia.com> | 2019-03-07 17:28:03 +0100 |
commit | 045b2715a73df3c9888f31eac43e93d5a576be4a (patch) | |
tree | 6ea92b15371c5d3d3d69c0246fb44983cab62180 /controlloop/common/actors/actor.appclcm/src/main | |
parent | 9849908bc526807c8c11f6609dbc5cef6ab2a872 (diff) |
Fix policy doesn't send payload to APPC
Fix policy doesn't send payload to APPC using AppcLcm
Change-Id: Ic3cb59203a412297f40f77d744cc86e4dddff7a2
Issue-ID: POLICY-1522
Signed-off-by: awudzins <adam.wudzinski@nokia.com>
Diffstat (limited to 'controlloop/common/actors/actor.appclcm/src/main')
-rw-r--r-- | controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java b/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java index 049a77a3a..5c82a9500 100644 --- a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java +++ b/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java @@ -236,8 +236,9 @@ public class AppcLcmActorServiceProvider implements Actor { * APPC will populate the payload based on A&AI look up of the vnd-id provided in the action * identifiers. */ - if (RECIPE_RESTART.equalsIgnoreCase(policy.getRecipe()) || RECIPE_REBUILD.equalsIgnoreCase(policy.getRecipe()) - || RECIPE_MIGRATE.equalsIgnoreCase(policy.getRecipe())) { + if (recipeSupportsPayload(policy.getRecipe()) && payloadSupplied(policy.getPayload())) { + appcRequest.setPayload(parsePayload(policy.getPayload())); + } else { appcRequest.setPayload(null); } @@ -250,6 +251,22 @@ public class AppcLcmActorServiceProvider implements Actor { return dmaapRequest; } + private static boolean payloadSupplied(Map<String, String> payload) { + return payload != null && !payload.isEmpty(); + } + + private static boolean recipeSupportsPayload(String recipe) { + return !RECIPE_RESTART.equalsIgnoreCase(recipe) && !RECIPE_REBUILD.equalsIgnoreCase(recipe) + && !RECIPE_MIGRATE.equalsIgnoreCase(recipe); + } + + private static String parsePayload(Map<String, String> payload) { + StringBuilder payloadString = new StringBuilder("{"); + payload + .forEach((key, value) -> payloadString.append("\"").append(key).append("\": ").append(value).append(",")); + return payloadString.substring(0, payloadString.length() - 1) + "}"; + } + /** * Parses the operation attempt using the subRequestId of APPC response. * |