Merge "Add template and tosca model entities and repositories"
[clamp.git] / src / main / java / org / onap / clamp / policy / operational / OperationalPolicy.java
index e8bf4a6..d9e8a57 100644 (file)
@@ -174,7 +174,7 @@ public class OperationalPolicy implements Serializable, Policy {
 
     @Override
     public JsonObject getJsonRepresentation() {
-         return jsonRepresentation;
+        return jsonRepresentation;
     }
 
     void setJsonRepresentation(JsonObject jsonRepresentation) {
@@ -282,4 +282,17 @@ public class OperationalPolicy implements Serializable, Policy {
         return result;
     }
 
+    /**
+    * Regenerate the Operational Policy Json Representation.
+    *
+    */
+    public void updateJsonRepresentation() {
+        try {
+            this.jsonRepresentation = OperationalPolicyRepresentationBuilder
+                    .generateOperationalPolicySchema(loop.getModelService());
+        } catch (JsonSyntaxException | IOException | NullPointerException e) {
+            logger.error("Unable to generate the operational policy Schema ... ", e);
+            this.jsonRepresentation = new JsonObject();
+        }
+    }
 }