- HashMap<String, String> yamlSpecs = new HashMap<String, String>();
- yamlSpecs.put("PolicyName", yamlParams.get("PolicyName"));
- yamlSpecs.put("description", yamlParams.get("description"));
- yamlSpecs.put("ECOMPName", yamlParams.get("ECOMPName"));
- yamlSpecs.put("actor", ((LinkedList<GuardPolicy>)yamlGuardObject.getGuards()).getFirst().getActor());
- yamlSpecs.put("recipe", ((LinkedList<GuardPolicy>)yamlGuardObject.getGuards()).getFirst().getRecipe());
- yamlSpecs.put("limit", ((LinkedList<Constraint>)((LinkedList<GuardPolicy>)yamlGuardObject.getGuards()).getFirst().getLimit_constraints()).getFirst().getNum().toString());
- yamlSpecs.put("timeWindow", ((LinkedList<Constraint>)((LinkedList<GuardPolicy>)yamlGuardObject.getGuards()).getFirst().getLimit_constraints()).getFirst().getDuration());
- yamlSpecs.put("guardActiveStart", ((LinkedList<Constraint>)((LinkedList<GuardPolicy>)yamlGuardObject.getGuards()).getFirst().getLimit_constraints()).getFirst().getTime_in_range().get("arg2"));
- yamlSpecs.put("guardActiveEnd", ((LinkedList<Constraint>)((LinkedList<GuardPolicy>)yamlGuardObject.getGuards()).getFirst().getLimit_constraints()).getFirst().getTime_in_range().get("arg3"));
- String xacmlPolicyContent = SafePolicyBuilder.generateXacmlGuard(xacmlTemplateContent,yamlSpecs);
- // Convert the Policy into Stream input to Policy Adapter.
+ HashMap<String, String> yamlSpecs = new HashMap<>();
+ yamlSpecs.put(POLICY_NAME, yamlParams.get(POLICY_NAME));
+ yamlSpecs.put(DESCRIPTION, yamlParams.get(DESCRIPTION));
+ yamlSpecs.put(ECOMPNAME, yamlParams.get(ECOMPNAME));
+ yamlSpecs.put("actor", yamlGuardObject.getGuards().getFirst().getActor());
+ yamlSpecs.put("recipe", yamlGuardObject.getGuards().getFirst().getRecipe());
+ if(yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getNum()!=null){
+ yamlSpecs.put("limit", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getNum().toString());
+ }
+ if(yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getDuration()!=null){
+ yamlSpecs.put("timeWindow", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getDuration());
+ }
+ yamlSpecs.put("guardActiveStart", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_in_range().get("arg2"));
+ yamlSpecs.put("guardActiveEnd", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_in_range().get("arg3"));
+ String xacmlPolicyContent = SafePolicyBuilder.generateXacmlGuard(xacmlTemplateContent,yamlSpecs, yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getBlacklist());
+ // Convert the Policy into Stream input to Policy Adapter.