X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=POLICY-SDK-APP%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fcontroller%2FCreateBRMSParamController.java;h=143d675bf2149a028c81cc5e37be29fdf7b82037;hp=1adeb6d96d0eff0cff023b950ce81635d7a13769;hb=e4ac1ef3c51fc9afe44849ada5bea8c3d6057897;hpb=0950d79047d3404c15b4dd30cffeb81346565f64 diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java index 1adeb6d96..143d675bf 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java @@ -62,8 +62,9 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.rest.adapter.PolicyRestAdapter; import org.onap.policy.rest.dao.CommonClassDao; -import org.onap.policy.rest.jpa.BRMSParamTemplate; +import org.onap.policy.rest.jpa.BrmsParamTemplate; import org.onap.policy.rest.jpa.PolicyEntity; +import org.onap.policy.utils.PolicyUtils; import org.onap.policy.xacml.api.XACMLErrorConstants; import org.onap.portalsdk.core.controller.RestrictedBaseController; import org.springframework.beans.factory.annotation.Autowired; @@ -130,9 +131,9 @@ public class CreateBRMSParamController extends RestrictedBaseController { } private String findRule(String ruleTemplate) { - List datas = commonClassDao.getDataById(BRMSParamTemplate.class, "ruleName", ruleTemplate); + List datas = commonClassDao.getDataById(BrmsParamTemplate.class, "ruleName", ruleTemplate); if (CollectionUtils.isNotEmpty(datas)) { - return ((BRMSParamTemplate) datas.get(0)).getRule(); + return ((BrmsParamTemplate) datas.get(0)).getRule(); } return null; } @@ -244,10 +245,14 @@ public class CreateBRMSParamController extends RestrictedBaseController { dynamicLayoutMap.put(caption, type); } - /* + /** + * prePopulateBRMSParamPolicyData. * When the User Click Edit or View Policy the following method will get invoked for setting the data to * PolicyRestAdapter. - * Which is used to bind the data in GUI + * Which is used to bind the data in GUI. + * + * @param policyAdapter PolicyRestAdapter + * @param entity PolicyEntity */ public void prePopulateBRMSParamPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) { dynamicLayoutMap = new HashMap<>(); @@ -351,20 +356,7 @@ public class CreateBRMSParamController extends RestrictedBaseController { String value = (String) attributeValue.getContent().get(0); AttributeDesignatorType designator = match.getAttributeDesignator(); String attributeId = designator.getAttributeId(); - if ("RiskType".equals(attributeId)) { - policyAdapter.setRiskType(value); - } - if ("RiskLevel".equals(attributeId)) { - policyAdapter.setRiskLevel(value); - } - if ("guard".equals(attributeId)) { - policyAdapter.setGuard(value); - } - if ("TTLDate".equals(attributeId) && !value.contains("NA")) { - PolicyController controller = new PolicyController(); - String newDate = controller.convertDate(value); - policyAdapter.setTtlDate(newDate); - } + policyAdapter.setupUsingAttribute(attributeId, value); } } @@ -535,9 +527,9 @@ public class CreateBRMSParamController extends RestrictedBaseController { // Replacing the value with the inputs provided by the user in the editor. body = matcher.replaceAll(copyMap.get(input)); } - response.setCharacterEncoding("UTF-8"); - response.setContentType("application / json"); - request.setCharacterEncoding("UTF-8"); + response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); + response.setContentType(PolicyUtils.APPLICATION_JSON); + request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); response.getWriter().write(new JSONObject("{policyData: " + mapper.writeValueAsString(body) + "}").toString());