aboutsummaryrefslogtreecommitdiffstats
path: root/applications/guard
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-09-12 16:05:18 -0400
committerJim Hahn <jrh3@att.com>2019-09-12 16:20:30 -0400
commit1df1c6aeb21b50ab5c4f7c4a7e6da7bc8abed62e (patch)
treed17b9209b4f26ba6f3a04600b514e90bbdd4cbb8 /applications/guard
parent88a247ef93ac0f0e2ff00345e0408a2af232b3c9 (diff)
Add yaml support to xacml-pdp rest server
Also modified code to use StandardYamlCoder. Change-Id: I0596c8b054339ac68ef8c4250cd25b9ff88d47e4 Issue-ID: POLICY-2085 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'applications/guard')
-rw-r--r--applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java11
1 files changed, 5 insertions, 6 deletions
diff --git a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java
index a93e2811..92e0301d 100644
--- a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java
+++ b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java
@@ -43,6 +43,8 @@ import java.util.stream.Stream;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
import org.apache.commons.io.IOUtils;
+import org.onap.policy.common.utils.coder.CoderException;
+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;
@@ -50,8 +52,6 @@ import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionExcepti
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
public class CoordinationGuardTranslator implements ToscaPolicyTranslator {
@@ -117,11 +117,10 @@ public class CoordinationGuardTranslator implements ToscaPolicyTranslator {
//
// Read the yaml into our Java Object
//
- Yaml yaml = new Yaml(new Constructor(CoordinationDirective.class));
- Object obj = yaml.load(contents);
+ CoordinationDirective obj = new StandardYamlCoder().decode(contents, CoordinationDirective.class);
LOGGER.debug(contents);
- return (CoordinationDirective) obj;
- } catch (IOException e) {
+ return obj;
+ } catch (IOException | CoderException e) {
LOGGER.error("Error while loading YAML coordination directive", e);
}
return null;