Fix to accomodate recent changes in policy-models-tosca 48/87148/1
authora.sreekumar <ajith.sreekumar@est.tech>
Tue, 7 May 2019 13:13:12 +0000 (13:13 +0000)
committera.sreekumar <ajith.sreekumar@est.tech>
Tue, 7 May 2019 13:13:12 +0000 (13:13 +0000)
Recent change in JpaToscaPolicy require corresponding changes in PDP-A as the code
was expecting a simple string earlier. This review contains the changes to fix
this

Change-Id: I3bbae264800b2c8bb8bdd61eae7b171028a85bc3
Issue-ID: POLICY-1739
Signed-off-by: a.sreekumar <ajith.sreekumar@est.tech>
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java
services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java

index 85d666c..1c94130 100644 (file)
@@ -53,11 +53,11 @@ public class ApexEngineHandler {
      * @throws ApexStarterException if the apex engine instantiation failed using the properties passed
      */
 
-    public ApexEngineHandler(final String properties) throws ApexStarterException {
+    public ApexEngineHandler(final Object properties) throws ApexStarterException {
         final StandardCoder standardCoder = new StandardCoder();
         JsonObject body;
         try {
-            body = standardCoder.decode(new StringReader(properties), JsonObject.class);
+            body = standardCoder.decode(new StringReader(properties.toString()), JsonObject.class);
         } catch (final CoderException e) {
             throw new ApexStarterException(e);
         }
index 9c53fb1..495bcec 100644 (file)
@@ -97,7 +97,7 @@ public class PdpStateChangeMessageHandler {
                 try {
                     // assumed that the apex policies list contains only one entry.
                     final ApexEngineHandler apexEngineHandler =
-                            new ApexEngineHandler((String) policies.get(0).getProperties().get("content"));
+                            new ApexEngineHandler(policies.get(0).getProperties().get("content"));
                     Registry.registerOrReplace(ApexStarterConstants.REG_APEX_ENGINE_HANDLER, apexEngineHandler);
                     pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(),
                             PdpResponseStatus.SUCCESS, "Apex engine started. State changed to active.");
index 478d1c7..64d4657 100644 (file)
@@ -120,8 +120,8 @@ public class PdpUpdateMessageHandler {
                 if (null != apexEngineHandler && apexEngineHandler.isApexEngineRunning()) {
                     apexEngineHandler.shutdown();
                 }
-                apexEngineHandler = new ApexEngineHandler(
-                        (String) pdpUpdateMsg.getPolicies().get(0).getProperties().get("content"));
+                apexEngineHandler =
+                        new ApexEngineHandler(pdpUpdateMsg.getPolicies().get(0).getProperties().get("content"));
                 Registry.registerOrReplace(ApexStarterConstants.REG_APEX_ENGINE_HANDLER, apexEngineHandler);
                 pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(),
                         PdpResponseStatus.SUCCESS, "Apex engine started and policies are running.");