aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--applications/common/pom.xml5
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/TestUtils.java10
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java1
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java15
-rw-r--r--applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java11
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpRestController.java5
-rw-r--r--pom.xml16
7 files changed, 28 insertions, 35 deletions
diff --git a/applications/common/pom.xml b/applications/common/pom.xml
index 8613a94d..dea04007 100644
--- a/applications/common/pom.xml
+++ b/applications/common/pom.xml
@@ -54,6 +54,11 @@
</dependency>
<dependency>
<groupId>org.onap.policy.common</groupId>
+ <artifactId>utils</artifactId>
+ <version>${policy.common.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.common</groupId>
<artifactId>utils-test</artifactId>
<version>${policy.common.version}</version>
</dependency>
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/TestUtils.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/TestUtils.java
index f720fec4..3aa23eee 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/TestUtils.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/TestUtils.java
@@ -27,18 +27,17 @@ import java.util.List;
import java.util.Map;
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.common.utils.resources.ResourceUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.yaml.snakeyaml.Yaml;
public class TestUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(TestUtils.class);
- private static final StandardCoder standardCoder = new StandardCoder();
+ private static final StandardYamlCoder yamlCoder = new StandardYamlCoder();
private TestUtils() {
super();
@@ -62,13 +61,10 @@ public class TestUtils {
// Decode it
//
String policyYaml = ResourceUtils.getResourceAsString(resourceFile);
- Yaml yaml = new Yaml();
- Object yamlObject = yaml.load(policyYaml);
- String yamlAsJsonString = standardCoder.encode(yamlObject);
//
// Serialize it into a class
//
- ToscaServiceTemplate serviceTemplate = standardCoder.decode(yamlAsJsonString, ToscaServiceTemplate.class);
+ ToscaServiceTemplate serviceTemplate = yamlCoder.decode(policyYaml, ToscaServiceTemplate.class);
//
// Make sure all the fields are setup properly
//
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 1c69c7a6..0575ef1b 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
@@ -32,7 +32,6 @@ import com.att.research.xacml.api.Response;
import com.att.research.xacml.api.Result;
import com.att.research.xacml.api.XACML3;
import com.att.research.xacml.std.IdentifierImpl;
-import com.att.research.xacml.std.annotations.RequestParser;
import com.att.research.xacml.util.XACMLPolicyWriter;
import com.google.gson.Gson;
import java.io.ByteArrayOutputStream;
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java
index 3e690882..3323040f 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java
@@ -49,7 +49,7 @@ import org.onap.policy.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.common.gson.GsonMessageBodyHandler;
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.common.utils.network.NetworkUtil;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
@@ -59,13 +59,12 @@ import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.yaml.snakeyaml.Yaml;
public class StdMatchableTranslatorTest {
private static final Logger logger = LoggerFactory.getLogger(StdMatchableTranslatorTest.class);
private static final String CLIENT_NAME = "policy-api";
- private static final StandardCoder standardCoder = new StandardCoder();
+ private static final StandardYamlCoder yamlCoder = new StandardYamlCoder();
private static int port;
private static RestServerParameters clientParams;
private static ToscaPolicyType testPolicyType;
@@ -116,13 +115,10 @@ public class StdMatchableTranslatorTest {
// Load our test policy type
//
String policyYaml = ResourceUtils.getResourceAsString("matchable/onap.policies.Test-1.0.0.yaml");
- Yaml yaml = new Yaml();
- Object yamlObject = yaml.load(policyYaml);
- String yamlAsJsonString = standardCoder.encode(yamlObject);
//
// Serialize it into a class
//
- ToscaServiceTemplate serviceTemplate = standardCoder.decode(yamlAsJsonString, ToscaServiceTemplate.class);
+ ToscaServiceTemplate serviceTemplate = yamlCoder.decode(policyYaml, ToscaServiceTemplate.class);
//
// Make sure all the fields are setup properly
//
@@ -160,13 +156,10 @@ public class StdMatchableTranslatorTest {
//
String policyYaml = ResourceUtils.getResourceAsString(
"src/test/resources/matchable/test.policies.input.tosca.yaml");
- Yaml yaml = new Yaml();
- Object yamlObject = yaml.load(policyYaml);
- String yamlAsJsonString = standardCoder.encode(yamlObject);
//
// Serialize it into a class
//
- ToscaServiceTemplate serviceTemplate = standardCoder.decode(yamlAsJsonString, ToscaServiceTemplate.class);
+ ToscaServiceTemplate serviceTemplate = yamlCoder.decode(policyYaml, ToscaServiceTemplate.class);
//
// Make sure all the fields are setup properly
//
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;
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpRestController.java b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpRestController.java
index 265dd686..3de830e3 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpRestController.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpRestController.java
@@ -62,14 +62,15 @@ import org.onap.policy.pdpx.main.rest.provider.StatisticsProvider;
*/
@Path("/policy/pdpx/v1")
@Api
-@Produces(MediaType.APPLICATION_JSON)
-@Consumes(MediaType.APPLICATION_JSON)
+@Produces({MediaType.APPLICATION_JSON, XacmlPdpRestController.APPLICATION_YAML})
+@Consumes({MediaType.APPLICATION_JSON, XacmlPdpRestController.APPLICATION_YAML})
@SwaggerDefinition(info = @Info(description = "Policy Xacml PDP Service", version = "1.0.0", title = "Policy Xacml PDP",
extensions = {@Extension(properties = {@ExtensionProperty(name = "planned-retirement-date", value = "tbd"),
@ExtensionProperty(name = "component", value = "Policy Framework")})}),
schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")}))
public class XacmlPdpRestController {
+ public static final String APPLICATION_YAML = "application/yaml";
@GET
@Path("/healthcheck")
diff --git a/pom.xml b/pom.xml
index 457c76ec..c52799a7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,9 +7,9 @@
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,8 +44,8 @@
<sonar.jacoco.reportPath>${project.basedir}/../target/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPath>
<sonar.jacoco.itReportPath>${project.basedir}/../target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
-
- <policy.common.version>1.5.2</policy.common.version>
+
+ <policy.common.version>1.6.0-SNAPSHOT</policy.common.version>
<policy.models.version>2.1.3</policy.models.version>
</properties>
@@ -55,7 +55,7 @@
<module>packages</module>
<module>testsuites</module>
</modules>
-
+
<dependencies>
<dependency>
<groupId>junit</groupId>
@@ -118,7 +118,7 @@
<version>${policy.models.version}</version>
</dependency>
</dependencies>
-
+
<distributionManagement>
<site>
<id>ecomp-site</id>
@@ -164,7 +164,7 @@
</goals>
<phase>process-sources</phase>
<configuration>
- <!-- Use Google Java Style Guide: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
+ <!-- Use Google Java Style Guide: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
with minor changes -->
<configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
<!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
@@ -206,7 +206,7 @@
</excludes>
</configuration>
<executions>
- <!-- Prepares the property pointing to the JaCoCo runtime agent which is passed as VM argument when
+ <!-- Prepares the property pointing to the JaCoCo runtime agent which is passed as VM argument when
Maven the Surefire plugin is executed. -->
<execution>
<id>pre-unit-test</id>