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%2FCreateBrmsParamPolicy.java;h=b27dd22cad770e758211ebec30edd711ec077fd1;hb=b6dee4c18a7384e765a36a8dbbaef301da232847;hp=047342ad023251b814fd1e64e91b0507e0d6db99;hpb=073cc188efe9abb4c010cf674e34e2cf46ef1c52;p=policy%2Fengine.git diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java index 047342ad0..b27dd22ca 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java @@ -38,6 +38,8 @@ import java.util.UUID; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.script.SimpleBindings; + import org.apache.commons.io.FilenameUtils; import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.eelf.PolicyLogger; @@ -48,6 +50,7 @@ import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl; import org.onap.policy.rest.adapter.PolicyRestAdapter; import org.onap.policy.rest.jpa.BRMSParamTemplate; +import com.att.research.xacml.api.pap.PAPException; import com.att.research.xacml.std.IdentifierImpl; import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType; @@ -162,7 +165,7 @@ public class CreateBrmsParamPolicy extends Policy { } @Override - public Map savePolicies() throws Exception { + public Map savePolicies() throws PAPException { Map successMap = new HashMap<>(); if(isPolicyExists()){ @@ -189,8 +192,10 @@ public class CreateBrmsParamPolicy extends Policy { private String getValueFromDictionary(String templateName){ String ruleTemplate = null; CommonClassDaoImpl dbConnection = new CommonClassDaoImpl(); - String queryString="from BRMSParamTemplate where param_template_name= '"+templateName+"'"; - List result = dbConnection.getDataByQuery(queryString); + String queryString="from BRMSParamTemplate where param_template_name= :templateName"; + SimpleBindings params = new SimpleBindings(); + params.put("templateName", templateName); + List result = dbConnection.getDataByQuery(queryString, params); if(!result.isEmpty()){ BRMSParamTemplate template = (BRMSParamTemplate) result.get(0); ruleTemplate = template.getRule(); @@ -227,6 +232,7 @@ public class CreateBrmsParamPolicy extends Policy { line = line.split("\\/\\*")[0] + line.split("\\*\\/")[1].replace("*/", ""); } catch (Exception e) { + LOGGER.debug(e); line = line.split("\\/\\*")[0]; } } else { @@ -238,6 +244,7 @@ public class CreateBrmsParamPolicy extends Policy { try { line = line.split("\\*\\/")[1].replace("*/", ""); } catch (Exception e) { + LOGGER.debug(e); line = ""; } } @@ -271,6 +278,7 @@ public class CreateBrmsParamPolicy extends Policy { try { nextComponent = components[i + 1]; } catch (Exception e) { + LOGGER.debug(e); nextComponent = components[i]; } //If the type is of type String then we add the UI Item and type to the map. @@ -296,7 +304,7 @@ public class CreateBrmsParamPolicy extends Policy { // separately because the fully configured policy is used for multiple // things @Override - public boolean prepareToSave() throws Exception { + public boolean prepareToSave() throws PAPException { if (isPreparedToSave()) { // we have already done this