- // Create the structure of the TOSCA service template to contain the policy type
- JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate();
- serviceTemplate.setTopologyTemplate(new JpaToscaTopologyTemplate());
- serviceTemplate.getTopologyTemplate().setPolicies(new JpaToscaPolicies());
- serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().put(foundPolicy.getKey(), foundPolicy);
-
- return serviceTemplate;
- }
-
- /**
- * Delete a legacy policy.
- *
- * @param dao the DAO to use for the deletion
- * @param policyId the policy ID
- * @param policyVersion the policy version
- * @return a service template containing the policy that has been deleted
- */
- private JpaToscaServiceTemplate deleteLegacyPolicy(final PfDao dao, final String policyId,
- final String policyVersion) {
-
- final JpaToscaPolicy deletePolicy =
- dao.get(JpaToscaPolicy.class, new PfConceptKey(policyId, policyVersion + LEGACY_MINOR_PATCH_SUFFIX));
-
- if (deletePolicy == null) {
- String errorMessage = NO_POLICY_FOUND_FOR_POLICY + policyId + ':' + policyVersion;
- LOGGER.warn(errorMessage);
- throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage);
- }
-
- // Delete the policy
- dao.delete(deletePolicy);
-
- // Create the structure of the TOSCA service template to contain the policy type
- JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate();
- serviceTemplate.setTopologyTemplate(new JpaToscaTopologyTemplate());
- serviceTemplate.getTopologyTemplate().setPolicies(new JpaToscaPolicies());
- serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().put(deletePolicy.getKey(), deletePolicy);
-
- return serviceTemplate;