From 6b4f9b69bc4acec28da8ef50b8f234d0182f0d78 Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Mon, 16 Mar 2020 11:09:36 -0400 Subject: Missing support for PolicySetType Adds support for PolicySetType specifically for Native policies. When/If the other applications change to support they can easily do so. Adding some more code coverage for Native application and translator. Issue-ID: POLICY-2433 Change-Id: I463ca9f04928d759624a2176598b463057d386bd Signed-off-by: Pamela Dragosh --- .../xacml/pdp/application/guard/CoordinationGuardTranslator.java | 7 ++----- .../onap/policy/xacml/pdp/application/guard/GuardTranslator.java | 5 ++++- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'applications/guard/src/main/java/org') 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 f1006c6d..2c7ad587 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 @@ -39,9 +39,6 @@ import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; 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; @@ -63,7 +60,7 @@ public class CoordinationGuardTranslator implements ToscaPolicyTranslator { } @Override - public PolicyType convertPolicy(ToscaPolicy toscaPolicy) throws ToscaPolicyConversionException { + public Object convertPolicy(ToscaPolicy toscaPolicy) throws ToscaPolicyConversionException { LOGGER.debug("Using CoordinationGuardTranslator.convertPolicy"); // // Policy name should be at the root @@ -88,7 +85,7 @@ public class CoordinationGuardTranslator implements ToscaPolicyTranslator { // Scan the string and convert to PoilcyType // try (InputStream is = new ByteArrayInputStream(xacmlStr.getBytes(StandardCharsets.UTF_8))) { - return (PolicyType) XACMLPolicyScanner.readPolicy(is); + return XACMLPolicyScanner.readPolicy(is); } catch (IOException e) { throw new ToscaPolicyConversionException("Failed to read policy", e); } diff --git a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java index fd46a988..1e4333ea 100644 --- a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java +++ b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java @@ -96,7 +96,8 @@ public class GuardTranslator implements ToscaPolicyTranslator { /** * Convert the policy. */ - public PolicyType convertPolicy(ToscaPolicy toscaPolicy) throws ToscaPolicyConversionException { + @Override + public Object convertPolicy(ToscaPolicy toscaPolicy) throws ToscaPolicyConversionException { // // Policy name should be at the root // @@ -140,6 +141,7 @@ public class GuardTranslator implements ToscaPolicyTranslator { /** * Convert Request. */ + @Override public Request convertRequest(DecisionRequest request) throws ToscaPolicyConversionException { LOGGER.info("Converting Request {}", request); try { @@ -152,6 +154,7 @@ public class GuardTranslator implements ToscaPolicyTranslator { /** * Convert response. */ + @Override public DecisionResponse convertResponse(Response xacmlResponse) { LOGGER.info("Converting Response {}", xacmlResponse); DecisionResponse decisionResponse = new DecisionResponse(); -- cgit 1.2.3-korg