X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=main%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fapi%2Fmain%2Frest%2Fprovider%2FPolicyProvider.java;h=6b123952f840fc37194aabf3d880e85a120aa411;hb=19286bf7b66750aba7192af363349db2a4d5323d;hp=15e409c6e7049facf6d92dd431cc5ab46e64cb3e;hpb=7575d2d1ecb5ef467032c4418a09283050dfc345;p=policy%2Fapi.git diff --git a/main/src/main/java/org/onap/policy/api/main/rest/provider/PolicyProvider.java b/main/src/main/java/org/onap/policy/api/main/rest/provider/PolicyProvider.java index 15e409c6..6b123952 100644 --- a/main/src/main/java/org/onap/policy/api/main/rest/provider/PolicyProvider.java +++ b/main/src/main/java/org/onap/policy/api/main/rest/provider/PolicyProvider.java @@ -32,12 +32,8 @@ import javax.ws.rs.core.Response; import org.apache.commons.lang3.tuple.Pair; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.pdp.concepts.PdpGroup; -import org.onap.policy.models.pdp.concepts.PdpGroupFilter; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; /** @@ -168,8 +164,6 @@ public class PolicyProvider extends CommonModelProvider { public ToscaServiceTemplate deletePolicy(String policyTypeId, String policyTypeVersion, String policyId, String policyVersion) throws PfModelException { - validateDeleteEligibility(policyTypeId, policyTypeVersion, policyId, policyVersion); - ToscaServiceTemplate serviceTemplate = modelsProvider.deletePolicy(policyId, policyVersion); if (!hasPolicy(serviceTemplate)) { @@ -180,35 +174,6 @@ public class PolicyProvider extends CommonModelProvider { return serviceTemplate; } - /** - * Validates whether specified policy can be deleted based on the rule that deployed policy cannot be deleted. - * - * @param policyTypeId the ID of policy type - * @param policyTypeVersion the version of policy type - * @param policyId the ID of policy - * @param policyVersion the version of policy - * - * @throws PfModelException the PfModel parsing exception - */ - private void validateDeleteEligibility(String policyTypeId, String policyTypeVersion, String policyId, - String policyVersion) throws PfModelException { - - // TODO: Remove this method when delete validation is implemented in the tosca provider - List policyTypes = new ArrayList<>(1); - policyTypes.add(new ToscaPolicyTypeIdentifier(policyTypeId, policyTypeVersion)); - List policies = new ArrayList<>(1); - policies.add(new ToscaPolicyIdentifier(policyId, policyVersion)); - PdpGroupFilter pdpGroupFilter = - PdpGroupFilter.builder().policyTypeList(policyTypes).policyList(policies).build(); - - List pdpGroups = modelsProvider.getFilteredPdpGroups(pdpGroupFilter); - - if (!pdpGroups.isEmpty()) { - throw new PfModelException(Response.Status.CONFLICT, - constructDeletePolicyViolationMessage(policyId, policyVersion, pdpGroups)); - } - } - /** * Retrieves the specified version of the policy. *