From: sebdet Date: Wed, 31 Oct 2018 17:41:40 +0000 (+0100) Subject: Fix Payload in policy X-Git-Tag: 3.0.2^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=clamp.git;a=commitdiff_plain;h=88f0dc9de3216366af961250bef43fa4e232116d Fix Payload in policy Fix payload field in Op Policy, must now be YAML format + fix SO actor value Issue-ID: CLAMP-241 Change-Id: Icce97a0c396fb9ae11c98ace66893066494fcf73 Signed-off-by: sebdet --- diff --git a/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java b/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java index 2ac51ab4..d6deddc6 100644 --- a/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java +++ b/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java @@ -33,6 +33,7 @@ import java.util.List; import java.util.Map; import org.onap.clamp.clds.util.JacksonUtils; +import org.yaml.snakeyaml.Yaml; /** * Parse policyConfigurations from Policy json properties. @@ -105,7 +106,16 @@ public class PolicyItem implements Cloneable { String payload = AbstractModelElement.getValueByName(node, "recipePayload"); if (payload != null && !payload.isEmpty()) { - recipePayload = JacksonUtils.getObjectMapperInstance().readValue(payload, new TypeReference>(){}); + if (payload.trim().startsWith("{") && payload.trim().endsWith("}")) { + // Seems to be a JSON + recipePayload = JacksonUtils.getObjectMapperInstance().readValue(payload, + new TypeReference>() { + }); + } else { + // SHould be a YAML then + Yaml yaml = new Yaml(); + recipePayload = (Map) yaml.load(payload); + } } oapRop = AbstractModelElement.getValueByName(node, "oapRop"); oapLimit = AbstractModelElement.getValueByName(node, "oapLimit"); diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html index 5a460030..331ab5cd 100644 --- a/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html +++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html @@ -253,9 +253,9 @@ label { + Payload (YAML)
- +
diff --git a/src/main/resources/clds/templates/globalProperties.json b/src/main/resources/clds/templates/globalProperties.json index b6f68f64..7cd449f9 100644 --- a/src/main/resources/clds/templates/globalProperties.json +++ b/src/main/resources/clds/templates/globalProperties.json @@ -49,7 +49,7 @@ "timeout": 345, "actor": { "APPC":"APPC", - "MSO": "SO", + "SO": "SO", "VFC": "VFC" }, "vnfRecipe": {