MS Model Input Validation
[policy/engine.git] / ONAP-PAP-REST / src / main / java / org / onap / policy / pap / xacml / rest / controller / MicroServiceDictionaryController.java
index 526e286..ff62080 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.
@@ -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.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -48,6 +47,7 @@ import org.onap.policy.rest.jpa.MicroServiceModels;
 import org.onap.policy.rest.jpa.UserInfo;
 import org.onap.policy.rest.util.MSAttributeObject;
 import org.onap.policy.rest.util.MSModelUtils;
+import org.onap.policy.utils.PolicyUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.stereotype.Controller;
@@ -64,40 +64,52 @@ public class MicroServiceDictionaryController {
        private static final Logger LOGGER  = FlexLogger.getLogger(MicroServiceDictionaryController.class);
 
        private static CommonClassDao commonClassDao;
-
-       public static void setCommonClassDao(CommonClassDao commonClassDao) {
-               MicroServiceDictionaryController.commonClassDao = commonClassDao;
-       }
-
+       
+    private static String successMapKey= "successMapKey";
+    private static String successMsg = "success";
+    private static String operation = "operation";
+    private static String getDictionary = "getDictionary";
+    private static String errorMsg = "error";
+    private static String dictionaryDBQuery = "dictionaryDBQuery";
+    private HashMap<String,MSAttributeObject > classMap;
+    private List<String> modelList = new ArrayList<>();
+    private static String apiflag = "apiflag";
+       private static String dictionaryFields ="dictionaryFields";
+       private static String update = "update";
+       private static String duplicateResponseString = "Duplicate";
+       private static String successMessage = "Success";
+       private static String utf8 = "UTF-8";
+       private static String applicationJsonContentType = "application / json";
+       private static String existsResponseString = "Exists";
+       private static String microServiceModelsDictionaryDatas = "microServiceModelsDictionaryDatas";
+       private static String modelName = "modelName";
+       private static String microServiceModelsDictionaryData = "microServiceModelsDictionaryData";
+       private static String description = "description";
+       private static String version = "version";
+       private static String classMapData = "classMap";
+       /*
+        * This is an empty constructor
+        */
+    public MicroServiceDictionaryController(){}        
+       
        @Autowired
        public MicroServiceDictionaryController(CommonClassDao commonClassDao){
                MicroServiceDictionaryController.commonClassDao = commonClassDao;
        }
-       
-       public MicroServiceDictionaryController(){}     
+       public static void setCommonClassDao(CommonClassDao commonClassDao) {
+               MicroServiceDictionaryController.commonClassDao = commonClassDao;
+       }
        
        public UserInfo getUserInfo(String loginId){
-               UserInfo name = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
-               return name;    
+               return (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
        }
-       
-    private static String SUCCESSKEY= "successMapKey";
-    private static String SUCCESS = "success";
-    private static String OPERATION = "operation";
-    private static String GETDICTIONARY = "getDictionary";
-    private static String ERROR = "error";
-    private static String DICTIONARYDBQUERY = "dictionaryDBQuery";
-    private HashMap<String,MSAttributeObject > classMap;
-    private List<String> modelList = new ArrayList<>();
-    
-       
 
        MSModelUtils utils = new MSModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
        private MicroServiceModels newModel;
        
        
        @RequestMapping(value={"/get_DCAEUUIDDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getDCAEUUIDDictionaryByNameEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getDCAEUUIDDictionaryByNameEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
@@ -112,31 +124,31 @@ public class MicroServiceDictionaryController {
        }
 
        @RequestMapping(value={"/get_DCAEUUIDData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getDCAEUUIDDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getDCAEUUIDDictionaryEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
                        model.put("dcaeUUIDDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(DCAEuuid.class)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
-            response.addHeader(SUCCESSKEY, SUCCESS);    
-            response.addHeader(OPERATION, GETDICTIONARY);
+            response.addHeader(successMapKey, successMsg);    
+            response.addHeader(operation, getDictionary);
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
-            response.addHeader(ERROR, DICTIONARYDBQUERY);
+            response.addHeader(errorMsg, dictionaryDBQuery);
             LOGGER.error(e);
                }
        }
        
        @RequestMapping(value={"/ms_dictionary/save_dcaeUUID"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView saveDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+       public ModelAndView saveDCAEUUIDDictionary(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();
@@ -144,14 +156,13 @@ public class MicroServiceDictionaryController {
                        JsonNode root = mapper.readTree(request.getReader());
             DCAEuuid dCAEuuid;
             if (fromAPI) {
-                dCAEuuid = (DCAEuuid)mapper.readValue(root.get("dictionaryFields").toString(), DCAEuuid.class);
+                dCAEuuid = (DCAEuuid)mapper.readValue(root.get(dictionaryFields).toString(), DCAEuuid.class);
                 
                 //check if update operation or create, get id for data to be updated and update attributeData
-                if (request.getParameter(OPERATION).equals("update")) {
+                if ((update).equals(request.getParameter(operation))) {
                        List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(dCAEuuid.getName(), "name", DCAEuuid.class);
-                       int id = 0;
                        DCAEuuid data = (DCAEuuid) duplicateData.get(0);
-                       id = data.getId();
+                       int id = data.getId();
                        if(id==0){
                                isFakeUpdate=true;
                                dCAEuuid.setId(1);
@@ -176,26 +187,26 @@ public class MicroServiceDictionaryController {
                        } 
             String responseString = "";
             if(duplicateflag){
-                responseString = "Duplicate";
+                responseString = duplicateResponseString;
             }else{
                 responseString = mapper.writeValueAsString(commonClassDao.getData(DCAEuuid.class));
             } 
             
             if (fromAPI) {
-                if (responseString!=null && !responseString.equals("Duplicate")) {
+                if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
                     if(isFakeUpdate){
-                        responseString = "Exists";
+                        responseString = existsResponseString;
                     } else {
-                        responseString = "Success";
+                        responseString = successMessage;
                     }
                 }
                 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("{dcaeUUIDDictionaryDatas: " + responseString + "}");
@@ -203,26 +214,26 @@ public class MicroServiceDictionaryController {
                 return null;
             }
         }catch (Exception e){
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                        LOGGER.error(e);
                }
                return null;
        }
 
        @RequestMapping(value={"/ms_dictionary/remove_dcaeuuid"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
+       public ModelAndView removeDCAEUUIDDictionary(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());
                        DCAEuuid dCAEuuid = (DCAEuuid)mapper.readValue(root.get("data").toString(), DCAEuuid.class);
                        commonClassDao.delete(dCAEuuid);
-                       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();
 
@@ -234,17 +245,17 @@ public class MicroServiceDictionaryController {
                }
                catch (Exception e){
                        LOGGER.error(e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
                return null;
        }
        
        
        @RequestMapping(value={"/get_MicroServiceConfigNameDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getMicroServiceConfigNameByNameDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getMicroServiceConfigNameByNameDictionaryEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
@@ -261,31 +272,31 @@ public class MicroServiceDictionaryController {
        
        
        @RequestMapping(value={"/get_MicroServiceConfigNameData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getMicroServiceConfigNameDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getMicroServiceConfigNameDictionaryEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
                        model.put("microServiceCongigNameDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(MicroServiceConfigName.class)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
-            response.addHeader(SUCCESSKEY, SUCCESS);    
-            response.addHeader(OPERATION, GETDICTIONARY);
+            response.addHeader(successMapKey, successMsg);    
+            response.addHeader(operation, getDictionary);
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
-            response.addHeader(ERROR, DICTIONARYDBQUERY);
+            response.addHeader(errorMsg, dictionaryDBQuery);
             LOGGER.error(e);
                }
        }
        
        @RequestMapping(value={"/ms_dictionary/save_configName"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView saveMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+       public ModelAndView saveMicroServiceConfigNameDictionary(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();
@@ -293,14 +304,13 @@ public class MicroServiceDictionaryController {
                        JsonNode root = mapper.readTree(request.getReader());
             MicroServiceConfigName microServiceConfigName;
             if (fromAPI) {
-                microServiceConfigName = (MicroServiceConfigName)mapper.readValue(root.get("dictionaryFields").toString(), MicroServiceConfigName.class);
+                microServiceConfigName = (MicroServiceConfigName)mapper.readValue(root.get(dictionaryFields).toString(), MicroServiceConfigName.class);
                 
                 //check if update operation or create, get id for data to be updated and update attributeData
-                if (request.getParameter(OPERATION).equals("update")) {
+                if ((update).equals(request.getParameter(operation))) {
                     List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(microServiceConfigName.getName(), "name", MicroServiceConfigName.class);
-                    int id = 0;
                     MicroServiceConfigName data = (MicroServiceConfigName) duplicateData.get(0);
-                    id = data.getId();
+                    int id = data.getId();
                 
                     if(id==0){
                         isFakeUpdate=true;
@@ -326,26 +336,26 @@ public class MicroServiceDictionaryController {
                        } 
             String responseString = "";
             if(duplicateflag){
-                responseString = "Duplicate";
+                responseString = duplicateResponseString;
             }else{
                 responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceConfigName.class));
             }
             
             if (fromAPI) {
-                if (responseString!=null && !responseString.equals("Duplicate")) {
+                if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
                     if(isFakeUpdate){
-                        responseString = "Exists";
+                        responseString = existsResponseString;
                     } else {
-                        responseString = "Success";
+                        responseString = successMessage;
                     }
                 }
                 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("{microServiceCongigNameDictionaryDatas: " + responseString + "}");
@@ -353,26 +363,26 @@ public class MicroServiceDictionaryController {
                 return null;
             }
         }catch (Exception e){
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                        LOGGER.error(e);
                }
                return null;
        }
 
        @RequestMapping(value={"/ms_dictionary/remove_msConfigName"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
+       public ModelAndView removeMicroServiceConfigNameDictionary(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());
                        MicroServiceConfigName microServiceConfigName = (MicroServiceConfigName)mapper.readValue(root.get("data").toString(), MicroServiceConfigName.class);
                        commonClassDao.delete(microServiceConfigName);
-                       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();
 
@@ -384,16 +394,16 @@ public class MicroServiceDictionaryController {
                }
                catch (Exception e){
                        LOGGER.error(e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
                return null;
        }
        
        @RequestMapping(value={"/get_MicroServiceLocationDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getMicroServiceLocationByNameDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getMicroServiceLocationByNameDictionaryEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
@@ -408,31 +418,31 @@ public class MicroServiceDictionaryController {
        }
        
        @RequestMapping(value={"/get_MicroServiceLocationData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getMicroServiceLocationDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getMicroServiceLocationDictionaryEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
                        model.put("microServiceLocationDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(MicroServiceLocation.class)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
-            response.addHeader(SUCCESSKEY, SUCCESS);    
-            response.addHeader(OPERATION, GETDICTIONARY);
+            response.addHeader(successMapKey, successMsg);    
+            response.addHeader(operation, getDictionary);
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
-            response.addHeader(ERROR, DICTIONARYDBQUERY);
+            response.addHeader(errorMsg, dictionaryDBQuery);
             LOGGER.error(e);
                }
        }
        
        @RequestMapping(value={"/ms_dictionary/save_location"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView saveMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response)throws UnsupportedEncodingException, IOException{
+       public ModelAndView saveMicroServiceLocationDictionary(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();
@@ -440,14 +450,13 @@ public class MicroServiceDictionaryController {
                        JsonNode root = mapper.readTree(request.getReader());
             MicroServiceLocation microServiceLocation;
             if (fromAPI) {
-                microServiceLocation = (MicroServiceLocation)mapper.readValue(root.get("dictionaryFields").toString(), MicroServiceLocation.class);
+                microServiceLocation = (MicroServiceLocation)mapper.readValue(root.get(dictionaryFields).toString(), MicroServiceLocation.class);
                 
                 //check if update operation or create, get id for data to be updated and update attributeData
-                if (request.getParameter(OPERATION).equals("update")) {
+                if ((update).equals(request.getParameter(operation))) {
                     List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(microServiceLocation.getName(), "name", MicroServiceLocation.class);
-                    int id = 0;
                     MicroServiceLocation data = (MicroServiceLocation) duplicateData.get(0);
-                    id = data.getId();
+                    int id = data.getId();
                   
                     if(id==0){
                         isFakeUpdate=true;
@@ -473,26 +482,26 @@ public class MicroServiceDictionaryController {
                        } 
             String responseString = "";
             if(duplicateflag){
-                responseString = "Duplicate";
+                responseString = duplicateResponseString;
             }else{
                 responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceLocation.class));
             }
             
             if (fromAPI) {
-                if (responseString!=null && !responseString.equals("Duplicate")) {
+                if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
                     if(isFakeUpdate){
-                        responseString = "Exists";
+                        responseString = existsResponseString;
                     } else {
-                        responseString = "Success";
+                        responseString = successMessage;
                     }
                 }
                 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("{microServiceLocationDictionaryDatas: " + responseString + "}");
@@ -500,26 +509,26 @@ public class MicroServiceDictionaryController {
                 return null;
             }
                }catch (Exception e){
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                        LOGGER.error(e);
                }
                return null;
        }
 
        @RequestMapping(value={"/ms_dictionary/remove_msLocation"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
+       public ModelAndView removeMicroServiceLocationDictionary(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());
                        MicroServiceLocation microServiceLocation = (MicroServiceLocation)mapper.readValue(root.get("data").toString(), MicroServiceLocation.class);
                        commonClassDao.delete(microServiceLocation);
-                       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();
 
@@ -531,16 +540,16 @@ public class MicroServiceDictionaryController {
                }
                catch (Exception e){
                        LOGGER.error(e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
                return null;
        }
        
     @RequestMapping(value={"/get_MicroServiceAttributeDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-    public void getMicroServiceAttributeByNameDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
+    public void getMicroServiceAttributeByNameDictionaryEntityData(HttpServletResponse response){
         try{
             Map<String, Object> model = new HashMap<>();
             ObjectMapper mapper = new ObjectMapper();
@@ -555,31 +564,31 @@ public class MicroServiceDictionaryController {
     }
     
     @RequestMapping(value={"/get_MicroServiceAttributeData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-    public void getMicroServiceAttributeDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
+    public void getMicroServiceAttributeDictionaryEntityData(HttpServletResponse response){
         try{
             Map<String, Object> model = new HashMap<>();
             ObjectMapper mapper = new ObjectMapper();
             model.put("microServiceAttributeDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(MicroServiceAttribute.class)));
             JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
             JSONObject j = new JSONObject(msg);
-            response.addHeader(SUCCESSKEY, SUCCESS);    
-            response.addHeader(OPERATION, GETDICTIONARY);
+            response.addHeader(successMapKey, successMsg);    
+            response.addHeader(operation, getDictionary);
             response.getWriter().write(j.toString());
  
         }
         catch (Exception e){
             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
-            response.addHeader(ERROR, DICTIONARYDBQUERY);
+            response.addHeader(errorMsg, dictionaryDBQuery);
             LOGGER.error(e);
         }
     }
     
     @RequestMapping(value={"/ms_dictionary/save_modelAttribute"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-    public ModelAndView saveMicroServiceAttributeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+    public ModelAndView saveMicroServiceAttributeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
         try {
             boolean duplicateflag = 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;
             }
             
@@ -589,10 +598,10 @@ public class MicroServiceDictionaryController {
             
             MicroServiceAttribute microServiceAttribute;
             if (fromAPI) {
-                microServiceAttribute = (MicroServiceAttribute)mapper.readValue(root.get("dictionaryFields").toString(), MicroServiceAttribute.class);
+                microServiceAttribute = (MicroServiceAttribute)mapper.readValue(root.get(dictionaryFields).toString(), MicroServiceAttribute.class);
                 
                 //check if update operation or create, get id for data to be updated and update attributeData
-                if (request.getParameter(OPERATION).equals("update")) {
+                if ((update).equals(request.getParameter(operation))) {
                     MicroServiceAttribute initialAttribute = (MicroServiceAttribute)mapper.readValue(root.get("initialFields").toString(), MicroServiceAttribute.class);
  
                     String checkValue = initialAttribute.getName() + ":" + initialAttribute.getValue() + ":" + initialAttribute.getModelName();
@@ -622,22 +631,22 @@ public class MicroServiceDictionaryController {
  
             String responseString = "";
             if(duplicateflag){
-                responseString = "Duplicate";
+                responseString = duplicateResponseString;
             }else{
                 responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceAttribute.class));
             }
             
             if (fromAPI) {
-                if (responseString!=null && !responseString.equals("Duplicate")) {
-                    responseString = "Success";
+                if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
+                    responseString = successMessage;
                 }
                 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("{microServiceAttributeDictionaryDatas: " + responseString + "}");
@@ -646,26 +655,26 @@ public class MicroServiceDictionaryController {
             }
         }
         catch (Exception e){
-            response.setCharacterEncoding("UTF-8");
-            request.setCharacterEncoding("UTF-8");
+            response.setCharacterEncoding(utf8);
+            request.setCharacterEncoding(utf8);
             PrintWriter out = response.getWriter();
-            out.write(e.getMessage());
+            out.write(PolicyUtils.CATCH_EXCEPTION);
             LOGGER.error(e);
         }
         return null;
     }
  
     @RequestMapping(value={"/ms_dictionary/remove_modelAttribute"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-    public ModelAndView removeMicroServiceAttributeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+    public ModelAndView removeMicroServiceAttributeDictionary(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());
             MicroServiceAttribute microServiceAttribute = (MicroServiceAttribute)mapper.readValue(root.get("data").toString(), MicroServiceAttribute.class);
             commonClassDao.delete(microServiceAttribute);
-            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();
  
@@ -677,21 +686,21 @@ public class MicroServiceDictionaryController {
         }
         catch (Exception e){
             LOGGER.error(e);
-            response.setCharacterEncoding("UTF-8");
-            request.setCharacterEncoding("UTF-8");
+            response.setCharacterEncoding(utf8);
+            request.setCharacterEncoding(utf8);
             PrintWriter out = response.getWriter();
-            out.write(e.getMessage());
+            out.write(PolicyUtils.CATCH_EXCEPTION);
         }
         return null;
     }
  
        
        @RequestMapping(value={"/get_MicroServiceModelsDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getMicroServiceModelsDictionaryByNameEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getMicroServiceModelsDictionaryByNameEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
-                       model.put("microServiceModelsDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(MicroServiceModels.class, "modelName")));
+                       model.put(microServiceModelsDictionaryDatas, mapper.writeValueAsString(commonClassDao.getDataByColumn(MicroServiceModels.class, modelName)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
                        response.getWriter().write(j.toString());
@@ -708,13 +717,13 @@ public class MicroServiceDictionaryController {
             ObjectMapper mapper = new ObjectMapper();
             JsonNode root = mapper.readTree(request.getReader());
             String modelName = null;
-            if (root.get("microServiceModelsDictionaryData").has("modelName")){
-                modelName = root.get("microServiceModelsDictionaryData").get("modelName").asText().replace("\"", "");
+            if (root.get(microServiceModelsDictionaryData).has(modelName)){
+                modelName = root.get(microServiceModelsDictionaryData).get(modelName).asText().replace("\"", "");
             }
              if (modelName!=null){
-                    model.put("microServiceModelsDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataById(MicroServiceModels.class, "modelName", modelName)));
+                    model.put(microServiceModelsDictionaryDatas, mapper.writeValueAsString(commonClassDao.getDataById(MicroServiceModels.class, modelName, modelName)));
              } else{
-                 model.put(ERROR, "No model name given");
+                 model.put(errorMsg, "No model name given");
              }
             JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
             JSONObject j = new JSONObject(msg);
@@ -726,26 +735,26 @@ public class MicroServiceDictionaryController {
     }
     
        @RequestMapping(value={"/get_MicroServiceModelsData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-       public void getMicroServiceModelsDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
+       public void getMicroServiceModelsDictionaryEntityData(HttpServletResponse response){
                try{
                        Map<String, Object> model = new HashMap<>();
                        ObjectMapper mapper = new ObjectMapper();
-                       model.put("microServiceModelsDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(MicroServiceModels.class)));
+                       model.put(microServiceModelsDictionaryDatas, mapper.writeValueAsString(commonClassDao.getData(MicroServiceModels.class)));
                        JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
                        JSONObject j = new JSONObject(msg);
-            response.addHeader(SUCCESSKEY, SUCCESS);    
-            response.addHeader(OPERATION, GETDICTIONARY);
+            response.addHeader(successMapKey, successMsg);    
+            response.addHeader(operation, getDictionary);
                        response.getWriter().write(j.toString());
                }
                catch (Exception e){
             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
-            response.addHeader(ERROR, DICTIONARYDBQUERY);
+            response.addHeader(errorMsg, dictionaryDBQuery);
             LOGGER.error(e);
                }
        }
        
     @RequestMapping(value={"/get_MicroServiceModelsDataServiceVersion"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-    public void getMicroServiceModelsDictionaryEntityDataServiceVersion(HttpServletRequest request, HttpServletResponse response){
+    public void getMicroServiceModelsDictionaryEntityDataServiceVersion(HttpServletResponse response){
         try{
             Map<String, Object> model = new HashMap<>();
             ObjectMapper mapper = new ObjectMapper();
@@ -757,7 +766,7 @@ public class MicroServiceDictionaryController {
                        data.add(msmodel.getModelName() + "-v" + msmodel.getVersion());
                 }
             }
-            model.put("microServiceModelsDictionaryDatas", mapper.writeValueAsString(data));
+            model.put(microServiceModelsDictionaryDatas, mapper.writeValueAsString(data));
             JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
             JSONObject j = new JSONObject(msg);
             response.addHeader("successMapKey", "success"); 
@@ -773,32 +782,32 @@ public class MicroServiceDictionaryController {
     }
     
     @RequestMapping(value={"/get_MicroServiceModelsDataByClass"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-    public void getMicroServiceModelsDictionaryClassEntityData(HttpServletRequest request, HttpServletResponse response){
+    public void getMicroServiceModelsDictionaryClassEntityData(HttpServletResponse response){
         try{
             Map<String, Object> model = new HashMap<>();
             ObjectMapper mapper = new ObjectMapper();
             model.put("microServiceModelsDictionaryClassDatas", mapper.writeValueAsString(modelList));
             JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
             JSONObject j = new JSONObject(msg);
-            response.addHeader(SUCCESSKEY, SUCCESS);    
-            response.addHeader(OPERATION, GETDICTIONARY);
+            response.addHeader(successMapKey, successMsg);    
+            response.addHeader(operation, getDictionary);
             response.getWriter().write(j.toString());
  
         }
         catch (Exception e){
             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
-            response.addHeader(ERROR, DICTIONARYDBQUERY);
+            response.addHeader(errorMsg, dictionaryDBQuery);
             LOGGER.error(e);
         }
     }
     
        @RequestMapping(value={"/ms_dictionary/save_model"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView saveMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+       public ModelAndView saveMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
                try {
                        boolean duplicateflag = false;
                        boolean fromAPI = false;
                        this.newModel = new MicroServiceModels();
-                       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();
@@ -811,23 +820,22 @@ public class MicroServiceDictionaryController {
                                JsonNode dataType = root.get("modelType");
                                String modelType= dataType.toString();
                                if(modelType.contains("yml")){
-                                       if (root.has("microServiceModelsDictionaryData")){
-                                               if (root.get("microServiceModelsDictionaryData").has("description")){
-                                                       microServiceModels.setDescription(root.get("microServiceModelsDictionaryData").get("description").asText().replace("\"", ""));
+                                       if (root.has(microServiceModelsDictionaryData)){
+                                               if (root.get(microServiceModelsDictionaryData).has(description)){
+                                                       microServiceModels.setDescription(root.get(microServiceModelsDictionaryData).get(description).asText().replace("\"", ""));
                                                }
-                                               if (root.get("microServiceModelsDictionaryData").has("modelName")){
-                                                       microServiceModels.setModelName(root.get("microServiceModelsDictionaryData").get("modelName").asText().replace("\"", ""));
+                                               if (root.get(microServiceModelsDictionaryData).has(modelName)){
+                                                       microServiceModels.setModelName(root.get(microServiceModelsDictionaryData).get(modelName).asText().replace("\"", ""));
                                                        this.newModel.setModelName(microServiceModels.getModelName());
                                                }
-                                               if (root.get("microServiceModelsDictionaryData").has("version")){
-                                                       microServiceModels.setVersion(root.get("microServiceModelsDictionaryData").get("version").asText().replace("\"", ""));
+                                               if (root.get(microServiceModelsDictionaryData).has(version)){
+                                                       microServiceModels.setVersion(root.get(microServiceModelsDictionaryData).get(version).asText().replace("\"", ""));
                                                        this.newModel.setVersion(microServiceModels.getVersion());
                                                }
                                        }
 
-                                       MSAttributeObject mainClass  = null;
                                        classMap = new HashMap<>();
-                                       JsonNode data = root.get("classMap");
+                                       JsonNode data = root.get(classMapData);
                                        ObjectMapper mapper1 = new ObjectMapper();
                                        String data1 = data.toString().substring(1, data.toString().length()-1);
                                        data1 = data1.replace("\\", "");
@@ -842,28 +850,28 @@ public class MicroServiceDictionaryController {
                                        }
 
                                        userId = root.get("userid").textValue();
-                                       mainClass = classMap.get(this.newModel.getModelName());
+                                       MSAttributeObject mainClass = classMap.get(this.newModel.getModelName());
                                        this.newModel.setDependency("[]");
                                        String value = new Gson().toJson(mainClass.getSubClass());
                                        this.newModel.setSub_attributes(value);
                                        String attributes= mainClass.getAttribute().toString().replace("{", "").replace("}", "");
                                        int equalsIndexForAttributes= attributes.indexOf("=");
-                                       String atttributesAfterFirstEquals= attributes.substring(equalsIndexForAttributes+1);
+                                       String atttributesAfterFirstEquals= attributes.substring(equalsIndexForAttributes+1, attributes.length()-1);
                                        this.newModel.setAttributes(atttributesAfterFirstEquals);
                                        String refAttributes= mainClass.getRefAttribute().toString().replace("{", "").replace("}", "");
                                        int equalsIndex= refAttributes.indexOf("=");
-                                       String refAttributesAfterFirstEquals= refAttributes.substring(equalsIndex+1);
+                                       String refAttributesAfterFirstEquals= refAttributes.substring(equalsIndex+1, refAttributes.length()-1);
                                        this.newModel.setRef_attributes(refAttributesAfterFirstEquals);
                                        this.newModel.setEnumValues(mainClass.getEnumType().toString().replace("{", "").replace("}", ""));
                                        this.newModel.setAnnotation(mainClass.getMatchingSet().toString().replace("{", "").replace("}", ""));
 
                                }else{
                                        if (fromAPI) {
-                                               microServiceModels = (MicroServiceModels)mapper.readValue(root.get("dictionaryFields").toString(), MicroServiceModels.class);
+                                               microServiceModels = (MicroServiceModels)mapper.readValue(root.get(dictionaryFields).toString(), MicroServiceModels.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")) {
+                                               if ((update).equals(request.getParameter(operation))) {
                                                        String checkName = microServiceModels.getModelName() + ":" + microServiceModels.getVersion();
                                                        List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(checkName, "modelName:version", MicroServiceModels.class);
                                                        int id = 0;
@@ -876,22 +884,22 @@ public class MicroServiceDictionaryController {
 
                                                }
                                        } else {
-                                               if (root.has("microServiceModelsDictionaryData")){
-                                                       if (root.get("microServiceModelsDictionaryData").has("description")){
-                                                               microServiceModels.setDescription(root.get("microServiceModelsDictionaryData").get("description").asText().replace("\"", ""));
+                                               if (root.has(microServiceModelsDictionaryData)){
+                                                       if (root.get(microServiceModelsDictionaryData).has(description)){
+                                                               microServiceModels.setDescription(root.get(microServiceModelsDictionaryData).get(description).asText().replace("\"", ""));
                                                        }
-                                                       if (root.get("microServiceModelsDictionaryData").has("modelName")){
-                                                               microServiceModels.setModelName(root.get("microServiceModelsDictionaryData").get("modelName").asText().replace("\"", ""));
+                                                       if (root.get(microServiceModelsDictionaryData).has(modelName)){
+                                                               microServiceModels.setModelName(root.get(microServiceModelsDictionaryData).get(modelName).asText().replace("\"", ""));
                                                                this.newModel.setModelName(microServiceModels.getModelName());
                                                        }
-                                                       if (root.get("microServiceModelsDictionaryData").has("version")){
-                                                               microServiceModels.setVersion(root.get("microServiceModelsDictionaryData").get("version").asText().replace("\"", ""));
+                                                       if (root.get(microServiceModelsDictionaryData).has(version)){
+                                                               microServiceModels.setVersion(root.get(microServiceModelsDictionaryData).get(version).asText().replace("\"", ""));
                                                                this.newModel.setVersion(microServiceModels.getVersion());
                                                        }
                                                }
-                                               if(root.has("classMap")){
+                                               if(root.has(classMapData)){
                                                        classMap = new HashMap<>();
-                                                       JsonNode data = root.get("classMap");
+                                                       JsonNode data = root.get(classMapData);
                                                        ObjectMapper mapper1 = new ObjectMapper();
                                                        String data1 = data.toString().substring(1, data.toString().length()-1);
                                                        data1 = data1.replace("\\", "");
@@ -932,22 +940,22 @@ public class MicroServiceDictionaryController {
                        } 
                        String responseString = "";
                        if(duplicateflag){
-                               responseString = "Duplicate";
+                               responseString = duplicateResponseString;
                        }else{
                                responseString = mapper.writeValueAsString(commonClassDao.getData(MicroServiceModels.class));
                        } 
 
                        if (fromAPI) {
-                               if (responseString!=null && !responseString.equals("Duplicate")) {
-                                       responseString = "Success";
+                               if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
+                                       responseString = successMessage;
                                }
                                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("{microServiceModelsDictionaryDatas: " + responseString + "}");
@@ -955,26 +963,26 @@ public class MicroServiceDictionaryController {
                                return null;
                        }
                }catch (Exception e){
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                        LOGGER.error(e);
                }
                return null;
        }
 
        @RequestMapping(value={"/ms_dictionary/remove_msModel"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
-       public ModelAndView removeMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
+       public ModelAndView removeMicroServiceModelsDictionary(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());
                        MicroServiceModels microServiceModels = (MicroServiceModels)mapper.readValue(root.get("data").toString(), MicroServiceModels.class);
                        commonClassDao.delete(microServiceModels);
-                       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();
 
@@ -986,26 +994,23 @@ public class MicroServiceDictionaryController {
                }
                catch (Exception e){
                        LOGGER.error(e);
-                       response.setCharacterEncoding("UTF-8");
-                       request.setCharacterEncoding("UTF-8");
+                       response.setCharacterEncoding(utf8);
+                       request.setCharacterEncoding(utf8);
                        PrintWriter out = response.getWriter();
-                       out.write(e.getMessage());
+                       out.write(PolicyUtils.CATCH_EXCEPTION);
                }
                return null;
        }
                
        private void addValuesToNewModel(HashMap<String,MSAttributeObject > classMap) {
-               new MicroServiceModels();
                //Loop  through the classmap and pull out the required info for the new file.
-               MSAttributeObject mainClass  = null;
-               ArrayList<String> dependency = null;
                String subAttribute = null;
                
-               mainClass = classMap.get(this.newModel.getModelName());
+               MSAttributeObject mainClass = classMap.get(this.newModel.getModelName());
                
                if (mainClass !=null){
                        String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[]{"[", "]", " "}, new String[]{"", "", ""});
-                       dependency = new ArrayList<String>(Arrays.asList(dependTemp.split(",")));       
+                       ArrayList<String> dependency = new ArrayList<>(Arrays.asList(dependTemp.split(",")));   
                        dependency = getFullDependencyList(dependency);
                        for (String element : dependency){
                                MSAttributeObject temp = new MSAttributeObject();
@@ -1042,7 +1047,7 @@ public class MicroServiceDictionaryController {
                        if (classMap.containsKey(element)){
                                MSAttributeObject value = classMap.get(element);                        
                                String rawValue = StringUtils.replaceEach(value.getDependency(), new String[]{"[", "]"}, new String[]{"", ""});
-                               workingList = new ArrayList<String>(Arrays.asList(rawValue.split(",")));        
+                               workingList = new ArrayList<>(Arrays.asList(rawValue.split(",")));      
                                for(String depend : workingList){
                                        if (!returnList.contains(depend) && !depend.isEmpty()){
                                                returnList.add(depend.trim());