From 5ae90a9bf72d2d6dbb163c3dbea5474b657be7e7 Mon Sep 17 00:00:00 2001 From: Tarun Tej Velaga Date: Tue, 15 Aug 2017 13:20:02 +0000 Subject: Policy-yaml changes Changes to Policy-yaml and sdc projects based on changes from policy/engine. Issue-Id: POLICY-88 Change-Id: Ic1a58f00029b9a66db6980fc7732a2ac57390229 Signed-off-by: Tarun Tej Velaga --- .../onap/policy/guard/PolicyGuardYamlToXacml.java | 56 +++++++++++----------- 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'controlloop/common/guard') diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardYamlToXacml.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardYamlToXacml.java index baf43b3b0..4d952b58e 100644 --- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardYamlToXacml.java +++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardYamlToXacml.java @@ -24,13 +24,11 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; - import org.onap.policy.controlloop.policy.guard.ControlLoopGuard; @@ -41,12 +39,12 @@ public class PolicyGuardYamlToXacml { public static void fromYamlToXacml(String yamlFile, String xacmlTemplate, String xacmlPolicyOutput){ ControlLoopGuard yamlGuardObject = Util.loadYamlGuard(yamlFile); - System.out.println("clname: " + yamlGuardObject.guards.getFirst().match_parameters.controlLoopName); - System.out.println("actor: " + yamlGuardObject.guards.getFirst().match_parameters.actor); - System.out.println("recipe: " + yamlGuardObject.guards.getFirst().match_parameters.recipe); - System.out.println("num: " + yamlGuardObject.guards.getFirst().limit_constraints.getFirst().freq_limit_per_target); - System.out.println("duration: " + yamlGuardObject.guards.getFirst().limit_constraints.getFirst().time_window); - System.out.println("time_in_range: " + yamlGuardObject.guards.getFirst().limit_constraints.getFirst().active_time_range); + System.out.println("clname: " + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getControlLoopName()); + System.out.println("actor: " + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getActor()); + System.out.println("recipe: " + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getRecipe()); + System.out.println("num: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getFreq_limit_per_target()); + System.out.println("duration: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_window()); + System.out.println("time_in_range: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getActive_time_range()); Path xacmlTemplatePath = Paths.get(xacmlTemplate); String xacmlTemplateContent; @@ -55,14 +53,14 @@ public class PolicyGuardYamlToXacml { xacmlTemplateContent = new String(Files.readAllBytes(xacmlTemplatePath)); String xacmlPolicyContent = generateXacmlGuard(xacmlTemplateContent, - yamlGuardObject.guards.getFirst().match_parameters.controlLoopName, - yamlGuardObject.guards.getFirst().match_parameters.actor, - yamlGuardObject.guards.getFirst().match_parameters.recipe, - yamlGuardObject.guards.getFirst().match_parameters.targets, - yamlGuardObject.guards.getFirst().limit_constraints.getFirst().freq_limit_per_target, - yamlGuardObject.guards.getFirst().limit_constraints.getFirst().time_window, - yamlGuardObject.guards.getFirst().limit_constraints.getFirst().active_time_range.get("start"), - yamlGuardObject.guards.getFirst().limit_constraints.getFirst().active_time_range.get("end") + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getControlLoopName(), + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getActor(), + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getRecipe(), + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getTargets(), + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getFreq_limit_per_target(), + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_window(), + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getActive_time_range().get("start"), + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getActive_time_range().get("end") ); @@ -81,7 +79,7 @@ public class PolicyGuardYamlToXacml { String clname, String actor, String recipe, - LinkedList targets, + List targets, Integer limit, Map timeWindow, String guardActiveStart, @@ -159,7 +157,7 @@ public class PolicyGuardYamlToXacml { } - public static boolean isNullOrEmptyList(LinkedList list){ + public static boolean isNullOrEmptyList(List list){ if(list == null){ return true; @@ -175,11 +173,11 @@ public class PolicyGuardYamlToXacml { public static void fromYamlToXacmlBlacklist(String yamlFile, String xacmlTemplate, String xacmlPolicyOutput){ ControlLoopGuard yamlGuardObject = Util.loadYamlGuard(yamlFile); - System.out.println("actor: " + yamlGuardObject.guards.getFirst().match_parameters.actor); - System.out.println("recipe: " + yamlGuardObject.guards.getFirst().match_parameters.recipe); - System.out.println("freq_limit_per_target: " + yamlGuardObject.guards.getFirst().limit_constraints.getFirst().freq_limit_per_target); - System.out.println("time_window: " + yamlGuardObject.guards.getFirst().limit_constraints.getFirst().time_window); - System.out.println("active_time_range: " + yamlGuardObject.guards.getFirst().limit_constraints.getFirst().active_time_range); + System.out.println("actor: " + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getActor()); + System.out.println("recipe: " + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getRecipe()); + System.out.println("freq_limit_per_target: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getFreq_limit_per_target()); + System.out.println("time_window: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_window()); + System.out.println("active_time_range: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getActive_time_range()); Path xacmlTemplatePath = Paths.get(xacmlTemplate); String xacmlTemplateContent; @@ -188,12 +186,12 @@ public class PolicyGuardYamlToXacml { xacmlTemplateContent = new String(Files.readAllBytes(xacmlTemplatePath)); String xacmlPolicyContent = generateXacmlGuardBlacklist(xacmlTemplateContent, - yamlGuardObject.guards.getFirst().match_parameters.controlLoopName, - yamlGuardObject.guards.getFirst().match_parameters.actor, - yamlGuardObject.guards.getFirst().match_parameters.recipe, - yamlGuardObject.guards.getFirst().limit_constraints.getFirst().blacklist, - yamlGuardObject.guards.getFirst().limit_constraints.getFirst().active_time_range.get("start"), - yamlGuardObject.guards.getFirst().limit_constraints.getFirst().active_time_range.get("end") + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getControlLoopName(), + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getActor(), + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getRecipe(), + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getBlacklist(), + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getActive_time_range().get("start"), + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getActive_time_range().get("end") ); -- cgit 1.2.3-korg