+
+ private void deleteToscaPolicies(ToscaEntityKey policyTypeKey) throws Exception {
+
+ String getPoliciesPath =
+ "policytypes/" + policyTypeKey.getName() + "/versions/" + policyTypeKey.getVersion() + "/policies";
+
+ Response rawPolicyResponse = readResource(getPoliciesPath, APP_JSON);
+ if (Response.Status.OK.getStatusCode() == rawPolicyResponse.getStatus()) {
+ ToscaServiceTemplate policyResponse = rawPolicyResponse.readEntity(ToscaServiceTemplate.class);
+
+ for (ToscaEntityKey policyKey : policyResponse.getToscaTopologyTemplate().getPoliciesAsMap().keySet()) {
+ String deletePolicyPath =
+ "policytypes/" + policyTypeKey.getName() + "/versions/" + policyTypeKey.getVersion()
+ + "/policies/" + policyKey.getName() + "/versions/" + policyKey.getVersion();
+ deleteResource(deletePolicyPath, APP_JSON);
+ }
+ }
+ }
+
+ private void deleteLegacyPolicies(String[] legacyPolicyNames, String legacyPolicyType) throws Exception {
+
+ for (String policyName : legacyPolicyNames) {
+ String policyPath =
+ "policytypes/" + legacyPolicyType + "/versions/1.0.0/policies/" + policyName + "/versions/1";
+ if (Response.Status.OK.getStatusCode() == readResource(policyPath, APP_JSON).getStatus()) {
+ deleteResource(policyPath, APP_JSON);
+ }
+ }
+ }