Added Junits for Policy PAP-REST
[policy/engine.git] / ONAP-PAP-REST / src / main / java / org / onap / policy / pap / xacml / rest / controller / FirewallDictionaryController.java
index 3a4d7b7..0466deb 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP-PAP-REST
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@ package org.onap.policy.pap.xacml.rest.controller;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.net.UnknownHostException;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -46,14 +45,15 @@ import org.onap.policy.rest.jpa.FWTag;
 import org.onap.policy.rest.jpa.FWTagPicker;
 import org.onap.policy.rest.jpa.FirewallDictionaryList;
 import org.onap.policy.rest.jpa.GroupServiceList;
-import org.onap.policy.rest.jpa.PrefixList;
 import org.onap.policy.rest.jpa.PortList;
+import org.onap.policy.rest.jpa.PrefixList;
 import org.onap.policy.rest.jpa.ProtocolList;
 import org.onap.policy.rest.jpa.SecurityZone;
 import org.onap.policy.rest.jpa.ServiceList;
 import org.onap.policy.rest.jpa.TermList;
 import org.onap.policy.rest.jpa.UserInfo;
 import org.onap.policy.rest.jpa.Zone;
+import org.onap.policy.utils.PolicyUtils;
 import org.onap.policy.xacml.api.XACMLErrorConstants;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
@@ -95,7 +95,6 @@ public class FirewallDictionaryController {
        private static String termName = "termName";
        private static String userid = "userid";
        private static String tagPickerName = "tagPickerName";
-       private static String fwTagPickerDictionaryData = "fwTagPickerDictionaryData";
        private static String fwTagDictionaryDatas = "fwTagDictionaryDatas";
        
        
@@ -108,10 +107,11 @@ public class FirewallDictionaryController {
            commonClassDao = clDao;
        }
        
-       /*
-        * This is an empty constructor
-        */
-       public FirewallDictionaryController(){} 
+       public FirewallDictionaryController(){
+               /*
+                * This is an empty constructor
+                */
+       }       
 
        public UserInfo getUserInfo(String loginId){
                return (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId); 
@@ -166,10 +166,10 @@ public class FirewallDictionaryController {
                        JsonNode root = mapper.readTree(request.getReader());
                        PrefixList prefixList;
                        if (fromAPI) {
-                               prefixList = (PrefixList)mapper.readValue(root.get(dictionaryFields).toString(), PrefixList.class);
+                               prefixList = mapper.readValue(root.get(dictionaryFields).toString(), PrefixList.class);
 
                                //check if update operation or create, get id for data to be updated and update attributeData
-                               if ((update).equals(request.getParameter(operation))) {
+                               if (update.equals(request.getParameter(operation))) {
                                        List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(prefixList.getPrefixListName(), prefixListName, PrefixList.class);
                                        PrefixList data = (PrefixList) duplicateData.get(0);
                                        int id = data.getId();
@@ -181,7 +181,7 @@ public class FirewallDictionaryController {
                                        }
                                }
                        } else {
-                               prefixList = (PrefixList)mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
+                               prefixList = mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
                        }
                        if(prefixList.getId() == 0){
                                List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(prefixList.getPrefixListName(), prefixListName, PrefixList.class);
@@ -228,18 +228,18 @@ public class FirewallDictionaryController {
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
                return null;
        }
 
        @RequestMapping(value={"/fw_dictionary/remove_PrefixList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+       public void removePrefixListDictionary(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());
-                       PrefixList prefixList = (PrefixList)mapper.readValue(root.get("data").toString(), PrefixList.class);
+                       PrefixList prefixList = mapper.readValue(root.get("data").toString(), PrefixList.class);
                        commonClassDao.delete(prefixList);
                        response.setCharacterEncoding(utf8);
                        response.setContentType(applicationJsonContentType);
@@ -249,25 +249,23 @@ public class FirewallDictionaryController {
                        String responseString = mapper.writeValueAsString(commonClassDao.getData(PrefixList.class));
                        JSONObject j = new JSONObject("{prefixListDictionaryDatas: " + responseString + "}");
                        out.write(j.toString());
-                       return null;
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
-               return null;
        }
 
        @RequestMapping(value={"/fw_dictionary/validate_prefixList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView validatePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+       public void validatePrefixListDictionary(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());
-                       PrefixList prefixList = (PrefixList)mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
+                       PrefixList prefixList = mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
                        String responseValidation = successMessage;
                        try{
                                CIDR.newCIDR(prefixList.getPrefixListValue());
@@ -282,16 +280,14 @@ public class FirewallDictionaryController {
                        PrintWriter out = response.getWriter();
                        JSONObject j = new JSONObject("{result: " + responseValidation + "}");
                        out.write(j.toString());
-                       return null;
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
-               return null;
        }
 
        @RequestMapping(value={"/get_PortListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -320,7 +316,7 @@ public class FirewallDictionaryController {
                        ObjectMapper mapper = new ObjectMapper();
                        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                        JsonNode root = mapper.readTree(request.getReader());
-                       PortList portList = (PortList)mapper.readValue(root.get("portListDictionaryData").toString(), PortList.class);
+                       PortList portList = mapper.readValue(root.get("portListDictionaryData").toString(), PortList.class);
                        if(portList.getId() == 0){
                                List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(portList.getPortName(), "portName", PortList.class);
                                if(!duplicateData.isEmpty()){
@@ -353,18 +349,18 @@ public class FirewallDictionaryController {
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
                return null;
        }
 
        @RequestMapping(value={"/fw_dictionary/remove_PortList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removePortListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+       public void removePortListDictionary(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());
-                       PortList portList = (PortList)mapper.readValue(root.get("data").toString(), PortList.class);
+                       PortList portList = mapper.readValue(root.get("data").toString(), PortList.class);
                        commonClassDao.delete(portList);
                        response.setCharacterEncoding(utf8);
                        response.setContentType(applicationJsonContentType);
@@ -374,16 +370,14 @@ public class FirewallDictionaryController {
                        String responseString = mapper.writeValueAsString(commonClassDao.getData(PortList.class));
                        JSONObject j = new JSONObject("{portListDictionaryDatas: " + responseString + "}");
                        out.write(j.toString());
-                       return null;
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
-               return null;
        }
 
        @RequestMapping(value={"/get_ProtocolListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -434,7 +428,7 @@ public class FirewallDictionaryController {
                        JsonNode root = mapper.readTree(request.getReader());
                        ProtocolList protocolList;
                        if (fromAPI) {
-                               protocolList = (ProtocolList)mapper.readValue(root.get(dictionaryFields).toString(), ProtocolList.class);
+                               protocolList = mapper.readValue(root.get(dictionaryFields).toString(), ProtocolList.class);
 
                                //check if update operation or create, get id for data to be updated and update attributeData
                                if ((update).equals(request.getParameter(operation))) {
@@ -449,7 +443,7 @@ public class FirewallDictionaryController {
                                        }
                                }
                        } else {
-                               protocolList = (ProtocolList)mapper.readValue(root.get("protocolListDictionaryData").toString(), ProtocolList.class);
+                               protocolList = mapper.readValue(root.get("protocolListDictionaryData").toString(), ProtocolList.class);
                        }
                        if(protocolList.getId() == 0){
                                List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(protocolList.getProtocolName(), protocolName, ProtocolList.class);
@@ -496,18 +490,18 @@ public class FirewallDictionaryController {
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
                return null;
        }
 
        @RequestMapping(value={"/fw_dictionary/remove_protocol"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+       public void removeProtocolListDictionary(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());
-                       ProtocolList protocolList = (ProtocolList)mapper.readValue(root.get("data").toString(), ProtocolList.class);
+                       ProtocolList protocolList = mapper.readValue(root.get("data").toString(), ProtocolList.class);
                        commonClassDao.delete(protocolList);
                        response.setCharacterEncoding(utf8);
                        response.setContentType(applicationJsonContentType);
@@ -518,16 +512,14 @@ public class FirewallDictionaryController {
                        String responseString = mapper.writeValueAsString(commonClassDao.getData(ProtocolList.class));
                        JSONObject j = new JSONObject("{protocolListDictionaryDatas: " + responseString + "}");
                        out.write(j.toString());
-                       return null;
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
-               return null;
        }
 
        @RequestMapping(value={"/get_AddressGroupDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -579,8 +571,8 @@ public class FirewallDictionaryController {
                        AddressGroup addressGroup;
                        GridData gridData;
                        if (fromAPI) {
-                               addressGroup = (AddressGroup)mapper.readValue(root.get(dictionaryFields).toString(), AddressGroup.class);
-                               gridData = (GridData)mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
+                               addressGroup = mapper.readValue(root.get(dictionaryFields).toString(), AddressGroup.class);
+                               gridData = mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
 
                                if(!addressGroup.getGroupName().startsWith(groupNameStart)){
                                        String groupName = groupNameStart+addressGroup.getGroupName();
@@ -600,28 +592,28 @@ public class FirewallDictionaryController {
                                        }            
                                }
                        } else {
-                               addressGroup = (AddressGroup)mapper.readValue(root.get("addressGroupDictionaryData").toString(), AddressGroup.class);
-                               gridData = (GridData)mapper.readValue(root.get("addressGroupDictionaryData").toString(), GridData.class);
+                               addressGroup = mapper.readValue(root.get("addressGroupDictionaryData").toString(), AddressGroup.class);
+                               gridData = mapper.readValue(root.get("addressGroupDictionaryData").toString(), GridData.class);
                                if(!addressGroup.getGroupName().startsWith(groupNameStart)){
                                        String groupName = groupNameStart+addressGroup.getGroupName();
                                        addressGroup.setGroupName(groupName);
                                }
                        }
-                       String userValue = "";
+                       StringBuilder userValue = new StringBuilder();
                        int counter = 0;
                        if(!gridData.getAttributes().isEmpty()){
                                for(Object attribute : gridData.getAttributes()){
                                        if(attribute instanceof LinkedHashMap<?, ?>){
                                                String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
                                                if(counter>0){
-                                                       userValue = userValue + ",";
+                                                       userValue.append(",");
                                                }
-                                               userValue = userValue + key ;
+                                               userValue.append(key) ;
                                                counter ++;
                                        }
                                }
                        }
-                       addressGroup.setServiceList(userValue);
+                       addressGroup.setServiceList(userValue.toString());
                        if(addressGroup.getId() == 0){
                                List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(addressGroup.getGroupName(), "name", AddressGroup.class);
                                if(!duplicateData.isEmpty()){
@@ -666,18 +658,18 @@ public class FirewallDictionaryController {
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
                return null;
        }
 
        @RequestMapping(value={"/fw_dictionary/remove_AddressGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+       public void removeAddressGroupDictionary(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());
-                       AddressGroup addressGroup = (AddressGroup)mapper.readValue(root.get("data").toString(), AddressGroup.class);
+                       AddressGroup addressGroup = mapper.readValue(root.get("data").toString(), AddressGroup.class);
                        commonClassDao.delete(addressGroup);
                        response.setCharacterEncoding(utf8);
                        response.setContentType(applicationJsonContentType);
@@ -688,16 +680,14 @@ public class FirewallDictionaryController {
                        String responseString = mapper.writeValueAsString(commonClassDao.getData(AddressGroup.class));
                        JSONObject j = new JSONObject("{addressGroupDictionaryDatas: " + responseString + "}");
                        out.write(j.toString());
-                       return null;
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
-               return null;
        }
 
        @RequestMapping(value={"/get_ActionListDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -705,13 +695,8 @@ public class FirewallDictionaryController {
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
-                       List<Object> list = commonClassDao.getData(ActionList.class);
-                       List<String> dictList = new ArrayList<>();
-                       for(int i = 0; i < list.size(); i++){
-                               ActionList dict = (ActionList) list.get(i);
-                               dictList.add(dict.getActionName());
-                       }
-                       model.put("actionListDictionaryDatas", mapper.writeValueAsString(dictList));
+                       List<String> list = commonClassDao.getDataByColumn(ActionList.class, "actionName");
+                       model.put("actionListDictionaryDatas", mapper.writeValueAsString(list));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
                        response.getWriter().write(j.toString());
@@ -754,7 +739,7 @@ public class FirewallDictionaryController {
                        JsonNode root = mapper.readTree(request.getReader());
                        ActionList actionList;
                        if (fromAPI) {
-                               actionList = (ActionList)mapper.readValue(root.get(dictionaryFields).toString(), ActionList.class);
+                               actionList = mapper.readValue(root.get(dictionaryFields).toString(), ActionList.class);
 
                                //check if update operation or create, get id for data to be updated and update attributeData
                                if ((update).equals(request.getParameter(operation))) {
@@ -769,7 +754,7 @@ public class FirewallDictionaryController {
                                        }  
                                }
                        } else {
-                               actionList = (ActionList)mapper.readValue(root.get("actionListDictionaryData").toString(), ActionList.class);
+                               actionList = mapper.readValue(root.get("actionListDictionaryData").toString(), ActionList.class);
                        }
                        if(actionList.getId() == 0){
                                List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(actionList.getActionName(), "actionName", ActionList.class);
@@ -816,18 +801,18 @@ public class FirewallDictionaryController {
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
                return null;
        }
 
        @RequestMapping(value={"/fw_dictionary/remove_ActionList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+       public void removeActionListDictionary(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());
-                       ActionList actionList = (ActionList)mapper.readValue(root.get("data").toString(), ActionList.class);
+                       ActionList actionList = mapper.readValue(root.get("data").toString(), ActionList.class);
                        commonClassDao.delete(actionList);
                        response.setCharacterEncoding(utf8);
                        response.setContentType(applicationJsonContentType);
@@ -837,16 +822,14 @@ public class FirewallDictionaryController {
                        String responseString = mapper.writeValueAsString(commonClassDao.getData(ActionList.class));
                        JSONObject j = new JSONObject("{actionListDictionaryDatas: " + responseString + "}");
                        out.write(j.toString());
-                       return null;
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
-               return null;
        }
 
        @RequestMapping(value={"/get_ServiceGroupData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -898,8 +881,8 @@ public class FirewallDictionaryController {
                        GroupServiceList groupServiceList;
                        GridData gridData;
                        if (fromAPI) {
-                               groupServiceList = (GroupServiceList)mapper.readValue(root.get(dictionaryFields).toString(), GroupServiceList.class);
-                               gridData = (GridData)mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
+                               groupServiceList = mapper.readValue(root.get(dictionaryFields).toString(), GroupServiceList.class);
+                               gridData = mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
 
                                if(!groupServiceList.getGroupName().startsWith(groupNameStart)){
                                        String groupName = groupNameStart+groupServiceList.getGroupName();
@@ -919,28 +902,28 @@ public class FirewallDictionaryController {
                                        }   
                                }
                        } else {
-                               groupServiceList = (GroupServiceList)mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GroupServiceList.class);
-                               gridData = (GridData)mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GridData.class);
+                               groupServiceList = mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GroupServiceList.class);
+                               gridData = mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GridData.class);
                        }
                        if(!groupServiceList.getGroupName().startsWith(groupNameStart)){
                                String groupName = groupNameStart+groupServiceList.getGroupName();
                                groupServiceList.setGroupName(groupName);
                        }
-                       String userValue = "";
+                       StringBuilder userValue = new StringBuilder();
                        int counter = 0;
                        if(!gridData.getAttributes().isEmpty()){
                                for(Object attribute : gridData.getAttributes()){
                                        if(attribute instanceof LinkedHashMap<?, ?>){
                                                String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
                                                if(counter>0){
-                                                       userValue = userValue + ",";
+                                                       userValue.append(",");
                                                }
-                                               userValue = userValue + key ;
+                                               userValue.append(key);
                                                counter ++;
                                        }
                                }
                        }
-                       groupServiceList.setServiceList(userValue);
+                       groupServiceList.setServiceList(userValue.toString());
                        if(groupServiceList.getId() == 0){
                                List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(groupServiceList.getGroupName(), "name", GroupServiceList.class);
                                if(!duplicateData.isEmpty()){
@@ -986,18 +969,18 @@ public class FirewallDictionaryController {
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
                return null;
        }
 
        @RequestMapping(value={"/fw_dictionary/remove_serviceGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+       public void removeServiceGroupDictionary(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());
-                       GroupServiceList groupServiceList = (GroupServiceList)mapper.readValue(root.get("data").toString(), GroupServiceList.class);
+                       GroupServiceList groupServiceList = mapper.readValue(root.get("data").toString(), GroupServiceList.class);
                        commonClassDao.delete(groupServiceList);
                        response.setCharacterEncoding(utf8);
                        response.setContentType(applicationJsonContentType);
@@ -1008,17 +991,14 @@ public class FirewallDictionaryController {
                        String responseString = mapper.writeValueAsString(commonClassDao.getData(GroupServiceList.class));
                        JSONObject j = new JSONObject("{serviceGroupDictionaryDatas: " + responseString + "}");
                        out.write(j.toString());
-
-                       return null;
                }
                catch (Exception e){
                        LOGGER.error(e);
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
-               return null;
        }
 
        @RequestMapping(value={"/get_SecurityZoneDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -1069,7 +1049,7 @@ public class FirewallDictionaryController {
                        JsonNode root = mapper.readTree(request.getReader());
                        SecurityZone securityZone;
                        if (fromAPI) {
-                               securityZone = (SecurityZone)mapper.readValue(root.get(dictionaryFields).toString(), SecurityZone.class);
+                               securityZone = mapper.readValue(root.get(dictionaryFields).toString(), SecurityZone.class);
 
                                //check if update operation or create, get id for data to be updated and update attributeData
                                if ((update).equals(request.getParameter(operation))) {
@@ -1084,7 +1064,7 @@ public class FirewallDictionaryController {
                                        }               
                                }
                        } else {
-                               securityZone = (SecurityZone)mapper.readValue(root.get("securityZoneDictionaryData").toString(), SecurityZone.class);
+                               securityZone = mapper.readValue(root.get("securityZoneDictionaryData").toString(), SecurityZone.class);
                        }
                        if(securityZone.getId() == 0){
                                List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(securityZone.getZoneName(), zoneName, SecurityZone.class);
@@ -1132,18 +1112,18 @@ public class FirewallDictionaryController {
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
                return null;
        }
 
        @RequestMapping(value={"/fw_dictionary/remove_securityZone"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
+       public void removeSecurityZoneDictionary(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());
-                       SecurityZone securityZone = (SecurityZone)mapper.readValue(root.get("data").toString(), SecurityZone.class);
+                       SecurityZone securityZone = mapper.readValue(root.get("data").toString(), SecurityZone.class);
                        commonClassDao.delete(securityZone);
                        response.setCharacterEncoding(utf8);
                        response.setContentType(applicationJsonContentType);
@@ -1154,17 +1134,14 @@ public class FirewallDictionaryController {
                        String responseString = mapper.writeValueAsString(commonClassDao.getData(SecurityZone.class));
                        JSONObject j = new JSONObject("{securityZoneDictionaryDatas: " + responseString + "}");
                        out.write(j.toString());
-
-                       return null;
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
-               return null;
        }
 
 
@@ -1217,8 +1194,8 @@ public class FirewallDictionaryController {
                        ServiceList serviceList;
                        GridData serviceListGridData;
                        if (fromAPI) {
-                               serviceList = (ServiceList)mapper.readValue(root.get(dictionaryFields).toString(), ServiceList.class);
-                               serviceListGridData = (GridData)mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
+                               serviceList = mapper.readValue(root.get(dictionaryFields).toString(), ServiceList.class);
+                               serviceListGridData = mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
 
                                //check if update operation or create, get id for data to be updated and update attributeData
                                if ((update).equals(request.getParameter(operation))) {
@@ -1233,39 +1210,39 @@ public class FirewallDictionaryController {
                                        }
                                }
                        }else{
-                               serviceList = (ServiceList)mapper.readValue(root.get("serviceListDictionaryData").toString(), ServiceList.class);
-                               serviceListGridData = (GridData)mapper.readValue(root.get("serviceListDictionaryData").toString(), GridData.class);
+                               serviceList = mapper.readValue(root.get("serviceListDictionaryData").toString(), ServiceList.class);
+                               serviceListGridData = mapper.readValue(root.get("serviceListDictionaryData").toString(), GridData.class);
                        }
-                       String tcpValue = "";
+                       StringBuilder tcpValue = new StringBuilder();
                        int counter = 0;
                        if(!serviceListGridData.getTransportProtocols().isEmpty()){
                                for(Object attribute : serviceListGridData.getTransportProtocols()){
                                        if(attribute instanceof LinkedHashMap<?, ?>){
                                                String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
                                                if(counter>0){
-                                                       tcpValue = tcpValue + ",";
+                                                       tcpValue.append(",");
                                                }
-                                               tcpValue = tcpValue + key ;
+                                               tcpValue.append(key);
                                                counter ++;
                                        }
                                }
                        }
-                       serviceList.setServiceTransProtocol(tcpValue);
-                       String appValue = "";
+                       serviceList.setServiceTransProtocol(tcpValue.toString());
+                       StringBuilder appValue = new StringBuilder();
                        int counter1 = 0;
                        if(!serviceListGridData.getAppProtocols().isEmpty()){
                                for(Object attribute : serviceListGridData.getAppProtocols()){
                                        if(attribute instanceof LinkedHashMap<?, ?>){
                                                String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
                                                if(counter1>0){
-                                                       appValue = appValue + ",";
+                                                       appValue.append(",");
                                                }
-                                               appValue = appValue + key ;
+                                               appValue.append(key);
                                                counter1 ++;
                                        }
                                }
                        }
-                       serviceList.setServiceAppProtocol(appValue);
+                       serviceList.setServiceAppProtocol(appValue.toString());
                        serviceList.setServiceType("SERVICE");
                        if(serviceList.getId() == 0){
                                List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(serviceList.getServiceName(), serviceName, ServiceList.class);
@@ -1312,19 +1289,18 @@ public class FirewallDictionaryController {
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
-
                return null;
        }
 
        @RequestMapping(value={"/fw_dictionary/remove_serviceList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
+       public void removeServiceListDictionary(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());
-                       ServiceList serviceList = (ServiceList)mapper.readValue(root.get("data").toString(), ServiceList.class);
+                       ServiceList serviceList = mapper.readValue(root.get("data").toString(), ServiceList.class);
                        commonClassDao.delete(serviceList);
                        response.setCharacterEncoding(utf8);
                        response.setContentType(applicationJsonContentType);
@@ -1335,17 +1311,14 @@ public class FirewallDictionaryController {
                        String responseString = mapper.writeValueAsString(commonClassDao.getData(ServiceList.class));
                        JSONObject j = new JSONObject("{serviceListDictionaryDatas: " + responseString + "}");
                        out.write(j.toString());
-
-                       return null;
                }
                catch (Exception e){
                        LOGGER.error(e);
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
-               return null;
        }
 
        @RequestMapping(value={"/get_ZoneData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -1394,7 +1367,7 @@ public class FirewallDictionaryController {
                        JsonNode root = mapper.readTree(request.getReader());
                        Zone zone;
                        if (fromAPI) {
-                               zone = (Zone)mapper.readValue(root.get(dictionaryFields).toString(), Zone.class);
+                               zone = mapper.readValue(root.get(dictionaryFields).toString(), Zone.class);
 
                                //check if update operation or create, get id for data to be updated and update attributeData
                                if ((update).equals(request.getParameter(operation))) {
@@ -1409,7 +1382,7 @@ public class FirewallDictionaryController {
                                        }
                                }
                        } else {
-                               zone = (Zone)mapper.readValue(root.get("zoneDictionaryData").toString(), Zone.class);
+                               zone = mapper.readValue(root.get("zoneDictionaryData").toString(), Zone.class);
                        }
                        if(zone.getId() == 0){
                                List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(zone.getZoneName(), zoneName, Zone.class);
@@ -1456,18 +1429,18 @@ public class FirewallDictionaryController {
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
                return null;
        }
 
        @RequestMapping(value={"/fw_dictionary/remove_zone"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+       public void removeZoneDictionary(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());
-                       Zone zone = (Zone)mapper.readValue(root.get("data").toString(), Zone.class);
+                       Zone zone = mapper.readValue(root.get("data").toString(), Zone.class);
                        commonClassDao.delete(zone);
                        response.setCharacterEncoding(utf8);
                        response.setContentType(applicationJsonContentType);
@@ -1478,17 +1451,14 @@ public class FirewallDictionaryController {
                        String responseString = mapper.writeValueAsString(commonClassDao.getData(Zone.class));
                        JSONObject j = new JSONObject("{zoneDictionaryDatas: " + responseString + "}");
                        out.write(j.toString());
-
-                       return null;
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
-               return null;
        }
 
        @RequestMapping(value={"/get_TermListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -1541,8 +1511,8 @@ public class FirewallDictionaryController {
                        TermListData termListDatas;
                        String userId = null;
                        if (fromAPI) {
-                               termList = (TermList)mapper.readValue(root.get(dictionaryFields).toString(), TermList.class);
-                               termListDatas = (TermListData)mapper.readValue(root.get(dictionaryFields).toString(), TermListData.class);
+                               termList = mapper.readValue(root.get(dictionaryFields).toString(), TermList.class);
+                               termListDatas = mapper.readValue(root.get(dictionaryFields).toString(), TermListData.class);
                                userId = "API";
 
                                //check if update operation or create, get id for data to be updated and update attributeData
@@ -1559,121 +1529,121 @@ public class FirewallDictionaryController {
                                        termList.setUserCreatedBy(this.getUserInfo(userId));
                                }
                        } else {
-                               termList = (TermList)mapper.readValue(root.get("termListDictionaryData").toString(), TermList.class);
-                               termListDatas = (TermListData)mapper.readValue(root.get("termListDictionaryData").toString(), TermListData.class);
+                               termList = mapper.readValue(root.get("termListDictionaryData").toString(), TermList.class);
+                               termListDatas = mapper.readValue(root.get("termListDictionaryData").toString(), TermListData.class);
                                userId = root.get(userid).textValue();
                        }
-                       String fromZoneValue = "";
+                       StringBuilder fromZoneValue = new StringBuilder();
                        int counter = 0;
                        if(!termListDatas.getFromZoneDatas().isEmpty()){
                                for(Object fromZone : termListDatas.getFromZoneDatas()){
                                        if(fromZone instanceof LinkedHashMap<?, ?>){
                                                String key = ((LinkedHashMap<?, ?>) fromZone).get(option).toString();
                                                if(counter>0){
-                                                       fromZoneValue = fromZoneValue + ",";
+                                                       fromZoneValue.append(",");
                                                }
-                                               fromZoneValue = fromZoneValue + key ;
+                                               fromZoneValue.append(key);
                                                counter ++;
                                        }
                                }
                        }
-                       termList.setFromZones(fromZoneValue);
+                       termList.setFromZones(fromZoneValue.toString());
 
-                       String toZoneValue = "";
+                       StringBuilder toZoneValue = new StringBuilder();
                        int toZonecounter = 0;
                        if(!termListDatas.getToZoneDatas().isEmpty()){
                                for(Object toZone : termListDatas.getToZoneDatas()){
                                        if(toZone instanceof LinkedHashMap<?, ?>){
                                                String key = ((LinkedHashMap<?, ?>) toZone).get(option).toString();
                                                if(toZonecounter>0){
-                                                       toZoneValue = toZoneValue + ",";
+                                                       toZoneValue.append(",");
                                                }
-                                               toZoneValue = toZoneValue + key ;
+                                               toZoneValue.append(key);
                                                toZonecounter ++;
                                        }
                                }
                        }
-                       termList.setToZones(toZoneValue);
+                       termList.setToZones(toZoneValue.toString());
 
-                       String srcListValues = "";
+                       StringBuilder srcListValues = new StringBuilder();
                        int srcListcounter = 0;
                        if(!termListDatas.getSourceListDatas().isEmpty()){
                                for(Object srcList : termListDatas.getSourceListDatas()){
                                        if(srcList instanceof LinkedHashMap<?, ?>){
                                                String key = ((LinkedHashMap<?, ?>) srcList).get(option).toString();
                                                if(srcListcounter>0){
-                                                       srcListValues = srcListValues + ",";
+                                                       srcListValues.append(",");
                                                }
-                                               srcListValues = srcListValues + key ;
+                                               srcListValues.append(key);
                                                srcListcounter ++;
                                        }
                                }
                        }
-                       termList.setSrcIPList(srcListValues);
+                       termList.setSrcIPList(srcListValues.toString());
 
-                       String desListValues = "";
+                       StringBuilder desListValues = new StringBuilder();
                        int destListcounter = 0;
                        if(!termListDatas.getDestinationListDatas().isEmpty()){
                                for(Object desList : termListDatas.getDestinationListDatas()){
                                        if(desList instanceof LinkedHashMap<?, ?>){
                                                String key = ((LinkedHashMap<?, ?>) desList).get(option).toString();
                                                if(destListcounter>0){
-                                                       desListValues = desListValues + ",";
+                                                       desListValues.append(",");
                                                }
-                                               desListValues = desListValues + key ;
+                                               desListValues.append(key);
                                                destListcounter ++;
                                        }
                                }
                        }
-                       termList.setDestIPList(desListValues);
+                       termList.setDestIPList(desListValues.toString());
 
-                       String srcSerValue = "";
+                       StringBuilder srcSerValue = new StringBuilder();
                        int srcSercounter = 0;
                        if(!termListDatas.getSourceServiceDatas().isEmpty()){
                                for(Object srcSrc : termListDatas.getSourceServiceDatas()){
                                        if(srcSrc instanceof LinkedHashMap<?, ?>){
                                                String key = ((LinkedHashMap<?, ?>) srcSrc).get(option).toString();
                                                if(srcSercounter>0){
-                                                       srcSerValue = srcSerValue + ",";
+                                                       srcSerValue.append(",");
                                                }
-                                               srcSerValue = srcSerValue + key ;
+                                               srcSerValue.append(key);
                                                srcSercounter ++;
                                        }
                                }
                        }
-                       termList.setSrcPortList(srcSerValue);
+                       termList.setSrcPortList(srcSerValue.toString());
 
-                       String desSrcValue = "";
+                       StringBuilder desSrcValue = new StringBuilder();
                        int desSrccounter = 0;
                        if(!termListDatas.getDestinationServiceDatas().isEmpty()){
                                for(Object desSrc : termListDatas.getDestinationServiceDatas()){
                                        if(desSrc instanceof LinkedHashMap<?, ?>){
                                                String key = ((LinkedHashMap<?, ?>) desSrc).get(option).toString();
                                                if(desSrccounter>0){
-                                                       desSrcValue = desSrcValue + ",";
+                                                       desSrcValue.append(",");
                                                }
-                                               desSrcValue = desSrcValue + key ;
+                                               desSrcValue.append(key);
                                                desSrccounter ++;
                                        }
                                }
                        }
-                       termList.setDestPortList(desSrcValue);
+                       termList.setDestPortList(desSrcValue.toString());
 
-                       String actionValue = "";
+                       StringBuilder actionValue = new StringBuilder();
                        int actioncounter = 0;
                        if(!termListDatas.getActionListDatas().isEmpty()){
                                for(Object actionList : termListDatas.getActionListDatas()){
                                        if(actionList instanceof LinkedHashMap<?, ?>){
                                                String key = ((LinkedHashMap<?, ?>) actionList).get(option).toString();
                                                if(actioncounter>0){
-                                                       actionValue = actionValue + ",";
+                                                       actionValue.append(",");
                                                }
-                                               actionValue = actionValue + key ;
+                                               actionValue.append(key);
                                                actioncounter ++;
                                        }
                                }
                        }
-                       termList.setAction(actionValue);
+                       termList.setAction(actionValue.toString());
 
                        if(termList.getId() == 0){
                                List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(termList.getTermName(), termName, TermList.class);
@@ -1682,11 +1652,13 @@ public class FirewallDictionaryController {
                                }else{
                                        termList.setUserCreatedBy(this.getUserInfo(userId));
                                        termList.setUserModifiedBy(this.getUserInfo(userId));
+                                       termList.setCreatedDate(new Date());
                                        commonClassDao.save(termList);
                                }
                        }else{
                                if(!isFakeUpdate) {
                                        termList.setUserModifiedBy(this.getUserInfo(userId));
+                                       termList.setModifiedDate(new Date());
                                        commonClassDao.update(termList); 
                                }
                        } 
@@ -1723,18 +1695,18 @@ public class FirewallDictionaryController {
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
                return null;
        }
 
        @RequestMapping(value={"/fw_dictionary/remove_termList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+       public void removeTermListDictionary(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());
-                       TermList termList = (TermList)mapper.readValue(root.get("data").toString(), TermList.class);
+                       TermList termList = mapper.readValue(root.get("data").toString(), TermList.class);
                        commonClassDao.delete(termList);
                        response.setCharacterEncoding(utf8);
                        response.setContentType(applicationJsonContentType);
@@ -1745,17 +1717,14 @@ public class FirewallDictionaryController {
                        String responseString = mapper.writeValueAsString(commonClassDao.getData(TermList.class));
                        JSONObject j = new JSONObject("{termListDictionaryDatas: " + responseString + "}");
                        out.write(j.toString());
-
-                       return null;
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
-               return null;
        }
        //ParentList Dictionary Data
        @RequestMapping(value={"/get_FWDictionaryListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
@@ -1799,38 +1768,38 @@ public class FirewallDictionaryController {
                        ObjectMapper mapper = new ObjectMapper();
                        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                        JsonNode root = mapper.readTree(request.getReader());
-                       FirewallDictionaryList fwDictList = (FirewallDictionaryList)mapper.readValue(root.get("fwDictListDictionaryData").toString(), FirewallDictionaryList.class);
-                       GridData gridData = (GridData)mapper.readValue(root.get("fwDictListDictionaryData").toString(), GridData.class);
-                       String userSLValue = "";
+                       FirewallDictionaryList fwDictList = mapper.readValue(root.get("fwDictListDictionaryData").toString(), FirewallDictionaryList.class);
+                       GridData gridData = mapper.readValue(root.get("fwDictListDictionaryData").toString(), GridData.class);
+                       StringBuilder userSLValue = new StringBuilder();
                        int slcounter = 0;
                        if(!gridData.getAttributes().isEmpty()){
                                for(Object attribute : gridData.getAttributes()){
                                        if(attribute instanceof LinkedHashMap<?, ?>){
                                                String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
                                                if(slcounter>0){
-                                                       userSLValue = userSLValue + ",";
+                                                       userSLValue.append(",");
                                                }
-                                               userSLValue = userSLValue + key ;
+                                               userSLValue.append(key);
                                                slcounter ++;
                                        }
                                }
                        }
-                       fwDictList.setServiceList(userSLValue);
-                       String userALValue = "";
+                       fwDictList.setServiceList(userSLValue.toString());
+                       StringBuilder userALValue = new StringBuilder();
                        int alcounter = 0;
                        if(!gridData.getAlAttributes().isEmpty()){
                                for(Object attribute : gridData.getAlAttributes()){
                                        if(attribute instanceof LinkedHashMap<?, ?>){
                                                String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
                                                if(alcounter>0){
-                                                       userALValue = userALValue + ",";
+                                                       userALValue.append(",");
                                                }
-                                               userALValue = userALValue + key ;
+                                               userALValue.append(key);
                                                alcounter ++;
                                        }
                                }
                        }
-                       fwDictList.setAddressList(userALValue);
+                       fwDictList.setAddressList(userALValue.toString());
                        if(fwDictList.getId() == 0){
                                List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(fwDictList.getParentItemName(), "parentItemName", FirewallDictionaryList.class);
                                if(!duplicateData.isEmpty()){
@@ -1853,9 +1822,7 @@ public class FirewallDictionaryController {
                                responseString = mapper.writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class));
                        }
                        JSONObject j = new JSONObject("{fwDictListDictionaryDatas: " + responseString + "}");
-
                        out.write(j.toString());
-
                        return null;
                }
                catch (Exception e){
@@ -1863,18 +1830,18 @@ public class FirewallDictionaryController {
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
                return null;
        }
 
        @RequestMapping(value={"/fw_dictionary/remove_FWDictionaryList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeFWDictionaryListy(HttpServletRequest request, HttpServletResponse response) throws IOException {
+       public void removeFWDictionaryList(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());
-                       FirewallDictionaryList fwDictList = (FirewallDictionaryList)mapper.readValue(root.get("data").toString(), FirewallDictionaryList.class);
+                       FirewallDictionaryList fwDictList = mapper.readValue(root.get("data").toString(), FirewallDictionaryList.class);
                        commonClassDao.delete(fwDictList);
                        response.setCharacterEncoding(utf8);
                        response.setContentType(applicationJsonContentType);
@@ -1885,17 +1852,14 @@ public class FirewallDictionaryController {
                        String responseString = mapper.writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class));
                        JSONObject j = new JSONObject("{fwDictListDictionaryDatas: " + responseString + "}");
                        out.write(j.toString());
-
-                       return null;
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
-               return null;
        }
 
 
@@ -1922,6 +1886,8 @@ public class FirewallDictionaryController {
                        model.put("fwTagPickerDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(FWTagPicker.class)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
+                       response.addHeader(successMapKey, successMessage); 
+                       response.addHeader(operation, getDictionary);
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
@@ -1934,55 +1900,51 @@ public class FirewallDictionaryController {
                try {
                        boolean duplicateflag = false;
                        boolean fromAPI = false;
-                       if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
+                       if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase (request.getParameter(apiflag))) {
                                fromAPI = true;
                        }
-
                        ObjectMapper mapper = new ObjectMapper();
                        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                        JsonNode root = mapper.readTree(request.getReader());
-
-
                        FWTagPicker fwTagPicker;
-                       TagGridValues data;
-                       String userId = null;
+                       
+                       String userId = "";
                        if (fromAPI) {
-                               fwTagPicker = (FWTagPicker)mapper.readValue(root.get(fwTagPickerDictionaryData).toString(), FWTagPicker.class);
-                               data = (TagGridValues)mapper.readValue(root.get(fwTagPickerDictionaryData).toString(), TagGridValues.class);
+                               fwTagPicker = mapper.readValue(root.get(dictionaryFields).toString(), FWTagPicker.class);
                                userId = "API";
-
                                //check if update operation or create, get id for data to be updated and update attributeData
                                if ((update).equals(request.getParameter(operation))) {
                                        List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(fwTagPicker.getTagPickerName(), tagPickerName, FWTagPicker.class);
+                                       int id = 0;
                                        FWTagPicker dbdata = (FWTagPicker) duplicateData.get(0);
-                                       int id = dbdata.getId();
+                                       id = dbdata.getId();
                                        fwTagPicker.setId(id);
                                        fwTagPicker.setUserCreatedBy(this.getUserInfo(userId));
                                }
                        } else {
-
-                               fwTagPicker = (FWTagPicker)mapper.readValue(root.get(fwTagPickerDictionaryData).toString(), FWTagPicker.class);
-                               data = (TagGridValues)mapper.readValue(root.get(fwTagPickerDictionaryData).toString(), TagGridValues.class);
+                               TagGridValues data;
+                               fwTagPicker = mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), FWTagPicker.class);
+                               data = mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), TagGridValues.class);
                                userId = root.get(userid).textValue();
-                       }
-
-                       String header = "";
-                       int counter = 0;
-                       if(!data.getTags().isEmpty()){
-                               for(Object attribute : data.getTags()){
-                                       if(attribute instanceof LinkedHashMap<?, ?>){
-                                               String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
-                                               String value = ((LinkedHashMap<?, ?>) attribute).get("number").toString();
-                                               if(counter>0){
-                                                       header = header + "#";
+                               
+                               StringBuilder header = new StringBuilder();
+                               int counter = 0;
+                               if(!data.getTags().isEmpty()){
+                                       for(Object attribute : data.getTags()){
+                                               if(attribute instanceof LinkedHashMap<?, ?>){
+                                                       String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
+                                                       String value = ((LinkedHashMap<?, ?>) attribute).get("number").toString();
+                                                       if(counter>0){
+                                                               header.append("#");
+                                                       }
+                                                       header.append(key+":"+value);
+                                                       counter ++;
                                                }
-                                               header = header + key + ":";
-                                               header = header + value;
-                                               counter ++;
                                        }
                                }
+                               fwTagPicker.setTagValues(header.toString());
                        }
-                       fwTagPicker.setTagValues(header);
+                       
                        if(fwTagPicker.getId() == 0){
                                List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(fwTagPicker.getTagPickerName(), tagPickerName, FWTagPicker.class);
                                if(!duplicateData.isEmpty()){
@@ -1997,7 +1959,6 @@ public class FirewallDictionaryController {
                                fwTagPicker.setModifiedDate(new Date());
                                commonClassDao.update(fwTagPicker); 
                        } 
-
                        String responseString = "";
                        if(duplicateflag){
                                responseString = duplicateResponseString;
@@ -2028,18 +1989,18 @@ public class FirewallDictionaryController {
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
                return null;
        }
 
        @RequestMapping(value={"/fw_dictionary/remove_tagPicker"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeFirewallTagPickerDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
+       public void removeFirewallTagPickerDictionary(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());
-                       FWTagPicker fwTagPicker = (FWTagPicker)mapper.readValue(root.get("data").toString(), FWTagPicker.class);
+                       FWTagPicker fwTagPicker = mapper.readValue(root.get("data").toString(), FWTagPicker.class);
                        commonClassDao.delete(fwTagPicker);
                        response.setCharacterEncoding(utf8);
                        response.setContentType(applicationJsonContentType);
@@ -2049,40 +2010,39 @@ public class FirewallDictionaryController {
                        String responseString = mapper.writeValueAsString(commonClassDao.getData(FWTagPicker.class));
                        JSONObject j = new JSONObject("{fwTagPickerDictionaryDatas: " + responseString + "}");
                        out.write(j.toString());
-                       return null;
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
-               return null;
        }
 
-
-       @RequestMapping(value={"/get_TagNameByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getTagNameEntityDataByName(HttpServletResponse response){
+       @RequestMapping(value={"/get_TagListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
+       public void getTagDictionaryEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
-                       model.put(fwTagDictionaryDatas, mapper.writeValueAsString(commonClassDao.getDataByColumn(FWTag.class, "fwTagName")));
+                       model.put(fwTagDictionaryDatas, mapper.writeValueAsString(commonClassDao.getData(FWTag.class)));        
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
+                       response.addHeader(successMapKey, successMessage); 
+                       response.addHeader(operation, getDictionary);
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                }
        }
-
-       @RequestMapping(value={"/get_TagListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getTagDictionaryEntityData(HttpServletResponse response){
+       
+       @RequestMapping(value={"/get_TagNameByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
+       public void getTagNameEntityDataByName(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
-                       model.put(fwTagDictionaryDatas, mapper.writeValueAsString(commonClassDao.getData(FWTag.class)));
+                       model.put("fwTagDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(FWTag.class, "fwTagName")));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
                        response.getWriter().write(j.toString());
@@ -2092,6 +2052,7 @@ public class FirewallDictionaryController {
                }
        }
 
+
        @RequestMapping(value={"/fw_dictionary/save_fwTag"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
        public ModelAndView saveFirewallTagDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
                try {
@@ -2100,50 +2061,47 @@ public class FirewallDictionaryController {
                        if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
                                fromAPI = true;
                        }
-
                        ObjectMapper mapper = new ObjectMapper();
                        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                        JsonNode root = mapper.readTree(request.getReader());
-
-
                        FWTag fwTag;
-                       TagGridValues tagGridValues;
-                       String userId = null;
+                       
+                       String userId="";
                        if (fromAPI) {
-                               fwTag = (FWTag)mapper.readValue(root.get(fwTagDictionaryDatas).toString(), FWTag.class);
-                               tagGridValues = (TagGridValues)mapper.readValue(root.get(fwTagDictionaryDatas).toString(), TagGridValues.class);
+                               fwTag = mapper.readValue(root.get(dictionaryFields).toString(), FWTag.class);
                                userId = "API";
-
                                //check if update operation or create, get id for data to be updated and update attributeData
-                               if ((update).equals(request.getParameter(operation))) {
-                                       List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(fwTag.getFwTagName(), "tagName", FWTag.class);
+                               if (update.equals(request.getParameter(operation))) {
+                                       List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(fwTag.getFwTagName(), "fwTagName", FWTag.class);
+                                       int id = 0;
                                        FWTag data = (FWTag) duplicateData.get(0);
-                                       int id = data.getId();
+                                       id = data.getId();
                                        fwTag.setId(id);
                                        fwTag.setUserCreatedBy(this.getUserInfo(userId));
-
                                }
                        } else {
-                               fwTag = (FWTag)mapper.readValue(root.get("fwTagDictionaryData").toString(), FWTag.class);
-                               tagGridValues = (TagGridValues)mapper.readValue(root.get("fwTagDictionaryData").toString(), TagGridValues.class);
+                               TagGridValues tagGridValues;
+                               fwTag = mapper.readValue(root.get("fwTagDictionaryData").toString(), FWTag.class);
+                               tagGridValues = mapper.readValue(root.get("fwTagDictionaryData").toString(), TagGridValues.class);
                                userId = root.get(userid).textValue();
-                       }
-
-                       String userValue = "";
-                       int counter = 0;
-                       if(!tagGridValues.getTags().isEmpty()){
-                               for(Object attribute : tagGridValues.getTags()){
-                                       if(attribute instanceof LinkedHashMap<?, ?>){
-                                               String key = ((LinkedHashMap<?, ?>) attribute).get("tags").toString();
-                                               if(counter>0){
-                                                       userValue = userValue + ",";
+                               
+                               StringBuilder userValue = new StringBuilder();
+                               int counter = 0;
+                               if(!tagGridValues.getTags().isEmpty()){
+                                       for(Object attribute : tagGridValues.getTags()){
+                                               if(attribute instanceof LinkedHashMap<?, ?>){
+                                                       String key = ((LinkedHashMap<?, ?>) attribute).get("tags").toString();
+                                                       if(counter>0){
+                                                               userValue.append(",");
+                                                       }
+                                                       userValue.append(key);
+                                                       counter ++;
                                                }
-                                               userValue = userValue + key ;
-                                               counter ++;
                                        }
                                }
+                               fwTag.setTagValues(userValue.toString());
                        }
-                       fwTag.setTagValues(userValue);
+                       
                        if(fwTag.getId() == 0){
                                List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(fwTag.getFwTagName(), "fwTagName", FWTag.class);
                                if(!duplicateData.isEmpty()){
@@ -2152,19 +2110,18 @@ public class FirewallDictionaryController {
                                        fwTag.setUserCreatedBy(this.getUserInfo(userId));
                                        fwTag.setUserModifiedBy(this.getUserInfo(userId));
                                        commonClassDao.save(fwTag);
-                               }   
+                               }               
                        }else{
                                fwTag.setUserModifiedBy(this.getUserInfo(userId));
-                               fwTag.setModifiedDate(new Date());
                                commonClassDao.update(fwTag); 
                        } 
-
                        String responseString = "";
                        if(duplicateflag){
-                               responseString = duplicateResponseString;
+                               responseString = "Duplicate";
                        }else{
-                               responseString =  mapper.writeValueAsString(commonClassDao.getData(FWTag.class));
+                               responseString = mapper.writeValueAsString(commonClassDao.getData(FWTag.class));
                        }
+
                        if (fromAPI) {
                                if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
                                        responseString = successMsg;
@@ -2173,7 +2130,6 @@ public class FirewallDictionaryController {
                                result.setViewName(responseString);
                                return result;
                        } else {
-
                                response.setCharacterEncoding(utf8);
                                response.setContentType(applicationJsonContentType);
                                request.setCharacterEncoding(utf8);
@@ -2189,18 +2145,18 @@ public class FirewallDictionaryController {
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
                return null;
        }
 
        @RequestMapping(value={"/fw_dictionary/remove_tagList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeFirewallTagDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
+       public void removeFirewallTagDictionary(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());
-                       FWTag fwTag = (FWTag)mapper.readValue(root.get("data").toString(), FWTag.class);
+                       FWTag fwTag = mapper.readValue(root.get("data").toString(), FWTag.class);
                        commonClassDao.delete(fwTag);
                        response.setCharacterEncoding(utf8);
                        response.setContentType(applicationJsonContentType);
@@ -2211,17 +2167,14 @@ public class FirewallDictionaryController {
                        String responseString = mapper.writeValueAsString(commonClassDao.getData(FWTag.class));
                        JSONObject j = new JSONObject("{fwTagDictionaryDatas: " + responseString + "}");
                        out.write(j.toString());
-
-                       return null;
                }
                catch (Exception e){
                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
                        response.setCharacterEncoding(utf8);
                        request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
-               return null;
        }
 }