From 70611fc67629b4ab0c7db4104d6a26a0645dac0a Mon Sep 17 00:00:00 2001 From: "a.sreekumar" Date: Fri, 14 Jun 2019 13:07:14 +0000 Subject: Policy JSON formatting issues in APEX In APEX, the policy model currently needs to be escaped, otherwise causes json formatting issues. This is fixed. Change-Id: If9d5043acef0b175494be797fc7acd9c6c4f4494 Issue-ID: POLICY-1839 Signed-off-by: a.sreekumar --- .../apex/services/onappf/handler/ApexEngineHandler.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java index 1c9413020..8cb3ae13e 100644 --- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java +++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java @@ -52,19 +52,19 @@ public class ApexEngineHandler { * @param properties the properties which contains the policies and configurations received from pap * @throws ApexStarterException if the apex engine instantiation failed using the properties passed */ - public ApexEngineHandler(final Object properties) throws ApexStarterException { final StandardCoder standardCoder = new StandardCoder(); - JsonObject body; + String policyModel; + String apexConfig; try { - body = standardCoder.decode(new StringReader(properties.toString()), JsonObject.class); + JsonObject body = standardCoder.decode(standardCoder.encode(properties), JsonObject.class); + final JsonObject engineServiceParameters = body.get("engineServiceParameters").getAsJsonObject(); + policyModel = standardCoder.encode(engineServiceParameters.get("policy_type_impl")); + engineServiceParameters.remove("policy_type_impl"); + apexConfig = standardCoder.encode(body); } catch (final CoderException e) { throw new ApexStarterException(e); } - final JsonObject engineServiceParameters = body.get("engineServiceParameters").getAsJsonObject(); - final String policyModel = engineServiceParameters.get("policy_type_impl").toString(); - engineServiceParameters.remove("policy_type_impl"); - final String apexConfig = body.toString(); final String modelFilePath = createFile(policyModel, "modelFile"); -- cgit 1.2.3-korg