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=244b7fd95234dbd2e3f4b970e9177128d7a0917c;hp=1adeb6d96d0eff0cff023b950ce81635d7a13769;hb=1e61676b77dd09659027b8984f050df7e8538526;hpb=f18fbfc026de9cf02126f57844c37abfee607394 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..244b7fd95 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 @@ -64,6 +64,7 @@ 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.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; @@ -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());