X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=POLICY-SDK-APP%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fcontroller%2FAutoPushController.java;h=e8217b99baeac91869eb7c21a9b4e07b09bc43fd;hb=779125e31adbcc59a9864843b523bd6ed2751cbb;hp=b5e17f2e064c0af8d3873a2f2c5fb98f1fb355bf;hpb=3c95fa7249cccc3d0eb3c9e89ba708a3167d41ba;p=policy%2Fengine.git diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java index b5e17f2e0..e8217b99b 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/AutoPushController.java @@ -58,7 +58,7 @@ import org.onap.policy.rest.adapter.AutoPushTabAdapter; import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.PolicyEntity; import org.onap.policy.rest.jpa.PolicyVersion; -import org.onap.policy.rest.util.PDPPolicyContainer; +import org.onap.policy.rest.util.PdpPolicyContainer; import org.onap.policy.utils.PolicyUtils; import org.onap.policy.xacml.api.XACMLErrorConstants; import org.onap.policy.xacml.api.pap.OnapPDPGroup; @@ -79,13 +79,12 @@ import org.springframework.web.servlet.ModelAndView; public class AutoPushController extends RestrictedBaseController { private static final Logger logger = FlexLogger.getLogger(AutoPushController.class); - private static final String UTF8 = "UTF-8"; @Autowired CommonClassDao commonClassDao; private PDPGroupContainer container; - private PDPPolicyContainer policyContainer; + private PdpPolicyContainer policyContainer; private PolicyController policyController; protected List groups = Collections.synchronizedList(new ArrayList<>()); @@ -194,6 +193,11 @@ public class AutoPushController extends RestrictedBaseController { public ModelAndView pushPolicyToPDPGroup(HttpServletRequest request, HttpServletResponse response) throws IOException { try { + response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); + request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); + // + // + // ArrayList selectedPdps = new ArrayList<>(); ArrayList selectedPoliciesInUI = new ArrayList<>(); PolicyController controller = getPolicyControllerInstance(); @@ -333,18 +337,12 @@ public class AutoPushController extends RestrictedBaseController { currentPoliciesInGroup.addAll(selectedPolicies); updatedGroupObject.setPolicies(currentPoliciesInGroup); this.container.updateGroup(updatedGroupObject, userId); - - response.setCharacterEncoding(UTF8); - response.setContentType("application / json"); - request.setCharacterEncoding(UTF8); - + response.setContentType(PolicyUtils.APPLICATION_JSON); refreshGroups(); response.getWriter().write(new JSONObject( new JsonMessage(mapper.writeValueAsString(groups))).toString()); } } catch (Exception e) { - response.setCharacterEncoding(UTF8); - request.setCharacterEncoding(UTF8); logger.error(e); response.getWriter().write(PolicyUtils.CATCH_EXCEPTION); } @@ -358,6 +356,11 @@ public class AutoPushController extends RestrictedBaseController { @RequestMapping(value = {"/auto_Push/remove_GroupPolicies.htm"}, method = {RequestMethod.POST}) public ModelAndView removePDPGroup(HttpServletRequest request, HttpServletResponse response) throws IOException { try { + response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); + request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); + // + // + // PolicyController controller = getPolicyControllerInstance(); this.container = new PDPGroupContainer(controller.getPapEngine()); ObjectMapper mapper = new ObjectMapper(); @@ -374,7 +377,7 @@ public class AutoPushController extends RestrictedBaseController { logger.info( "**********************************************************************************************"); - policyContainer = new PDPPolicyContainer(group); + policyContainer = new PdpPolicyContainer(group); if (removePolicyData.size() > 0) { IntStream.range(0, removePolicyData.size()).mapToObj(i -> removePolicyData.get(i).toString()) .forEach(polData -> this.policyContainer.removeItem(polData)); @@ -390,15 +393,11 @@ public class AutoPushController extends RestrictedBaseController { this.container.updateGroup(updatedGroupObject); } - response.setCharacterEncoding(UTF8); - response.setContentType("application / json"); - request.setCharacterEncoding(UTF8); + response.setContentType(PolicyUtils.APPLICATION_JSON); refreshGroups(); response.getWriter().write(new JSONObject(new JsonMessage(mapper.writeValueAsString(groups))).toString()); } catch (Exception e) { - response.setCharacterEncoding(UTF8); - request.setCharacterEncoding(UTF8); logger.error(e); response.getWriter().write(PolicyUtils.CATCH_EXCEPTION); }