From fc07c32a4c01a2541c8061a37c3c6589c720e2b3 Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Mon, 21 Oct 2019 14:21:54 -0400 Subject: Use yaml policies in models-examples Now that yaml is supported, use those policies that are stored in the models-examples that are preloaded into the api. Fixed a minor checkstyle issue. Not sure why it was missed. Issue-ID: POLICY-2066 Change-Id: I2f4384a310bfa818555de5dacb477daf82fac6de Signed-off-by: Pamela Dragosh --- .../pdp/xacml/application/common/std/StdMatchableTranslator.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'applications/common/src') diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java index 7551f7e3..2d831f62 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java @@ -62,6 +62,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType; import org.onap.policy.common.endpoints.parameters.RestServerParameters; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.common.utils.coder.StandardYamlCoder; import org.onap.policy.models.decisions.concepts.DecisionRequest; import org.onap.policy.models.decisions.concepts.DecisionResponse; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; @@ -91,7 +92,7 @@ public class StdMatchableTranslator implements ToscaPolicyTranslator { private static final Logger LOGGER = LoggerFactory.getLogger(StdMatchableTranslator.class); private static final String POLICY_ID = "policy-id"; - private static final StandardCoder standardCoder = new StandardCoder(); + private static final StandardYamlCoder standardYamlCoder = new StandardYamlCoder(); private final Map matchablePolicyTypes = new HashMap<>(); @Setter @@ -549,7 +550,7 @@ public class StdMatchableTranslator implements ToscaPolicyTranslator { } LOGGER.info("Read in local policy type {}", policyTypePath.toAbsolutePath()); try { - ToscaServiceTemplate serviceTemplate = standardCoder.decode(new String(bytes, StandardCharsets.UTF_8), + ToscaServiceTemplate serviceTemplate = standardYamlCoder.decode(new String(bytes, StandardCharsets.UTF_8), ToscaServiceTemplate.class); JpaToscaServiceTemplate jtst = new JpaToscaServiceTemplate(); jtst.fromAuthorative(serviceTemplate); @@ -605,7 +606,7 @@ public class StdMatchableTranslator implements ToscaPolicyTranslator { // Store it locally // try { - standardCoder.encode(policyTypePath.toFile(), policyType); + standardYamlCoder.encode(policyTypePath.toFile(), policyType); } catch (CoderException e) { LOGGER.error("Failed to store {} locally to {}", policyTypeId, policyTypePath, e); } @@ -617,6 +618,6 @@ public class StdMatchableTranslator implements ToscaPolicyTranslator { private Path constructLocalFilePath(ToscaPolicyTypeIdentifier policyTypeId) { return Paths.get(this.pathForData.toAbsolutePath().toString(), policyTypeId.getName() + "-" - + policyTypeId.getVersion() + ".json"); + + policyTypeId.getVersion() + ".yaml"); } } -- cgit 1.2.3-korg