aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authora.sreekumar <ajith.sreekumar@est.tech>2019-06-14 13:07:14 +0000
committera.sreekumar <ajith.sreekumar@est.tech>2019-06-14 13:07:14 +0000
commit70611fc67629b4ab0c7db4104d6a26a0645dac0a (patch)
tree433ee0e448a4b89fe14aff304ab8921abbddf32a
parent3f53167d98e00198c15c950d9b7ba4ea8b4a4c05 (diff)
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 <ajith.sreekumar@est.tech>
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java14
1 files 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");