import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.annotations.Expose;
-
import java.io.UnsupportedEncodingException;
import java.util.Map;
import javax.persistence.Column;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
import org.json.JSONObject;
+import org.onap.clamp.clds.tosca.update.ToscaConverterWithDictionarySupport;
import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
import org.onap.clamp.loop.common.AuditEntity;
import org.onap.clamp.loop.template.LoopElementModel;
return new Gson().fromJson(jsonObject.toString(), JsonObject.class);
}
- private String getModelPropertyNameFromTosca(JsonObject object, String policyModelType) {
- return object.getAsJsonObject("policy_types").getAsJsonObject(policyModelType)
- .getAsJsonObject(
- "properties")
- .keySet().toArray(new String[1])[0];
- }
-
/**
* This method create the policy payload that must be sent to PEF.
*
JsonObject policyDetails = new JsonObject();
thisPolicy.add(this.getName(), policyDetails);
policyDetails.addProperty("type", this.getPolicyModel().getPolicyModelType());
+ policyDetails.addProperty("type_version", this.getPolicyModel().getVersion());
policyDetails.addProperty("version", this.getPolicyModel().getVersion());
JsonObject policyMetadata = new JsonObject();
policyDetails.add("metadata", policyMetadata);
policyMetadata.addProperty("policy-id", this.getName());
- JsonObject policyProperties = new JsonObject();
- policyDetails.add("properties", policyProperties);
- policyProperties
- .add(this.getModelPropertyNameFromTosca(toscaJson, this.getPolicyModel().getPolicyModelType()),
- this.getConfigurationsJson());
+ policyDetails.add("properties", this.getConfigurationsJson());
+
String policyPayload = new GsonBuilder().setPrettyPrinting().create().toJson(policyPayloadResult);
logger.info("Policy payload: " + policyPayload);
return policyPayload;
this.jsonRepresentation = jsonRepresentation;
}
+ /**
+ * Regenerate the Policy Json Representation.
+ *
+ * @param toscaConverter The tosca converter required to regenerate the json schema
+ */
+ public abstract void updateJsonRepresentation(ToscaConverterWithDictionarySupport toscaConverter);
+
/**
* policyModel getter.
*
.append(blueprintFilename.replaceAll(".yaml", ""));
return buffer.toString().replace('.', '_').replaceAll(" ", "");
}
-
}