diff options
Diffstat (limited to 'applications/guard/src')
5 files changed, 13 insertions, 15 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 2c7ad587..b20c8cce 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 @@ -42,6 +42,7 @@ import java.util.stream.Stream; 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.common.utils.resources.ResourceUtils; 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; @@ -157,15 +158,16 @@ public class CoordinationGuardTranslator implements ToscaPolicyTranslator { /* * Replace function placeholders with appropriate values */ - try (Stream<String> stream = Files.lines(Paths.get(xacmlProtoFilename))) { - return stream.map(s -> s.replace("UNIQUE_ID", uniqueId)) - .map(s -> s.replace("CONTROL_LOOP_ONE", cLOne)) - .map(s -> s.replace("CONTROL_LOOP_TWO", cLTwo)) - .collect(Collectors.joining(XacmlPolicyUtils.LINE_SEPARATOR)); - } catch (IOException e) { - throw new ToscaPolicyConversionException( - "Error while generating XACML policy for coordination directive", e); + String policyXml = ResourceUtils.getResourceAsString(xacmlProtoFilename); + if (policyXml == null) { + throw new ToscaPolicyConversionException("Error while generating XACML policy for coordination directive"); } + policyXml = policyXml.replace("UNIQUE_ID", uniqueId); + policyXml = policyXml.replace("CONTROL_LOOP_ONE", cLOne); + policyXml = policyXml.replace("CONTROL_LOOP_TWO", cLTwo); + + return policyXml; + } } diff --git a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/CoordinationTest.java b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/CoordinationTest.java index 5b62f364..31aced6d 100644 --- a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/CoordinationTest.java +++ b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/CoordinationTest.java @@ -251,10 +251,6 @@ public class CoordinationTest { // insertOperationEvent(requestCl1Node1, OPEN); // - // Try cl2 on node2, cl1 only open on node1: should get permit - // - requestAndCheckDecision(requestCl2Node2, PERMIT); - // // Open cl2 on node2 // insertOperationEvent(requestCl2Node2, OPEN); diff --git a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/SonCoordinationTest.java b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/SonCoordinationTest.java index e840bb7b..fc4c5e68 100644 --- a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/SonCoordinationTest.java +++ b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/SonCoordinationTest.java @@ -275,7 +275,7 @@ public class SonCoordinationTest { // Dbao newEntry = new Dbao(); newEntry.setActor(properties.get("actor").toString()); - newEntry.setOperation(properties.get("recipe").toString()); + newEntry.setOperation(properties.get("operation").toString()); newEntry.setClosedLoopName(properties.get("clname").toString()); newEntry.setOutcome(outcome); newEntry.setStarttime(Date.from(Instant.now().minusMillis(20000))); diff --git a/applications/guard/src/test/resources/requests/coordination.cl.vPci.node.1.json b/applications/guard/src/test/resources/requests/coordination.cl.vPci.node.1.json index 22e710bd..d6a48c7c 100644 --- a/applications/guard/src/test/resources/requests/coordination.cl.vPci.node.1.json +++ b/applications/guard/src/test/resources/requests/coordination.cl.vPci.node.1.json @@ -7,7 +7,7 @@ "resource": { "guard": { "actor": "SDNR", - "recipe": "ModifyConfig", + "operation": "ModifyConfig", "clname": "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459", "target": "node1" } diff --git a/applications/guard/src/test/resources/requests/coordination.cl.vSonh.node.1.json b/applications/guard/src/test/resources/requests/coordination.cl.vSonh.node.1.json index 5846da37..10f2bc1e 100644 --- a/applications/guard/src/test/resources/requests/coordination.cl.vSonh.node.1.json +++ b/applications/guard/src/test/resources/requests/coordination.cl.vSonh.node.1.json @@ -7,7 +7,7 @@ "resource": { "guard": { "actor": "SDNR", - "recipe": "ModifyConfigANR", + "operation": "ModifyConfigANR", "clname": "ControlLoop-vSONH-7d4baf04-8875-4d1f-946d-06b874048b61", "target": "node1" } |