X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fclamp%2Fpolicy%2Fmicroservice%2FMicroServicePolicy.java;h=96b3a09bddd1922e0025ab935f4db47f5c2d5add;hb=2dd4e997c1ccf5dab4dfb7665ce74c0fd1f13e49;hp=c4037ffb659dee70879ca174183237b6a600c6a6;hpb=897a3e004a858ef68d989dad15dde91a69e151a5;p=clamp.git diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java index c4037ffb..96b3a09b 100644 --- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java +++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java @@ -27,6 +27,7 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.gson.JsonObject; import com.google.gson.annotations.Expose; +import java.io.IOException; import java.io.Serializable; import java.util.HashSet; import java.util.Set; @@ -39,8 +40,7 @@ import javax.persistence.Table; import javax.persistence.Transient; import org.hibernate.annotations.TypeDef; import org.hibernate.annotations.TypeDefs; -import org.onap.clamp.clds.tosca.ToscaYamlToJsonConvertor; -import org.onap.clamp.clds.util.JsonUtils; +import org.onap.clamp.clds.tosca.update.UnknownComponentException; import org.onap.clamp.dao.model.jsontype.StringJsonUserType; import org.onap.clamp.loop.Loop; import org.onap.clamp.loop.template.LoopElementModel; @@ -104,9 +104,16 @@ public class MicroServicePolicy extends Policy implements Serializable { * @param shared The flag indicate whether the MicroService is shared */ public MicroServicePolicy(String name, PolicyModel policyModel, Boolean shared, LoopElementModel loopElementModel) { - this(name, policyModel, shared, JsonUtils.GSON_JPA_MODEL - .fromJson(new ToscaYamlToJsonConvertor().parseToscaYaml(policyModel.getPolicyModelTosca(), - policyModel.getPolicyModelType()), JsonObject.class), loopElementModel,null,null); + this.name = name; + this.setPolicyModel(policyModel); + this.shared = shared; + try { + this.setJsonRepresentation(Policy.generateJsonRepresentationFromToscaModel(policyModel.getPolicyModelTosca(),policyModel.getPolicyModelType())); + } catch (UnknownComponentException | NullPointerException | IOException e) { + logger.error("Unable to generate the microservice policy Schema ... ", e); + this.setJsonRepresentation(new JsonObject()); + } + this.setLoopElementModel(loopElementModel); } /** @@ -116,7 +123,7 @@ public class MicroServicePolicy extends Policy implements Serializable { * @param name The name of the MicroService * @param policyModel The policy model type of the MicroService * @param shared The flag indicate whether the MicroService is - * shared + * shared * @param jsonRepresentation The UI representation in json format * @param loopElementModel The loop element model from which this instance should be created * @param pdpGroup The Pdp Group info