import org.apache.commons.lang3.tuple.Pair;\r
import org.onap.policy.models.base.PfConceptKey;\r
import org.onap.policy.models.base.PfModelException;\r
-import org.onap.policy.models.pdp.concepts.PdpGroup;\r
-import org.onap.policy.models.pdp.concepts.PdpGroupFilter;\r
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;\r
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;\r
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;\r
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;\r
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;\r
\r
/**\r
public ToscaServiceTemplate deletePolicy(String policyTypeId, String policyTypeVersion, String policyId,\r
String policyVersion) throws PfModelException {\r
\r
- validateDeleteEligibility(policyTypeId, policyTypeVersion, policyId, policyVersion);\r
-\r
ToscaServiceTemplate serviceTemplate = modelsProvider.deletePolicy(policyId, policyVersion);\r
\r
if (!hasPolicy(serviceTemplate)) {\r
return serviceTemplate;\r
}\r
\r
- /**\r
- * Validates whether specified policy can be deleted based on the rule that deployed policy cannot be deleted.\r
- *\r
- * @param policyTypeId the ID of policy type\r
- * @param policyTypeVersion the version of policy type\r
- * @param policyId the ID of policy\r
- * @param policyVersion the version of policy\r
- *\r
- * @throws PfModelException the PfModel parsing exception\r
- */\r
- private void validateDeleteEligibility(String policyTypeId, String policyTypeVersion, String policyId,\r
- String policyVersion) throws PfModelException {\r
-\r
- // TODO: Remove this method when delete validation is implemented in the tosca provider\r
- List<ToscaPolicyTypeIdentifier> policyTypes = new ArrayList<>(1);\r
- policyTypes.add(new ToscaPolicyTypeIdentifier(policyTypeId, policyTypeVersion));\r
- List<ToscaPolicyIdentifier> policies = new ArrayList<>(1);\r
- policies.add(new ToscaPolicyIdentifier(policyId, policyVersion));\r
- PdpGroupFilter pdpGroupFilter =\r
- PdpGroupFilter.builder().policyTypeList(policyTypes).policyList(policies).build();\r
-\r
- List<PdpGroup> pdpGroups = modelsProvider.getFilteredPdpGroups(pdpGroupFilter);\r
-\r
- if (!pdpGroups.isEmpty()) {\r
- throw new PfModelException(Response.Status.CONFLICT,\r
- constructDeletePolicyViolationMessage(policyId, policyVersion, pdpGroups));\r
- }\r
- }\r
-\r
/**\r
* Retrieves the specified version of the policy.\r
*\r