package org.onap.clamp.policy.microservice;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
+import javax.persistence.Transient;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
*/
private static final long serialVersionUID = 6271238288583332616L;
+ @Transient
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(MicroServicePolicy.class);
+
@Expose
@Id
@Column(nullable = false, name = "name", unique = true)
* The constructor that create the json representation from the policyTosca
* using the ToscaYamlToJsonConvertor.
*
- * @param name
- * The name of the MicroService
- * @param type
- * The model type of the MicroService
- * @param policyTosca
- * The policy Tosca of the MicroService
- * @param shared
- * The flag indicate whether the MicroService is shared
- * @param usedByLoops
- * The list of loops that uses this MicroService
+ * @param name The name of the MicroService
+ * @param modelType The model type of the MicroService
+ * @param policyTosca The policy Tosca of the MicroService
+ * @param shared The flag indicate whether the MicroService is shared
+ * @param usedByLoops The list of loops that uses this MicroService
*/
public MicroServicePolicy(String name, String modelType, String policyTosca, Boolean shared,
- Set<Loop> usedByLoops) {
+ Set<Loop> usedByLoops) {
this.name = name;
this.modelType = modelType;
this.policyTosca = policyTosca;
this.shared = shared;
this.jsonRepresentation = JsonUtils.GSON_JPA_MODEL
- .fromJson(new ToscaYamlToJsonConvertor(null).parseToscaYaml(policyTosca), JsonObject.class);
+ .fromJson(new ToscaYamlToJsonConvertor().parseToscaYaml(policyTosca, modelType), JsonObject.class);
this.usedByLoops = usedByLoops;
}
* The constructor that does not make use of ToscaYamlToJsonConvertor but take
* the jsonRepresentation instead.
*
- * @param name
- * The name of the MicroService
- * @param type
- * The model type of the MicroService
- * @param policyTosca
- * The policy Tosca of the MicroService
- * @param shared
- * The flag indicate whether the MicroService is shared
- * @param jsonRepresentation
- * The UI representation in json format
- * @param usedByLoops
- * The list of loops that uses this MicroService
+ * @param name The name of the MicroService
+ * @param modelType The model type of the MicroService
+ * @param policyTosca The policy Tosca of the MicroService
+ * @param shared The flag indicate whether the MicroService is
+ * shared
+ * @param jsonRepresentation The UI representation in json format
+ * @param usedByLoops The list of loops that uses this MicroService
*/
public MicroServicePolicy(String name, String modelType, String policyTosca, Boolean shared,
- JsonObject jsonRepresentation, Set<Loop> usedByLoops) {
+ JsonObject jsonRepresentation, Set<Loop> usedByLoops) {
this.name = name;
this.modelType = modelType;
this.policyTosca = policyTosca;
private String getMicroServicePropertyNameFromTosca(JsonObject object) {
return object.getAsJsonObject("policy_types").getAsJsonObject(this.modelType).getAsJsonObject("properties")
- .keySet().toArray(new String[1])[0];
+ .keySet().toArray(new String[1])[0];
}
@Override
JsonObject policyProperties = new JsonObject();
policyDetails.add("properties", policyProperties);
policyProperties.add(this.getMicroServicePropertyNameFromTosca(toscaJson), this.getProperties());
- return new GsonBuilder().setPrettyPrinting().create().toJson(policyPayloadResult);
+ String policyPayload = new GsonBuilder().setPrettyPrinting().create().toJson(policyPayloadResult);
+ logger.info("Micro service policy payload: " + policyPayload);
+ return policyPayload;
}
}