X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Fcomponents%2FDecisionPolicy.java;h=c8c540c344a556132c88feab2bc670b523a51008;hb=95524c8ef8be0d41de8bb2b918f320e464ebb897;hp=22d2da311215422ba7bfd025981ee83fa57e6772;hpb=7727ac7ce0b25e07dcdc1a29962356c6bf9c94d9;p=policy%2Fengine.git diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java index 22d2da311..c8c540c34 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-PAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,9 +53,8 @@ import org.onap.policy.controlloop.policy.guard.GuardPolicy; import org.onap.policy.controlloop.policy.guard.MatchParameters; import org.onap.policy.controlloop.policy.guard.builder.ControlLoopGuardBuilder; import org.onap.policy.pap.xacml.rest.XACMLPapServlet; -import org.onap.policy.pap.xacml.rest.util.JPAUtils; import org.onap.policy.rest.adapter.PolicyRestAdapter; -import org.onap.policy.rest.jpa.Datatype; +import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.DecisionSettings; import org.onap.policy.rest.jpa.FunctionDefinition; import org.onap.policy.utils.PolicyUtils; @@ -108,15 +107,15 @@ public class DecisionPolicy extends Policy { List dynamicFieldTwoRuleAlgorithms = new LinkedList<>(); List dataTypeList = new LinkedList<>(); - protected Map dropDownMap = new HashMap<>(); + private CommonClassDao commonClassDao; - public DecisionPolicy() { super(); } - public DecisionPolicy(PolicyRestAdapter policyAdapter){ + public DecisionPolicy(PolicyRestAdapter policyAdapter, CommonClassDao commonClassDao){ this.policyAdapter = policyAdapter; + this.commonClassDao = commonClassDao; } @Override @@ -168,7 +167,9 @@ public class DecisionPolicy extends Policy { if(policyAdapter.getRuleProvider().equals(GUARD_YAML) || policyAdapter.getRuleProvider().equals(GUARD_BL_YAML)){ Map yamlParams = new HashMap<>(); - yamlParams.put(DESCRIPTION, (policyAdapter.getPolicyDescription()!=null)? policyAdapter.getPolicyDescription(): "YAML Guard Policy"); + String blackListEntryType = policyAdapter.getBlackListEntryType() !=null ? policyAdapter.getBlackListEntryType(): "Use Manual Entry"; + String description = policyAdapter.getPolicyDescription() != null? policyAdapter.getPolicyDescription(): "YAML Guard Policy"; + yamlParams.put(DESCRIPTION, description + "@blEntry@" + blackListEntryType + "@blEntry@"); String fileName = policyAdapter.getNewFileName(); String name = fileName.substring(fileName.lastIndexOf('\\') + 1, fileName.length()); if ((name == null) || ("".equals(name))) { @@ -296,6 +297,16 @@ public class DecisionPolicy extends Policy { blackList.add(blackListString); } } + if(yamlParams.containsKey("appendBlackList")){ + String appendBlackListString = yamlParams.get("appendBlackList"); + List appendBlackList = null; + if(appendBlackListString!=null && !appendBlackListString.trim().isEmpty()){ + appendBlackList = Arrays.asList(appendBlackListString.split(",")); + for(int i=0; i createDropDownMap(){ - JPAUtils jpaUtils = null; - try { - jpaUtils = JPAUtils.getJPAUtilsInstance(XACMLPapServlet.getEmf()); - } catch (Exception e) { - LOGGER.error("Exception Occured"+e); - } - Map dropDownOptions = new HashMap<>(); - if(jpaUtils!=null){ - Map> functionMap = jpaUtils.getFunctionDatatypeMap(); - for (Map.Entry> map: functionMap.entrySet()) { - for (FunctionDefinition functionDef : map.getValue()) { - dropDownOptions.put(functionDef.getShortname(),functionDef.getXacmlid()); - } - } - } - return dropDownOptions; - } private String getDataType(String key) { @@ -800,4 +792,12 @@ public class DecisionPolicy extends Policy { return policyAdapter.getData(); } + public String getFunctionDefinitionId(String key){ + FunctionDefinition object = (FunctionDefinition) commonClassDao.getDataById(FunctionDefinition.class, "shortname", key); + if(object != null){ + return object.getXacmlid(); + } + return null; + } + }