Sonar fixes for ONAP-PAP-REST
[policy/engine.git] / ONAP-PAP-REST / src / main / java / org / onap / policy / pap / xacml / rest / controller / ClosedLoopDictionaryController.java
index a2a6d6e..d142a46 100644 (file)
@@ -22,7 +22,6 @@ package org.onap.policy.pap.xacml.rest.controller;
 
 import java.io.IOException;
 import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -62,26 +61,47 @@ public class ClosedLoopDictionaryController{
        private static final Logger LOGGER = FlexLogger.getLogger(ClosedLoopDictionaryController.class);
 
        private static CommonClassDao commonClassDao;
+       private static String vsclaction = "vsclaction";
+       private static String successMapKey = "successMapKey";
+       private static String successMessage = "success";
+       private static String operation = "operation";
+       private static String getDictionary = "getDictionary";
+       private static String dictionaryDBQuery = "dictionaryDBQuery";
+       private static String errorMsg  = "error";
+       private static String vnftype = "vnftype";
+       private static String pepName = "pepName";
+       private static String varbindName = "varbindName";
+       private static String serviceName = "serviceName";
+       private static String siteName = "siteName";
+       private static String apiflag = "apiflag";
+       private static String dictionaryFields = "dictionaryFields";
+       private static String update = "update";
+       private static String duplicateResponseString = "Duplicate";
+       private static String userid = "userid";
+       private static String utf8 = "UTF-8";
+       private static String applicationJsonContentType = "application / json";
+       private static String successMsg = "Success";
        
        @Autowired
        public ClosedLoopDictionaryController(CommonClassDao commonClassDao){
                ClosedLoopDictionaryController.commonClassDao = commonClassDao;
        }
-       
+       /*
+        * This is an empty constructor
+        */
        public ClosedLoopDictionaryController(){}
 
        public UserInfo getUserInfo(String loginId){
-               UserInfo name = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
-               return name;
+               return (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
        }
 
 
        @RequestMapping(value={"/get_VSCLActionDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getVSCLActionDictionaryByNameEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getVSCLActionDictionaryByNameEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
-                       model.put("vsclActionDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(VSCLAction.class, "vsclaction")));
+                       model.put("vsclActionDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(VSCLAction.class, vsclaction)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
                        response.getWriter().write(j.toString());
@@ -93,34 +113,34 @@ public class ClosedLoopDictionaryController{
 
 
        @RequestMapping(value={"/get_VSCLActionData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getVSCLActionDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getVSCLActionDictionaryEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
                        model.put("vsclActionDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(VSCLAction.class)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
-                       response.addHeader("successMapKey", "success"); 
-                       response.addHeader("operation", "getDictionary");
+                       response.addHeader(successMapKey, successMessage); 
+                       response.addHeader(operation, getDictionary);
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
-                       response.addHeader("error", "dictionaryDBQuery");
+                       response.addHeader(errorMsg, dictionaryDBQuery);
                }
        }
 
        @RequestMapping(value={"/get_VNFTypeDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getVNFTypeDictionaryByNameEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getVNFTypeDictionaryByNameEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
-                       model.put("vnfTypeDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(VNFType.class, "vnftype")));
+                       model.put("vnfTypeDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(VNFType.class, vnftype)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
-                       response.addHeader("successMapKey", "success"); 
-                       response.addHeader("operation", "getDictionary");
+                       response.addHeader(successMapKey, successMessage); 
+                       response.addHeader(operation, getDictionary);
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
@@ -129,30 +149,30 @@ public class ClosedLoopDictionaryController{
        }
 
        @RequestMapping(value={"/get_VNFTypeData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getVNFTypeDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getVNFTypeDictionaryEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
                        model.put("vnfTypeDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(VNFType.class)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
-                       response.addHeader("successMapKey", "success"); 
-                       response.addHeader("operation", "getDictionary");
+                       response.addHeader(successMapKey, successMessage); 
+                       response.addHeader(operation, getDictionary);
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
-                       response.addHeader("error", "dictionaryDBQuery");
+                       response.addHeader(errorMsg, dictionaryDBQuery);
                }
        }
 
        @RequestMapping(value={"/get_PEPOptionsDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getPEPOptionsDictionaryByNameEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getPEPOptionsDictionaryByNameEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
-                       model.put("pepOptionsDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(PEPOptions.class, "pepName")));
+                       model.put("pepOptionsDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(PEPOptions.class, pepName)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
                        response.getWriter().write(j.toString());
@@ -163,30 +183,30 @@ public class ClosedLoopDictionaryController{
        }
 
        @RequestMapping(value={"/get_PEPOptionsData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getPEPOptionsDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getPEPOptionsDictionaryEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
                        model.put("pepOptionsDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(PEPOptions.class)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
-                       response.addHeader("successMapKey", "success"); 
-                       response.addHeader("operation", "getDictionary");
+                       response.addHeader(successMapKey, successMessage); 
+                       response.addHeader(operation, getDictionary);
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
-                       response.addHeader("error", "dictionaryDBQuery");
+                       response.addHeader(errorMsg, dictionaryDBQuery);
                }
        }
 
        @RequestMapping(value={"/get_VarbindDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getVarbindDictionaryByNameEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getVarbindDictionaryByNameEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
-                       model.put("varbindDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(VarbindDictionary.class, "varbindName")));
+                       model.put("varbindDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(VarbindDictionary.class, varbindName)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
                        response.getWriter().write(j.toString());
@@ -197,30 +217,30 @@ public class ClosedLoopDictionaryController{
        }
 
        @RequestMapping(value={"/get_VarbindDictionaryData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getVarbindDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getVarbindDictionaryEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
                        model.put("varbindDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(VarbindDictionary.class)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
-                       response.addHeader("successMapKey", "success"); 
-                       response.addHeader("operation", "getDictionary");
+                       response.addHeader(successMapKey, successMessage); 
+                       response.addHeader(operation, getDictionary);
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
-                       response.addHeader("error", "dictionaryDBQuery");
+                       response.addHeader(errorMsg, dictionaryDBQuery);
                }
        }
 
        @RequestMapping(value={"/get_ClosedLoopServicesDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getClosedLoopServiceDictionaryByNameEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getClosedLoopServiceDictionaryByNameEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
-                       model.put("closedLoopServiceDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(ClosedLoopD2Services.class, "serviceName")));
+                       model.put("closedLoopServiceDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(ClosedLoopD2Services.class, serviceName)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
                        response.getWriter().write(j.toString());
@@ -231,30 +251,30 @@ public class ClosedLoopDictionaryController{
        }
 
        @RequestMapping(value={"/get_ClosedLoopServicesData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getClosedLoopServiceDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getClosedLoopServiceDictionaryEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
                        model.put("closedLoopServiceDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(ClosedLoopD2Services.class)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
-                       response.addHeader("successMapKey", "success"); 
-                       response.addHeader("operation", "getDictionary");
+                       response.addHeader(successMapKey, successMessage); 
+                       response.addHeader(operation, getDictionary);
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
-                       response.addHeader("error", "dictionaryDBQuery");
+                       response.addHeader(errorMsg, dictionaryDBQuery);
                }
        }
 
        @RequestMapping(value={"/get_ClosedLoopSiteDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getClosedLoopSiteDictionaryByNameEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getClosedLoopSiteDictionaryByNameEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
-                       model.put("closedLoopSiteDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(ClosedLoopSite.class, "siteName")));
+                       model.put("closedLoopSiteDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(ClosedLoopSite.class, siteName)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
                        response.getWriter().write(j.toString());
@@ -265,31 +285,31 @@ public class ClosedLoopDictionaryController{
        }
 
        @RequestMapping(value={"/get_ClosedLoopSiteData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getClosedLoopSiteDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getClosedLoopSiteDictionaryEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
                        model.put("closedLoopSiteDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(ClosedLoopSite.class)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
-                       response.addHeader("successMapKey", "success"); 
-                       response.addHeader("operation", "getDictionary");
+                       response.addHeader(successMapKey, successMessage); 
+                       response.addHeader(operation, getDictionary);
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
-                       response.addHeader("error", "dictionaryDBQuery");
+                       response.addHeader(errorMsg, dictionaryDBQuery);
                }
        }
 
        @RequestMapping(value={"/cl_dictionary/save_vsclAction"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView saveVSCLAction(HttpServletRequest request, HttpServletResponse response)throws UnsupportedEncodingException, IOException{
+       public ModelAndView saveVSCLAction(HttpServletRequest request, HttpServletResponse response)throws IOException{
                try {
                        boolean duplicateflag = false;
                        boolean isFakeUpdate = false;
                        boolean fromAPI = false;
-                       if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
+                       if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
                                fromAPI = true;
                        }
                        ObjectMapper mapper = new ObjectMapper();
@@ -298,15 +318,14 @@ public class ClosedLoopDictionaryController{
                        VSCLAction vSCLAction;
                        String userId = null;
                        if (fromAPI) {
-                               vSCLAction = (VSCLAction)mapper.readValue(root.get("dictionaryFields").toString(), VSCLAction.class);
+                               vSCLAction = (VSCLAction)mapper.readValue(root.get(dictionaryFields).toString(), VSCLAction.class);
                                userId = "API";
 
                                //check if update operation or create, get id for data to be updated and update attributeData
-                               if (request.getParameter("operation").equals("update")) {
-                                       List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(vSCLAction.getVsclaction(), "vsclaction", VSCLAction.class);
-                                       int id = 0;
+                               if ((update).equals(request.getParameter(operation))) {
+                                       List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(vSCLAction.getVsclaction(), vsclaction, VSCLAction.class);
                                        VSCLAction data = (VSCLAction) duplicateData.get(0);
-                                       id = data.getId();
+                                       int id = data.getId();
                                        if(id==0){
                                                isFakeUpdate=true;
                                                vSCLAction.setId(1);
@@ -319,10 +338,10 @@ public class ClosedLoopDictionaryController{
 
                        } else {
                                vSCLAction = (VSCLAction)mapper.readValue(root.get("vsclActionDictionaryData").toString(), VSCLAction.class);
-                               userId = root.get("userid").textValue();
+                               userId = root.get(userid).textValue();
                        }
                        if(vSCLAction.getId() == 0){
-                               List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(vSCLAction.getVsclaction(), "vsclaction", VSCLAction.class);
+                               List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(vSCLAction.getVsclaction(), vsclaction, VSCLAction.class);
                                if(!duplicateData.isEmpty()){
                                        duplicateflag = true;
                                }else{
@@ -340,16 +359,16 @@ public class ClosedLoopDictionaryController{
 
                        String responseString = "";
                        if(duplicateflag){
-                               responseString = "Duplicate";
+                               responseString = duplicateResponseString;
                        }else{
                                responseString = mapper.writeValueAsString(commonClassDao.getData(VSCLAction.class));
                        }       
                        if (fromAPI) {
-                               if (responseString!=null && !responseString.equals("Duplicate")) {
+                               if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
                                        if(isFakeUpdate) {
                                                responseString = "Exists";
                                        } else {
-                                               responseString = "Success";
+                                               responseString = successMsg;
                                        }               
 
                                }
@@ -357,9 +376,9 @@ public class ClosedLoopDictionaryController{
                                result.setViewName(responseString);
                                return result;
                        } else {
-                               response.setCharacterEncoding("UTF-8");
-                               response.setContentType("application / json"); 
-                               request.setCharacterEncoding("UTF-8");
+                               response.setCharacterEncoding(utf8);
+                               response.setContentType(applicationJsonContentType); 
+                               request.setCharacterEncoding(utf8);
 
                                PrintWriter out = response.getWriter();
                                JSONObject j = new JSONObject("{vsclActionDictionaryDatas: " + responseString + "}");
@@ -369,8 +388,8 @@ public class ClosedLoopDictionaryController{
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
                        out.write(e.getMessage());
                }
@@ -378,16 +397,16 @@ public class ClosedLoopDictionaryController{
        }
 
        @RequestMapping(value={"/cl_dictionary/remove_VsclAction"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeVSCLAction(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
+       public ModelAndView removeVSCLAction(HttpServletRequest request, HttpServletResponse response) throws IOException {
                try{
                        ObjectMapper mapper = new ObjectMapper();
                        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                        JsonNode root = mapper.readTree(request.getReader());
                        VSCLAction vSCLAction = (VSCLAction)mapper.readValue(root.get("data").toString(), VSCLAction.class);
                        commonClassDao.delete(vSCLAction);
-                       response.setCharacterEncoding("UTF-8");
-                       response.setContentType("application / json");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       response.setContentType(applicationJsonContentType);
+                       request.setCharacterEncoding(utf8);
 
                        PrintWriter out = response.getWriter();
 
@@ -399,8 +418,8 @@ public class ClosedLoopDictionaryController{
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
                        out.write(e.getMessage());
                }
@@ -408,13 +427,13 @@ public class ClosedLoopDictionaryController{
        }
 
        @RequestMapping(value={"/cl_dictionary/save_vnfType"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView saveVnfType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+       public ModelAndView saveVnfType(HttpServletRequest request, HttpServletResponse response) throws IOException{
                try {
                        boolean duplicateflag = false;
                        boolean isFakeUpdate = false;
                        boolean fromAPI = false;
 
-                       if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
+                       if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
                                fromAPI = true;
                        }
                        ObjectMapper mapper = new ObjectMapper();
@@ -424,15 +443,14 @@ public class ClosedLoopDictionaryController{
                        String userId = null;
 
                        if (fromAPI) {
-                               vNFType = (VNFType)mapper.readValue(root.get("dictionaryFields").toString(), VNFType.class);
+                               vNFType = (VNFType)mapper.readValue(root.get(dictionaryFields).toString(), VNFType.class);
                                userId = "API";
 
                                //check if update operation or create, get id for data to be updated and update attributeData
-                               if (request.getParameter("operation").equals("update")) {
-                                       List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(vNFType.getVnftype(), "vnftype", VNFType.class);
-                                       int id = 0;
+                               if ((update).equals(request.getParameter(operation))) {
+                                       List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(vNFType.getVnftype(), vnftype, VNFType.class);
                                        VNFType data = (VNFType) duplicateData.get(0);
-                                       id = data.getId();
+                                       int id = data.getId();
                                        if(id==0){
                                                isFakeUpdate=true;
                                                vNFType.setId(1);
@@ -443,10 +461,10 @@ public class ClosedLoopDictionaryController{
                                }
                        } else {
                                vNFType = (VNFType)mapper.readValue(root.get("vnfTypeDictionaryData").toString(), VNFType.class);
-                               userId = root.get("userid").textValue();
+                               userId = root.get(userid).textValue();
                        }
                        if(vNFType.getId() == 0){
-                               List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(vNFType.getVnftype(), "vnftype", VNFType.class);
+                               List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(vNFType.getVnftype(), vnftype, VNFType.class);
                                if(!duplicateData.isEmpty()){
                                        duplicateflag = true;
                                }else{
@@ -463,25 +481,25 @@ public class ClosedLoopDictionaryController{
                        } 
                        String responseString = "";
                        if(duplicateflag){
-                               responseString = "Duplicate";
+                               responseString = duplicateResponseString;
                        }else{
                                responseString = mapper.writeValueAsString(commonClassDao.getData(VNFType.class));
                        } 
                        if (fromAPI) {
-                               if (responseString!=null && !responseString.equals("Duplicate")) {
+                               if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
                                        if(isFakeUpdate) {
                                                responseString = "Exists";
                                        } else {
-                                               responseString = "Success";
+                                               responseString = successMsg;
                                        }        
                                }
                                ModelAndView result = new ModelAndView();
                                result.setViewName(responseString);
                                return result; 
                        } else {
-                               response.setCharacterEncoding("UTF-8");
-                               response.setContentType("application / json");
-                               request.setCharacterEncoding("UTF-8");
+                               response.setCharacterEncoding(utf8);
+                               response.setContentType(applicationJsonContentType);
+                               request.setCharacterEncoding(utf8);
 
                                PrintWriter out = response.getWriter();
                                JSONObject j = new JSONObject("{vnfTypeDictionaryDatas: " + responseString + "}");
@@ -491,8 +509,8 @@ public class ClosedLoopDictionaryController{
                } 
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
                        out.write(e.getMessage());
                }
@@ -500,16 +518,16 @@ public class ClosedLoopDictionaryController{
        }
 
        @RequestMapping(value={"/cl_dictionary/remove_vnfType"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeVnfType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
+       public ModelAndView removeVnfType(HttpServletRequest request, HttpServletResponse response) throws IOException {
                try{
                        ObjectMapper mapper = new ObjectMapper();
                        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                        JsonNode root = mapper.readTree(request.getReader());
                        VNFType vNFType = (VNFType)mapper.readValue(root.get("data").toString(), VNFType.class);
                        commonClassDao.delete(vNFType);
-                       response.setCharacterEncoding("UTF-8");
-                       response.setContentType("application / json");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       response.setContentType(applicationJsonContentType);
+                       request.setCharacterEncoding(utf8);
 
                        PrintWriter out = response.getWriter();
 
@@ -521,8 +539,8 @@ public class ClosedLoopDictionaryController{
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
                        out.write(e.getMessage());
                }
@@ -530,12 +548,12 @@ public class ClosedLoopDictionaryController{
        }
 
        @RequestMapping(value={"/cl_dictionary/save_pepOptions"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView savePEPOptions(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+       public ModelAndView savePEPOptions(HttpServletRequest request, HttpServletResponse response) throws IOException{
                try {
                        boolean duplicateflag = false;
             boolean isFakeUpdate = false;
             boolean fromAPI = false;
-            if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
+            if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
                 fromAPI = true;
             }
                        ObjectMapper mapper = new ObjectMapper();
@@ -545,16 +563,15 @@ public class ClosedLoopDictionaryController{
             GridData gridData;
             String userId = null;
             if (fromAPI) {
-                pEPOptions = (PEPOptions)mapper.readValue(root.get("dictionaryFields").toString(), PEPOptions.class);
-                gridData = (GridData)mapper.readValue(root.get("dictionaryFields").toString(), GridData.class);
+                pEPOptions = (PEPOptions)mapper.readValue(root.get(dictionaryFields).toString(), PEPOptions.class);
+                gridData = (GridData)mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
                 userId = "API";
                 
                 //check if update operation or create, get id for data to be updated and update attributeData
-                if (request.getParameter("operation").equals("update")) {
-                    List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(pEPOptions.getPepName(), "pepName", PEPOptions.class);
-                    int id = 0;
+                if ((update).equals(request.getParameter(operation))) {
+                    List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(pEPOptions.getPepName(), pepName, PEPOptions.class);
                     PEPOptions data = (PEPOptions) duplicateData.get(0);
-                    id = data.getId();
+                    int id = data.getId();
                     if(id==0){
                         isFakeUpdate=true;
                         pEPOptions.setId(1);
@@ -566,11 +583,11 @@ public class ClosedLoopDictionaryController{
             } else {
                pEPOptions = (PEPOptions)mapper.readValue(root.get("pepOptionsDictionaryData").toString(), PEPOptions.class);
                gridData = (GridData)mapper.readValue(root.get("pepOptionsDictionaryData").toString(), GridData.class);
-               userId = root.get("userid").textValue();
+               userId = root.get(userid).textValue();
             }
                        String actions = "";
                        int counter = 0;
-                       if(gridData.getAttributes().size() > 0){
+                       if(!gridData.getAttributes().isEmpty()){
                                for(Object attribute : gridData.getAttributes()){
                                        if(attribute instanceof LinkedHashMap<?, ?>){
                                                String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
@@ -586,7 +603,7 @@ public class ClosedLoopDictionaryController{
                        }
                        pEPOptions.setActions(actions);
                        if(pEPOptions.getId() == 0){
-                               List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(pEPOptions.getPepName(), "pepName", PEPOptions.class);
+                               List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(pEPOptions.getPepName(), pepName, PEPOptions.class);
                                if(!duplicateData.isEmpty()){
                                        duplicateflag = true;
                                }else{
@@ -603,16 +620,16 @@ public class ClosedLoopDictionaryController{
                        }
             String responseString = "";
             if(duplicateflag){
-                responseString = "Duplicate";
+                responseString = duplicateResponseString;
             }else{
                 responseString = mapper.writeValueAsString(commonClassDao.getData(PEPOptions.class));
             } 
             if (fromAPI) {
-                if (responseString!=null && !responseString.equals("Duplicate")) {
+                if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
                     if(isFakeUpdate){
                         responseString = "Exists";
                     } else {
-                        responseString = "Success";
+                        responseString = successMsg;
                     } 
                 }
                 
@@ -620,9 +637,9 @@ public class ClosedLoopDictionaryController{
                 result.setViewName(responseString);
                 return result;
             } else {
-                response.setCharacterEncoding("UTF-8");
-                response.setContentType("application / json");
-                request.setCharacterEncoding("UTF-8");
+                response.setCharacterEncoding(utf8);
+                response.setContentType(applicationJsonContentType);
+                request.setCharacterEncoding(utf8);
  
                 PrintWriter out = response.getWriter();
                 JSONObject j = new JSONObject("{pepOptionsDictionaryDatas: " + responseString + "}");
@@ -632,8 +649,8 @@ public class ClosedLoopDictionaryController{
  
         }catch (Exception e){
                LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
                        out.write(e.getMessage());
                }
@@ -641,16 +658,16 @@ public class ClosedLoopDictionaryController{
        }
 
        @RequestMapping(value={"/cl_dictionary/remove_pepOptions"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removePEPOptions(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
+       public ModelAndView removePEPOptions(HttpServletRequest request, HttpServletResponse response) throws IOException {
                try{
                        ObjectMapper mapper = new ObjectMapper();
                        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                        JsonNode root = mapper.readTree(request.getReader());
                        PEPOptions pEPOptions = (PEPOptions)mapper.readValue(root.get("data").toString(), PEPOptions.class);
                        commonClassDao.delete(pEPOptions);
-                       response.setCharacterEncoding("UTF-8");
-                       response.setContentType("application / json");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       response.setContentType(applicationJsonContentType);
+                       request.setCharacterEncoding(utf8);
 
                        PrintWriter out = response.getWriter();
 
@@ -662,8 +679,8 @@ public class ClosedLoopDictionaryController{
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
                        out.write(e.getMessage());
                }
@@ -671,12 +688,12 @@ public class ClosedLoopDictionaryController{
        }
 
        @RequestMapping(value={"/cl_dictionary/save_service"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView saveServiceType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+       public ModelAndView saveServiceType(HttpServletRequest request, HttpServletResponse response) throws IOException{
                try {
                        boolean duplicateflag = false;
             boolean isFakeUpdate = false;
             boolean fromAPI = false;
-            if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
+            if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
                 fromAPI = true;
             }
                        ObjectMapper mapper = new ObjectMapper();
@@ -685,15 +702,14 @@ public class ClosedLoopDictionaryController{
             ClosedLoopD2Services serviceData;
             String userId = null;
             if (fromAPI) {
-                serviceData = (ClosedLoopD2Services)mapper.readValue(root.get("dictionaryFields").toString(), ClosedLoopD2Services.class);
+                serviceData = (ClosedLoopD2Services)mapper.readValue(root.get(dictionaryFields).toString(), ClosedLoopD2Services.class);
                 userId = "API";
                 
                 //check if update operation or create, get id for data to be updated and update attributeData
-                if (request.getParameter("operation").equals("update")) {
-                    List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(serviceData.getServiceName(), "serviceName", ClosedLoopD2Services.class);
-                    int id = 0;
+                if ((update).equals(request.getParameter(operation))) {
+                    List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(serviceData.getServiceName(), serviceName, ClosedLoopD2Services.class);
                     ClosedLoopD2Services data = (ClosedLoopD2Services) duplicateData.get(0);
-                    id = data.getId();
+                    int id = data.getId();
                     if(id==0){
                         isFakeUpdate=true;
                         serviceData.setId(1);
@@ -704,10 +720,10 @@ public class ClosedLoopDictionaryController{
                 }
             } else {
                serviceData = (ClosedLoopD2Services)mapper.readValue(root.get("closedLoopServiceDictionaryData").toString(), ClosedLoopD2Services.class);
-               userId = root.get("userid").textValue();
+               userId = root.get(userid).textValue();
             }
                        if(serviceData.getId() == 0){
-                               List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(serviceData.getServiceName(), "serviceName", ClosedLoopD2Services.class);
+                               List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(serviceData.getServiceName(), serviceName, ClosedLoopD2Services.class);
                                if(!duplicateData.isEmpty()){
                                        duplicateflag = true;
                                }else{
@@ -724,25 +740,25 @@ public class ClosedLoopDictionaryController{
                        }
             String responseString = "";
             if(duplicateflag){
-                responseString = "Duplicate";
+                responseString = duplicateResponseString;
             }else{
                 responseString = mapper.writeValueAsString(commonClassDao.getData(ClosedLoopD2Services.class));
             } 
             if (fromAPI) {
-                if (responseString!=null && !responseString.equals("Duplicate")) {
+                if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
                     if(isFakeUpdate){
                         responseString = "Exists";
                     } else {
-                        responseString = "Success";
+                        responseString = successMsg;
                     }
                 }
                 ModelAndView result = new ModelAndView();
                 result.setViewName(responseString);
                 return result;
             } else {
-                response.setCharacterEncoding("UTF-8");
-                response.setContentType("application / json");
-                request.setCharacterEncoding("UTF-8");
+                response.setCharacterEncoding(utf8);
+                response.setContentType(applicationJsonContentType);
+                request.setCharacterEncoding(utf8);
  
                 PrintWriter out = response.getWriter();
                 JSONObject j = new JSONObject("{closedLoopServiceDictionaryDatas: " + responseString + "}");
@@ -751,8 +767,8 @@ public class ClosedLoopDictionaryController{
             }
         }catch (Exception e){
                LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
                        out.write(e.getMessage());
                }
@@ -760,16 +776,16 @@ public class ClosedLoopDictionaryController{
        }
 
        @RequestMapping(value={"/cl_dictionary/remove_Service"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeServiceType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
+       public ModelAndView removeServiceType(HttpServletRequest request, HttpServletResponse response) throws IOException {
                try{
                        ObjectMapper mapper = new ObjectMapper();
                        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                        JsonNode root = mapper.readTree(request.getReader());
                        ClosedLoopD2Services closedLoopD2Services = (ClosedLoopD2Services)mapper.readValue(root.get("data").toString(), ClosedLoopD2Services.class);
                        commonClassDao.delete(closedLoopD2Services);
-                       response.setCharacterEncoding("UTF-8");
-                       response.setContentType("application / json");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       response.setContentType(applicationJsonContentType);
+                       request.setCharacterEncoding(utf8);
 
                        PrintWriter out = response.getWriter();
 
@@ -781,8 +797,8 @@ public class ClosedLoopDictionaryController{
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
                        out.write(e.getMessage());
                }
@@ -790,13 +806,13 @@ public class ClosedLoopDictionaryController{
        }
 
        @RequestMapping(value={"/cl_dictionary/save_siteName"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView saveSiteType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+       public ModelAndView saveSiteType(HttpServletRequest request, HttpServletResponse response) throws IOException{
                try {
                        boolean duplicateflag = false;
             boolean isFakeUpdate = false;
             boolean fromAPI = false;
             
-            if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
+            if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
                 fromAPI = true;
             }
                        ObjectMapper mapper = new ObjectMapper();
@@ -805,14 +821,13 @@ public class ClosedLoopDictionaryController{
             ClosedLoopSite siteData;
             String userId = null;
             if (fromAPI) {
-                siteData = (ClosedLoopSite)mapper.readValue(root.get("dictionaryFields").toString(), ClosedLoopSite.class);
+                siteData = (ClosedLoopSite)mapper.readValue(root.get(dictionaryFields).toString(), ClosedLoopSite.class);
                 userId = "API";
                 //check if update operation or create, get id for data to be updated and update attributeData
-                if (request.getParameter("operation").equals("update")) {
-                    List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(siteData.getSiteName(), "siteName", ClosedLoopSite.class);
-                    int id = 0;
+                if ((update).equals(request.getParameter(operation))) {
+                    List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(siteData.getSiteName(), siteName, ClosedLoopSite.class);
                     ClosedLoopSite data = (ClosedLoopSite) duplicateData.get(0);
-                    id = data.getId();
+                    int id = data.getId();
                     if(id==0){
                         isFakeUpdate=true;
                         siteData.setId(1);
@@ -823,10 +838,10 @@ public class ClosedLoopDictionaryController{
                 }
             } else {
                siteData = (ClosedLoopSite)mapper.readValue(root.get("closedLoopSiteDictionaryData").toString(), ClosedLoopSite.class);
-               userId = root.get("userid").textValue();
+               userId = root.get(userid).textValue();
             }
                        if(siteData.getId() == 0){
-                               List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(siteData.getSiteName(), "siteName", ClosedLoopSite.class);
+                               List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(siteData.getSiteName(), siteName, ClosedLoopSite.class);
                                if(!duplicateData.isEmpty()){
                                        duplicateflag = true;
                                }else{
@@ -843,26 +858,26 @@ public class ClosedLoopDictionaryController{
                        }
             String responseString = "";
             if(duplicateflag){
-                responseString = "Duplicate";
+                responseString = duplicateResponseString;
             }else{
                 responseString = mapper.writeValueAsString(commonClassDao.getData(ClosedLoopSite.class));
             }   
             
             if (fromAPI) {
-                if (responseString!=null && !responseString.equals("Duplicate")) {
+                if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
                     if(isFakeUpdate){
                         responseString = "Exists";
                     } else {
-                        responseString = "Success";
+                        responseString = successMsg;
                     }
                 }
                 ModelAndView result = new ModelAndView();
                 result.setViewName(responseString);
                 return result;
             } else {
-                response.setCharacterEncoding("UTF-8");
-                response.setContentType("application / json");
-                request.setCharacterEncoding("UTF-8");
+                response.setCharacterEncoding(utf8);
+                response.setContentType(applicationJsonContentType);
+                request.setCharacterEncoding(utf8);
  
                 PrintWriter out = response.getWriter();
                 JSONObject j = new JSONObject("{closedLoopSiteDictionaryDatas: " + responseString + "}");
@@ -871,8 +886,8 @@ public class ClosedLoopDictionaryController{
             }
         }catch (Exception e){
                LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
                        out.write(e.getMessage());
                }
@@ -880,16 +895,16 @@ public class ClosedLoopDictionaryController{
        }
 
        @RequestMapping(value={"/cl_dictionary/remove_site"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeSiteType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
+       public ModelAndView removeSiteType(HttpServletRequest request, HttpServletResponse response) throws IOException {
                try{
                        ObjectMapper mapper = new ObjectMapper();
                        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                        JsonNode root = mapper.readTree(request.getReader());
                        ClosedLoopSite closedLoopSite = (ClosedLoopSite)mapper.readValue(root.get("data").toString(), ClosedLoopSite.class);
                        commonClassDao.delete(closedLoopSite);
-                       response.setCharacterEncoding("UTF-8");
-                       response.setContentType("application / json");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       response.setContentType(applicationJsonContentType);
+                       request.setCharacterEncoding(utf8);
 
                        PrintWriter out = response.getWriter();
 
@@ -901,8 +916,8 @@ public class ClosedLoopDictionaryController{
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
                        out.write(e.getMessage());
                }
@@ -910,12 +925,12 @@ public class ClosedLoopDictionaryController{
        }
 
        @RequestMapping(value={"/cl_dictionary/save_varbind"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView saveVarbind(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+       public ModelAndView saveVarbind(HttpServletRequest request, HttpServletResponse response) throws IOException{
                try {
                        boolean duplicateflag = false;
             boolean isFakeUpdate = false;
             boolean fromAPI = false;
-            if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
+            if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
                 fromAPI = true;
             }
                        ObjectMapper mapper = new ObjectMapper();
@@ -924,15 +939,14 @@ public class ClosedLoopDictionaryController{
             VarbindDictionary varbindDictionary;
             String userId = null;
             if (fromAPI) {
-                varbindDictionary = (VarbindDictionary)mapper.readValue(root.get("dictionaryFields").toString(), VarbindDictionary.class);
+                varbindDictionary = (VarbindDictionary)mapper.readValue(root.get(dictionaryFields).toString(), VarbindDictionary.class);
                 userId = "API";
                 
                 //check if update operation or create, get id for data to be updated and update attributeData
-                if (request.getParameter("operation").equals("update")) {
-                    List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(varbindDictionary.getVarbindName(), "varbindName", VarbindDictionary.class);
-                    int id = 0;
+                if ((update).equals(request.getParameter(operation))) {
+                    List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(varbindDictionary.getVarbindName(), varbindName, VarbindDictionary.class);
                     VarbindDictionary data = (VarbindDictionary) duplicateData.get(0);
-                    id = data.getId();
+                    int id = data.getId();
                     if(id==0){
                         isFakeUpdate=true;
                         varbindDictionary.setId(1);
@@ -943,10 +957,10 @@ public class ClosedLoopDictionaryController{
                 }
             } else {
                varbindDictionary = (VarbindDictionary)mapper.readValue(root.get("varbindDictionaryData").toString(), VarbindDictionary.class);
-               userId = root.get("userid").textValue();
+               userId = root.get(userid).textValue();
             }
                        if(varbindDictionary.getId() == 0){
-                               List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(varbindDictionary.getVarbindName(), "varbindName", VarbindDictionary.class);
+                               List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(varbindDictionary.getVarbindName(), varbindName, VarbindDictionary.class);
                                if(!duplicateData.isEmpty()){
                                        duplicateflag = true;
                                }else{
@@ -963,26 +977,26 @@ public class ClosedLoopDictionaryController{
                        }
             String responseString = "";
             if(duplicateflag){
-                responseString = "Duplicate";
+                responseString = duplicateResponseString;
             }else{
                 responseString = mapper.writeValueAsString(commonClassDao.getData(VarbindDictionary.class));
             }
             
             if (fromAPI) {
-                if (responseString!=null && !responseString.equals("Duplicate")) {
+                if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
                     if(isFakeUpdate){
                         responseString = "Exists";
                     } else {
-                        responseString = "Success";
+                        responseString = successMsg;
                     }
                 }
                 ModelAndView result = new ModelAndView();
                 result.setViewName(responseString);
                 return result;
             } else {
-                response.setCharacterEncoding("UTF-8");
-                response.setContentType("application / json");
-                request.setCharacterEncoding("UTF-8");
+                response.setCharacterEncoding(utf8);
+                response.setContentType(applicationJsonContentType);
+                request.setCharacterEncoding(utf8);
  
                 PrintWriter out = response.getWriter();
                 JSONObject j = new JSONObject("{varbindDictionaryDatas: " + responseString + "}");
@@ -991,8 +1005,8 @@ public class ClosedLoopDictionaryController{
             }
         }catch (Exception e){
                LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
                        out.write(e.getMessage());
                }
@@ -1000,16 +1014,16 @@ public class ClosedLoopDictionaryController{
        }
 
        @RequestMapping(value={"/cl_dictionary/remove_varbindDict"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeVarbind(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+       public ModelAndView removeVarbind(HttpServletRequest request, HttpServletResponse response) throws IOException{
                try{
                        ObjectMapper mapper = new ObjectMapper();
                        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                        JsonNode root = mapper.readTree(request.getReader());
                        VarbindDictionary varbindDictionary = (VarbindDictionary)mapper.readValue(root.get("data").toString(), VarbindDictionary.class);
                        commonClassDao.delete(varbindDictionary);
-                       response.setCharacterEncoding("UTF-8");
-                       response.setContentType("application / json");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       response.setContentType(applicationJsonContentType);
+                       request.setCharacterEncoding(utf8);
 
                        PrintWriter out = response.getWriter();
 
@@ -1021,8 +1035,8 @@ public class ClosedLoopDictionaryController{
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
                        out.write(e.getMessage());
                }