diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2019-10-21 14:21:54 -0400 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2019-10-21 14:22:03 -0400 |
commit | fc07c32a4c01a2541c8061a37c3c6589c720e2b3 (patch) | |
tree | 98c2f46d6cc1d413586df462abd091e828f1de3e /applications/common/src/main/java | |
parent | 3107498c86304ef114e6799ee430013fc26e1750 (diff) |
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 <pdragosh@research.att.com>
Diffstat (limited to 'applications/common/src/main/java')
-rw-r--r-- | applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java | 9 |
1 files changed, 5 insertions, 4 deletions
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<ToscaPolicyTypeIdentifier, ToscaPolicyType> 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"); } } |