Merge "Fix Fortify Scan Issue"
[policy/engine.git] / ONAP-PAP-REST / src / main / java / org / onap / policy / pap / xacml / rest / controller / ClosedLoopDictionaryController.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-PAP-REST
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.pap.xacml.rest.controller;
22
23 import java.io.IOException;
24 import java.io.PrintWriter;
25 import java.util.Date;
26 import java.util.HashMap;
27 import java.util.LinkedHashMap;
28 import java.util.List;
29 import java.util.Map;
30
31 import javax.servlet.http.HttpServletRequest;
32 import javax.servlet.http.HttpServletResponse;
33
34 import org.json.JSONObject;
35 import org.onap.policy.common.logging.flexlogger.FlexLogger;
36 import org.onap.policy.common.logging.flexlogger.Logger;
37 import org.onap.policy.pap.xacml.rest.adapters.GridData;
38 import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
39 import org.onap.policy.pap.xacml.rest.util.JsonMessage;
40 import org.onap.policy.rest.dao.CommonClassDao;
41 import org.onap.policy.rest.jpa.ClosedLoopD2Services;
42 import org.onap.policy.rest.jpa.ClosedLoopSite;
43 import org.onap.policy.rest.jpa.PEPOptions;
44 import org.onap.policy.rest.jpa.UserInfo;
45 import org.onap.policy.rest.jpa.VNFType;
46 import org.onap.policy.rest.jpa.VSCLAction;
47 import org.onap.policy.rest.jpa.VarbindDictionary;
48 import org.onap.policy.utils.PolicyUtils;
49 import org.onap.policy.xacml.api.XACMLErrorConstants;
50 import org.springframework.beans.factory.annotation.Autowired;
51 import org.springframework.http.MediaType;
52 import org.springframework.stereotype.Controller;
53 import org.springframework.web.bind.annotation.RequestMapping;
54 import org.springframework.web.servlet.ModelAndView;
55
56 import com.fasterxml.jackson.databind.DeserializationFeature;
57 import com.fasterxml.jackson.databind.JsonNode;
58 import com.fasterxml.jackson.databind.ObjectMapper;
59
60 @Controller
61 public class ClosedLoopDictionaryController{
62
63         private static final Logger LOGGER = FlexLogger.getLogger(ClosedLoopDictionaryController.class);
64
65         private static CommonClassDao commonClassDao;
66         private static String vsclaction = "vsclaction";
67         private static String successMapKey = "successMapKey";
68         private static String successMessage = "success";
69         private static String operation = "operation";
70         private static String getDictionary = "getDictionary";
71         private static String dictionaryDBQuery = "dictionaryDBQuery";
72         private static String errorMsg  = "error";
73         private static String vnftype = "vnftype";
74         private static String pepName = "pepName";
75         private static String varbindName = "varbindName";
76         private static String serviceName = "serviceName";
77         private static String siteName = "siteName";
78         private static String apiflag = "apiflag";
79         private static String dictionaryFields = "dictionaryFields";
80         private static String update = "update";
81         private static String duplicateResponseString = "Duplicate";
82         private static String userid = "userid";
83         private static String utf8 = "UTF-8";
84         private static String applicationJsonContentType = "application / json";
85         private static String successMsg = "Success";
86         
87         @Autowired
88         public ClosedLoopDictionaryController(CommonClassDao commonClassDao){
89                 ClosedLoopDictionaryController.commonClassDao = commonClassDao;
90         }
91         
92         public void setCommonClassDao(CommonClassDao commonClassDao){
93                 ClosedLoopDictionaryController.commonClassDao = commonClassDao;
94         }
95         /*
96          * This is an empty constructor
97          */
98         public ClosedLoopDictionaryController(){}
99
100         public UserInfo getUserInfo(String loginId){
101                 return (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
102         }
103
104
105         @RequestMapping(value={"/get_VSCLActionDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
106         public void getVSCLActionDictionaryByNameEntityData(HttpServletResponse response){
107                 try{
108                         Map<String, Object> model = new HashMap<>();
109                         ObjectMapper mapper = new ObjectMapper();
110                         model.put("vsclActionDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(VSCLAction.class, vsclaction)));
111                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
112                         JSONObject j = new JSONObject(msg);
113                         response.getWriter().write(j.toString());
114                 }
115                 catch (Exception e){
116                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
117                 }
118         }
119
120
121         @RequestMapping(value={"/get_VSCLActionData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
122         public void getVSCLActionDictionaryEntityData(HttpServletResponse response){
123                 try{
124                         Map<String, Object> model = new HashMap<>();
125                         ObjectMapper mapper = new ObjectMapper();
126                         model.put("vsclActionDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(VSCLAction.class)));
127                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
128                         JSONObject j = new JSONObject(msg);
129                         response.addHeader(successMapKey, successMessage); 
130                         response.addHeader(operation, getDictionary);
131                         response.getWriter().write(j.toString());
132                 }
133                 catch (Exception e){
134                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
135                         response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
136                         response.addHeader(errorMsg, dictionaryDBQuery);
137                 }
138         }
139
140         @RequestMapping(value={"/get_VNFTypeDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
141         public void getVNFTypeDictionaryByNameEntityData(HttpServletResponse response){
142                 try{
143                         Map<String, Object> model = new HashMap<>();
144                         ObjectMapper mapper = new ObjectMapper();
145                         model.put("vnfTypeDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(VNFType.class, vnftype)));
146                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
147                         JSONObject j = new JSONObject(msg);
148                         response.addHeader(successMapKey, successMessage); 
149                         response.addHeader(operation, getDictionary);
150                         response.getWriter().write(j.toString());
151                 }
152                 catch (Exception e){
153                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
154                 }
155         }
156
157         @RequestMapping(value={"/get_VNFTypeData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
158         public void getVNFTypeDictionaryEntityData(HttpServletResponse response){
159                 try{
160                         Map<String, Object> model = new HashMap<>();
161                         ObjectMapper mapper = new ObjectMapper();
162                         model.put("vnfTypeDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(VNFType.class)));
163                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
164                         JSONObject j = new JSONObject(msg);
165                         response.addHeader(successMapKey, successMessage); 
166                         response.addHeader(operation, getDictionary);
167                         response.getWriter().write(j.toString());
168                 }
169                 catch (Exception e){
170                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
171                         response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
172                         response.addHeader(errorMsg, dictionaryDBQuery);
173                 }
174         }
175
176         @RequestMapping(value={"/get_PEPOptionsDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
177         public void getPEPOptionsDictionaryByNameEntityData(HttpServletResponse response){
178                 try{
179                         Map<String, Object> model = new HashMap<>();
180                         ObjectMapper mapper = new ObjectMapper();
181                         model.put("pepOptionsDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(PEPOptions.class, pepName)));
182                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
183                         JSONObject j = new JSONObject(msg);
184                         response.getWriter().write(j.toString());
185                 }
186                 catch (Exception e){
187                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
188                 }
189         }
190
191         @RequestMapping(value={"/get_PEPOptionsData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
192         public void getPEPOptionsDictionaryEntityData(HttpServletResponse response){
193                 try{
194                         Map<String, Object> model = new HashMap<>();
195                         ObjectMapper mapper = new ObjectMapper();
196                         model.put("pepOptionsDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(PEPOptions.class)));
197                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
198                         JSONObject j = new JSONObject(msg);
199                         response.addHeader(successMapKey, successMessage); 
200                         response.addHeader(operation, getDictionary);
201                         response.getWriter().write(j.toString());
202                 }
203                 catch (Exception e){
204                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
205                         response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
206                         response.addHeader(errorMsg, dictionaryDBQuery);
207                 }
208         }
209
210         @RequestMapping(value={"/get_VarbindDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
211         public void getVarbindDictionaryByNameEntityData(HttpServletResponse response){
212                 try{
213                         Map<String, Object> model = new HashMap<>();
214                         ObjectMapper mapper = new ObjectMapper();
215                         model.put("varbindDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(VarbindDictionary.class, varbindName)));
216                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
217                         JSONObject j = new JSONObject(msg);
218                         response.getWriter().write(j.toString());
219                 }
220                 catch (Exception e){
221                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
222                 }
223         }
224
225         @RequestMapping(value={"/get_VarbindDictionaryData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
226         public void getVarbindDictionaryEntityData(HttpServletResponse response){
227                 try{
228                         Map<String, Object> model = new HashMap<>();
229                         ObjectMapper mapper = new ObjectMapper();
230                         model.put("varbindDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(VarbindDictionary.class)));
231                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
232                         JSONObject j = new JSONObject(msg);
233                         response.addHeader(successMapKey, successMessage); 
234                         response.addHeader(operation, getDictionary);
235                         response.getWriter().write(j.toString());
236                 }
237                 catch (Exception e){
238                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
239                         response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
240                         response.addHeader(errorMsg, dictionaryDBQuery);
241                 }
242         }
243
244         @RequestMapping(value={"/get_ClosedLoopServicesDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
245         public void getClosedLoopServiceDictionaryByNameEntityData(HttpServletResponse response){
246                 try{
247                         Map<String, Object> model = new HashMap<>();
248                         ObjectMapper mapper = new ObjectMapper();
249                         model.put("closedLoopServiceDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(ClosedLoopD2Services.class, serviceName)));
250                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
251                         JSONObject j = new JSONObject(msg);
252                         response.getWriter().write(j.toString());
253                 }
254                 catch (Exception e){
255                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
256                 }
257         }
258
259         @RequestMapping(value={"/get_ClosedLoopServicesData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
260         public void getClosedLoopServiceDictionaryEntityData(HttpServletResponse response){
261                 try{
262                         Map<String, Object> model = new HashMap<>();
263                         ObjectMapper mapper = new ObjectMapper();
264                         model.put("closedLoopServiceDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(ClosedLoopD2Services.class)));
265                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
266                         JSONObject j = new JSONObject(msg);
267                         response.addHeader(successMapKey, successMessage); 
268                         response.addHeader(operation, getDictionary);
269                         response.getWriter().write(j.toString());
270                 }
271                 catch (Exception e){
272                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
273                         response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
274                         response.addHeader(errorMsg, dictionaryDBQuery);
275                 }
276         }
277
278         @RequestMapping(value={"/get_ClosedLoopSiteDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
279         public void getClosedLoopSiteDictionaryByNameEntityData(HttpServletResponse response){
280                 try{
281                         Map<String, Object> model = new HashMap<>();
282                         ObjectMapper mapper = new ObjectMapper();
283                         model.put("closedLoopSiteDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(ClosedLoopSite.class, siteName)));
284                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
285                         JSONObject j = new JSONObject(msg);
286                         response.getWriter().write(j.toString());
287                 }
288                 catch (Exception e){
289                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
290                 }
291         }
292
293         @RequestMapping(value={"/get_ClosedLoopSiteData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
294         public void getClosedLoopSiteDictionaryEntityData(HttpServletResponse response){
295                 try{
296                         Map<String, Object> model = new HashMap<>();
297                         ObjectMapper mapper = new ObjectMapper();
298                         model.put("closedLoopSiteDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(ClosedLoopSite.class)));
299                         JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
300                         JSONObject j = new JSONObject(msg);
301                         response.addHeader(successMapKey, successMessage); 
302                         response.addHeader(operation, getDictionary);
303                         response.getWriter().write(j.toString());
304                 }
305                 catch (Exception e){
306                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
307                         response.setStatus(HttpServletResponse.SC_BAD_REQUEST);                             
308                         response.addHeader(errorMsg, dictionaryDBQuery);
309                 }
310         }
311
312         @RequestMapping(value={"/cl_dictionary/save_vsclAction"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
313         public ModelAndView saveVSCLAction(HttpServletRequest request, HttpServletResponse response)throws IOException{
314                 try {
315                         boolean duplicateflag = false;
316                         boolean isFakeUpdate = false;
317                         boolean fromAPI = false;
318                         if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
319                                 fromAPI = true;
320                         }
321                         ObjectMapper mapper = new ObjectMapper();
322                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
323                         JsonNode root = mapper.readTree(request.getReader());
324                         VSCLAction vSCLAction;
325                         String userId = null;
326                         if (fromAPI) {
327                                 vSCLAction = (VSCLAction)mapper.readValue(root.get(dictionaryFields).toString(), VSCLAction.class);
328                                 userId = "API";
329
330                                 //check if update operation or create, get id for data to be updated and update attributeData
331                                 if ((update).equals(request.getParameter(operation))) {
332                                         List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(vSCLAction.getVsclaction(), vsclaction, VSCLAction.class);
333                                         VSCLAction data = (VSCLAction) duplicateData.get(0);
334                                         int id = data.getId();
335                                         if(id==0){
336                                                 isFakeUpdate=true;
337                                                 vSCLAction.setId(1);
338                                         } else {
339                                                 vSCLAction.setId(id);
340                                         }
341
342                                         vSCLAction.setUserCreatedBy(this.getUserInfo(userId));
343                                 }
344
345                         } else {
346                                 vSCLAction = (VSCLAction)mapper.readValue(root.get("vsclActionDictionaryData").toString(), VSCLAction.class);
347                                 userId = root.get(userid).textValue();
348                         }
349                         if(vSCLAction.getId() == 0){
350                                 List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(vSCLAction.getVsclaction(), vsclaction, VSCLAction.class);
351                                 if(!duplicateData.isEmpty()){
352                                         duplicateflag = true;
353                                 }else{
354                                         vSCLAction.setUserCreatedBy(this.getUserInfo(userId));
355                                         vSCLAction.setUserModifiedBy(this.getUserInfo(userId));
356                                         vSCLAction.setModifiedDate(new Date());
357                                         commonClassDao.save(vSCLAction);
358                                 }
359                         }else{
360                                 if(!isFakeUpdate) {
361                                         vSCLAction.setUserModifiedBy(this.getUserInfo(userId));
362                                         commonClassDao.update(vSCLAction); 
363                                 }
364                         }
365
366                         String responseString = "";
367                         if(duplicateflag){
368                                 responseString = duplicateResponseString;
369                         }else{
370                                 responseString = mapper.writeValueAsString(commonClassDao.getData(VSCLAction.class));
371                         }       
372                         if (fromAPI) {
373                                 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
374                                         if(isFakeUpdate) {
375                                                 responseString = "Exists";
376                                         } else {
377                                                 responseString = successMsg;
378                                         }               
379
380                                 }
381                                 ModelAndView result = new ModelAndView();
382                                 result.setViewName(responseString);
383                                 return result;
384                         } else {
385                                 response.setCharacterEncoding(utf8);
386                                 response.setContentType(applicationJsonContentType); 
387                                 request.setCharacterEncoding(utf8);
388
389                                 PrintWriter out = response.getWriter();
390                                 JSONObject j = new JSONObject("{vsclActionDictionaryDatas: " + responseString + "}");
391                                 out.write(j.toString());
392                                 return null;
393                         }
394                 }
395                 catch (Exception e){
396                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
397                         response.setCharacterEncoding(utf8);
398                         request.setCharacterEncoding(utf8);
399                         PrintWriter out = response.getWriter();
400                         out.write(PolicyUtils.CATCH_EXCEPTION);
401                 }
402                 return null;
403         }
404
405         @RequestMapping(value={"/cl_dictionary/remove_VsclAction"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
406         public ModelAndView removeVSCLAction(HttpServletRequest request, HttpServletResponse response) throws IOException {
407                 try{
408                         ObjectMapper mapper = new ObjectMapper();
409                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
410                         JsonNode root = mapper.readTree(request.getReader());
411                         VSCLAction vSCLAction = (VSCLAction)mapper.readValue(root.get("data").toString(), VSCLAction.class);
412                         commonClassDao.delete(vSCLAction);
413                         response.setCharacterEncoding(utf8);
414                         response.setContentType(applicationJsonContentType);
415                         request.setCharacterEncoding(utf8);
416
417                         PrintWriter out = response.getWriter();
418
419                         String responseString = mapper.writeValueAsString(commonClassDao.getData(VSCLAction.class));
420                         JSONObject j = new JSONObject("{vsclActionDictionaryDatas: " + responseString + "}");
421                         out.write(j.toString());
422
423                         return null;
424                 }
425                 catch (Exception e){
426                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
427                         response.setCharacterEncoding(utf8);
428                         request.setCharacterEncoding(utf8);
429                         PrintWriter out = response.getWriter();
430                         out.write(PolicyUtils.CATCH_EXCEPTION);
431                 }
432                 return null;
433         }
434
435         @RequestMapping(value={"/cl_dictionary/save_vnfType"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
436         public ModelAndView saveVnfType(HttpServletRequest request, HttpServletResponse response) throws IOException{
437                 try {
438                         boolean duplicateflag = false;
439                         boolean isFakeUpdate = false;
440                         boolean fromAPI = false;
441
442                         if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
443                                 fromAPI = true;
444                         }
445                         ObjectMapper mapper = new ObjectMapper();
446                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
447                         JsonNode root = mapper.readTree(request.getReader());
448                         VNFType vNFType;
449                         String userId = null;
450
451                         if (fromAPI) {
452                                 vNFType = (VNFType)mapper.readValue(root.get(dictionaryFields).toString(), VNFType.class);
453                                 userId = "API";
454
455                                 //check if update operation or create, get id for data to be updated and update attributeData
456                                 if ((update).equals(request.getParameter(operation))) {
457                                         List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(vNFType.getVnftype(), vnftype, VNFType.class);
458                                         VNFType data = (VNFType) duplicateData.get(0);
459                                         int id = data.getId();
460                                         if(id==0){
461                                                 isFakeUpdate=true;
462                                                 vNFType.setId(1);
463                                         } else {
464                                                 vNFType.setId(id);
465                                         }
466                                         vNFType.setUserCreatedBy(this.getUserInfo(userId));
467                                 }
468                         } else {
469                                 vNFType = (VNFType)mapper.readValue(root.get("vnfTypeDictionaryData").toString(), VNFType.class);
470                                 userId = root.get(userid).textValue();
471                         }
472                         if(vNFType.getId() == 0){
473                                 List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(vNFType.getVnftype(), vnftype, VNFType.class);
474                                 if(!duplicateData.isEmpty()){
475                                         duplicateflag = true;
476                                 }else{
477                                         vNFType.setUserCreatedBy(this.getUserInfo(userId));
478                                         vNFType.setUserModifiedBy(this.getUserInfo(userId));
479                                         commonClassDao.save(vNFType);
480                                 }        
481                         }else{
482                                 if(!isFakeUpdate) {
483                                         vNFType.setUserModifiedBy(this.getUserInfo(userId));
484                                         vNFType.setModifiedDate(new Date());
485                                         commonClassDao.update(vNFType); 
486                                 }
487                         } 
488                         String responseString = "";
489                         if(duplicateflag){
490                                 responseString = duplicateResponseString;
491                         }else{
492                                 responseString = mapper.writeValueAsString(commonClassDao.getData(VNFType.class));
493                         } 
494                         if (fromAPI) {
495                                 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
496                                         if(isFakeUpdate) {
497                                                 responseString = "Exists";
498                                         } else {
499                                                 responseString = successMsg;
500                                         }        
501                                 }
502                                 ModelAndView result = new ModelAndView();
503                                 result.setViewName(responseString);
504                                 return result; 
505                         } else {
506                                 response.setCharacterEncoding(utf8);
507                                 response.setContentType(applicationJsonContentType);
508                                 request.setCharacterEncoding(utf8);
509
510                                 PrintWriter out = response.getWriter();
511                                 JSONObject j = new JSONObject("{vnfTypeDictionaryDatas: " + responseString + "}");
512                                 out.write(j.toString()); 
513                                 return null;
514                         }
515                 } 
516                 catch (Exception e){
517                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
518                         response.setCharacterEncoding(utf8);
519                         request.setCharacterEncoding(utf8);
520                         PrintWriter out = response.getWriter();
521                         out.write(PolicyUtils.CATCH_EXCEPTION);
522                 }
523                 return null;
524         }
525
526         @RequestMapping(value={"/cl_dictionary/remove_vnfType"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
527         public ModelAndView removeVnfType(HttpServletRequest request, HttpServletResponse response) throws IOException {
528                 try{
529                         ObjectMapper mapper = new ObjectMapper();
530                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
531                         JsonNode root = mapper.readTree(request.getReader());
532                         VNFType vNFType = (VNFType)mapper.readValue(root.get("data").toString(), VNFType.class);
533                         commonClassDao.delete(vNFType);
534                         response.setCharacterEncoding(utf8);
535                         response.setContentType(applicationJsonContentType);
536                         request.setCharacterEncoding(utf8);
537
538                         PrintWriter out = response.getWriter();
539
540                         String responseString = mapper.writeValueAsString(commonClassDao.getData(VNFType.class));
541                         JSONObject j = new JSONObject("{vnfTypeDictionaryDatas: " + responseString + "}");
542                         out.write(j.toString());
543
544                         return null;
545                 }
546                 catch (Exception e){
547                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
548                         response.setCharacterEncoding(utf8);
549                         request.setCharacterEncoding(utf8);
550                         PrintWriter out = response.getWriter();
551                         out.write(PolicyUtils.CATCH_EXCEPTION);
552                 }
553                 return null;
554         }
555
556         @RequestMapping(value={"/cl_dictionary/save_pepOptions"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
557         public ModelAndView savePEPOptions(HttpServletRequest request, HttpServletResponse response) throws IOException{
558                 try {
559                         boolean duplicateflag = false;
560             boolean isFakeUpdate = false;
561             boolean fromAPI = false;
562             if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
563                 fromAPI = true;
564             }
565                         ObjectMapper mapper = new ObjectMapper();
566                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
567                         JsonNode root = mapper.readTree(request.getReader());
568             PEPOptions pEPOptions;
569             GridData gridData;
570             String userId = null;
571             if (fromAPI) {
572                 pEPOptions = (PEPOptions)mapper.readValue(root.get(dictionaryFields).toString(), PEPOptions.class);
573                 gridData = (GridData)mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
574                 userId = "API";
575                 
576                 //check if update operation or create, get id for data to be updated and update attributeData
577                 if ((update).equals(request.getParameter(operation))) {
578                     List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(pEPOptions.getPepName(), pepName, PEPOptions.class);
579                     PEPOptions data = (PEPOptions) duplicateData.get(0);
580                     int id = data.getId();
581                     if(id==0){
582                         isFakeUpdate=true;
583                         pEPOptions.setId(1);
584                     } else {
585                         pEPOptions.setId(id);
586                     }
587                     pEPOptions.setUserCreatedBy(this.getUserInfo(userId));
588                 }
589             } else {
590                 pEPOptions = (PEPOptions)mapper.readValue(root.get("pepOptionsDictionaryData").toString(), PEPOptions.class);
591                 gridData = (GridData)mapper.readValue(root.get("pepOptionsDictionaryData").toString(), GridData.class);
592                 userId = root.get(userid).textValue();
593             }
594                         String actions = "";
595                         int counter = 0;
596                         if(!gridData.getAttributes().isEmpty()){
597                                 for(Object attribute : gridData.getAttributes()){
598                                         if(attribute instanceof LinkedHashMap<?, ?>){
599                                                 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
600                                                 String value = ((LinkedHashMap<?, ?>) attribute).get("number").toString();
601                                                 if(counter>0){
602                                                         actions = actions + ":#@";
603                                                 }
604                                                 actions = actions + key + "=#@";
605                                                 actions = actions + value;
606                                                 counter ++;
607                                         }
608                                 }
609                         }
610                         pEPOptions.setActions(actions);
611                         if(pEPOptions.getId() == 0){
612                                 List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(pEPOptions.getPepName(), pepName, PEPOptions.class);
613                                 if(!duplicateData.isEmpty()){
614                                         duplicateflag = true;
615                                 }else{
616                                         pEPOptions.setUserCreatedBy(this.getUserInfo(userId));
617                                         pEPOptions.setUserModifiedBy(this.getUserInfo(userId));
618                                         commonClassDao.save(pEPOptions);
619                                 }        
620                         }else{
621                                 if(!isFakeUpdate){
622                                         pEPOptions.setUserModifiedBy(this.getUserInfo(userId));
623                                         pEPOptions.setModifiedDate(new Date());
624                                         commonClassDao.update(pEPOptions);
625                                 }
626                         }
627             String responseString = "";
628             if(duplicateflag){
629                 responseString = duplicateResponseString;
630             }else{
631                 responseString = mapper.writeValueAsString(commonClassDao.getData(PEPOptions.class));
632             } 
633             if (fromAPI) {
634                 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
635                     if(isFakeUpdate){
636                         responseString = "Exists";
637                     } else {
638                         responseString = successMsg;
639                     } 
640                 }
641                 
642                 ModelAndView result = new ModelAndView();
643                 result.setViewName(responseString);
644                 return result;
645             } else {
646                 response.setCharacterEncoding(utf8);
647                 response.setContentType(applicationJsonContentType);
648                 request.setCharacterEncoding(utf8);
649  
650                 PrintWriter out = response.getWriter();
651                 JSONObject j = new JSONObject("{pepOptionsDictionaryDatas: " + responseString + "}");
652                 out.write(j.toString());
653                 return null;
654             }
655  
656         }catch (Exception e){
657                 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
658                         response.setCharacterEncoding(utf8);
659                         request.setCharacterEncoding(utf8);
660                         PrintWriter out = response.getWriter();
661                         out.write(PolicyUtils.CATCH_EXCEPTION);
662                 }
663                 return null;
664         }
665
666         @RequestMapping(value={"/cl_dictionary/remove_pepOptions"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
667         public ModelAndView removePEPOptions(HttpServletRequest request, HttpServletResponse response) throws IOException {
668                 try{
669                         ObjectMapper mapper = new ObjectMapper();
670                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
671                         JsonNode root = mapper.readTree(request.getReader());
672                         PEPOptions pEPOptions = (PEPOptions)mapper.readValue(root.get("data").toString(), PEPOptions.class);
673                         commonClassDao.delete(pEPOptions);
674                         response.setCharacterEncoding(utf8);
675                         response.setContentType(applicationJsonContentType);
676                         request.setCharacterEncoding(utf8);
677
678                         PrintWriter out = response.getWriter();
679
680                         String responseString = mapper.writeValueAsString(commonClassDao.getData(PEPOptions.class));
681                         JSONObject j = new JSONObject("{pepOptionsDictionaryDatas: " + responseString + "}");
682                         out.write(j.toString());
683
684                         return null;
685                 }
686                 catch (Exception e){
687                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
688                         response.setCharacterEncoding(utf8);
689                         request.setCharacterEncoding(utf8);
690                         PrintWriter out = response.getWriter();
691                         out.write(PolicyUtils.CATCH_EXCEPTION);
692                 }
693                 return null;
694         }
695
696         @RequestMapping(value={"/cl_dictionary/save_service"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
697         public ModelAndView saveServiceType(HttpServletRequest request, HttpServletResponse response) throws IOException{
698                 try {
699                         boolean duplicateflag = false;
700             boolean isFakeUpdate = false;
701             boolean fromAPI = false;
702             if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
703                 fromAPI = true;
704             }
705                         ObjectMapper mapper = new ObjectMapper();
706                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
707                         JsonNode root = mapper.readTree(request.getReader());
708             ClosedLoopD2Services serviceData;
709             String userId = null;
710             if (fromAPI) {
711                 serviceData = (ClosedLoopD2Services)mapper.readValue(root.get(dictionaryFields).toString(), ClosedLoopD2Services.class);
712                 userId = "API";
713                 
714                 //check if update operation or create, get id for data to be updated and update attributeData
715                 if ((update).equals(request.getParameter(operation))) {
716                     List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(serviceData.getServiceName(), serviceName, ClosedLoopD2Services.class);
717                     ClosedLoopD2Services data = (ClosedLoopD2Services) duplicateData.get(0);
718                     int id = data.getId();
719                     if(id==0){
720                         isFakeUpdate=true;
721                         serviceData.setId(1);
722                     } else {
723                         serviceData.setId(id);
724                     }
725                     serviceData.setUserCreatedBy(this.getUserInfo(userId));
726                 }
727             } else {
728                 serviceData = (ClosedLoopD2Services)mapper.readValue(root.get("closedLoopServiceDictionaryData").toString(), ClosedLoopD2Services.class);
729                 userId = root.get(userid).textValue();
730             }
731                         if(serviceData.getId() == 0){
732                                 List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(serviceData.getServiceName(), serviceName, ClosedLoopD2Services.class);
733                                 if(!duplicateData.isEmpty()){
734                                         duplicateflag = true;
735                                 }else{
736                                         serviceData.setUserCreatedBy(this.getUserInfo(userId));
737                                         serviceData.setUserModifiedBy(this.getUserInfo(userId));
738                                         commonClassDao.save(serviceData);
739                                 }
740                         }else{
741                                 if(!isFakeUpdate){
742                                         serviceData.setUserModifiedBy(this.getUserInfo(userId));
743                                         serviceData.setModifiedDate(new Date());
744                                         commonClassDao.update(serviceData); 
745                                 }
746                         }
747             String responseString = "";
748             if(duplicateflag){
749                 responseString = duplicateResponseString;
750             }else{
751                 responseString = mapper.writeValueAsString(commonClassDao.getData(ClosedLoopD2Services.class));
752             } 
753             if (fromAPI) {
754                 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
755                     if(isFakeUpdate){
756                         responseString = "Exists";
757                     } else {
758                         responseString = successMsg;
759                     }
760                 }
761                 ModelAndView result = new ModelAndView();
762                 result.setViewName(responseString);
763                 return result;
764             } else {
765                 response.setCharacterEncoding(utf8);
766                 response.setContentType(applicationJsonContentType);
767                 request.setCharacterEncoding(utf8);
768  
769                 PrintWriter out = response.getWriter();
770                 JSONObject j = new JSONObject("{closedLoopServiceDictionaryDatas: " + responseString + "}");
771                 out.write(j.toString());
772                 return null;
773             }
774         }catch (Exception e){
775                 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
776                         response.setCharacterEncoding(utf8);
777                         request.setCharacterEncoding(utf8);
778                         PrintWriter out = response.getWriter();
779                         out.write(PolicyUtils.CATCH_EXCEPTION);
780                 }
781                 return null;
782         }
783
784         @RequestMapping(value={"/cl_dictionary/remove_Service"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
785         public ModelAndView removeServiceType(HttpServletRequest request, HttpServletResponse response) throws IOException {
786                 try{
787                         ObjectMapper mapper = new ObjectMapper();
788                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
789                         JsonNode root = mapper.readTree(request.getReader());
790                         ClosedLoopD2Services closedLoopD2Services = (ClosedLoopD2Services)mapper.readValue(root.get("data").toString(), ClosedLoopD2Services.class);
791                         commonClassDao.delete(closedLoopD2Services);
792                         response.setCharacterEncoding(utf8);
793                         response.setContentType(applicationJsonContentType);
794                         request.setCharacterEncoding(utf8);
795
796                         PrintWriter out = response.getWriter();
797
798                         String responseString = mapper.writeValueAsString(commonClassDao.getData(ClosedLoopD2Services.class));
799                         JSONObject j = new JSONObject("{closedLoopServiceDictionaryDatas: " + responseString + "}");
800                         out.write(j.toString());
801
802                         return null;
803                 }
804                 catch (Exception e){
805                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
806                         response.setCharacterEncoding(utf8);
807                         request.setCharacterEncoding(utf8);
808                         PrintWriter out = response.getWriter();
809                         out.write(PolicyUtils.CATCH_EXCEPTION);
810                 }
811                 return null;
812         }
813
814         @RequestMapping(value={"/cl_dictionary/save_siteName"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
815         public ModelAndView saveSiteType(HttpServletRequest request, HttpServletResponse response) throws IOException{
816                 try {
817                         boolean duplicateflag = false;
818             boolean isFakeUpdate = false;
819             boolean fromAPI = false;
820             
821             if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
822                 fromAPI = true;
823             }
824                         ObjectMapper mapper = new ObjectMapper();
825                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
826                         JsonNode root = mapper.readTree(request.getReader());
827             ClosedLoopSite siteData;
828             String userId = null;
829             if (fromAPI) {
830                 siteData = (ClosedLoopSite)mapper.readValue(root.get(dictionaryFields).toString(), ClosedLoopSite.class);
831                 userId = "API";
832                 //check if update operation or create, get id for data to be updated and update attributeData
833                 if ((update).equals(request.getParameter(operation))) {
834                     List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(siteData.getSiteName(), siteName, ClosedLoopSite.class);
835                     ClosedLoopSite data = (ClosedLoopSite) duplicateData.get(0);
836                     int id = data.getId();
837                     if(id==0){
838                         isFakeUpdate=true;
839                         siteData.setId(1);
840                     } else {
841                         siteData.setId(id);
842                     }
843                     siteData.setUserCreatedBy(this.getUserInfo(userId));
844                 }
845             } else {
846                 siteData = (ClosedLoopSite)mapper.readValue(root.get("closedLoopSiteDictionaryData").toString(), ClosedLoopSite.class);
847                 userId = root.get(userid).textValue();
848             }
849                         if(siteData.getId() == 0){
850                                 List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(siteData.getSiteName(), siteName, ClosedLoopSite.class);
851                                 if(!duplicateData.isEmpty()){
852                                         duplicateflag = true;
853                                 }else{
854                                         siteData.setUserCreatedBy(this.getUserInfo(userId));
855                                         siteData.setUserModifiedBy(this.getUserInfo(userId));
856                                         commonClassDao.save(siteData);
857                                 }
858                         }else{
859                                 if(!isFakeUpdate) {
860                                         siteData.setUserModifiedBy(this.getUserInfo(userId));
861                                         siteData.setModifiedDate(new Date());
862                                         commonClassDao.update(siteData);
863                                 }
864                         }
865             String responseString = "";
866             if(duplicateflag){
867                 responseString = duplicateResponseString;
868             }else{
869                 responseString = mapper.writeValueAsString(commonClassDao.getData(ClosedLoopSite.class));
870             }   
871             
872             if (fromAPI) {
873                 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
874                     if(isFakeUpdate){
875                         responseString = "Exists";
876                     } else {
877                         responseString = successMsg;
878                     }
879                 }
880                 ModelAndView result = new ModelAndView();
881                 result.setViewName(responseString);
882                 return result;
883             } else {
884                 response.setCharacterEncoding(utf8);
885                 response.setContentType(applicationJsonContentType);
886                 request.setCharacterEncoding(utf8);
887  
888                 PrintWriter out = response.getWriter();
889                 JSONObject j = new JSONObject("{closedLoopSiteDictionaryDatas: " + responseString + "}");
890                 out.write(j.toString());
891                 return null;
892             }
893         }catch (Exception e){
894                 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
895                         response.setCharacterEncoding(utf8);
896                         request.setCharacterEncoding(utf8);
897                         PrintWriter out = response.getWriter();
898                         out.write(PolicyUtils.CATCH_EXCEPTION);
899                 }
900                 return null;
901         }
902
903         @RequestMapping(value={"/cl_dictionary/remove_site"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
904         public ModelAndView removeSiteType(HttpServletRequest request, HttpServletResponse response) throws IOException {
905                 try{
906                         ObjectMapper mapper = new ObjectMapper();
907                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
908                         JsonNode root = mapper.readTree(request.getReader());
909                         ClosedLoopSite closedLoopSite = (ClosedLoopSite)mapper.readValue(root.get("data").toString(), ClosedLoopSite.class);
910                         commonClassDao.delete(closedLoopSite);
911                         response.setCharacterEncoding(utf8);
912                         response.setContentType(applicationJsonContentType);
913                         request.setCharacterEncoding(utf8);
914
915                         PrintWriter out = response.getWriter();
916
917                         String responseString = mapper.writeValueAsString(commonClassDao.getData(ClosedLoopSite.class));
918                         JSONObject j = new JSONObject("{closedLoopSiteDictionaryDatas: " + responseString + "}");
919                         out.write(j.toString());
920
921                         return null;
922                 }
923                 catch (Exception e){
924                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
925                         response.setCharacterEncoding(utf8);
926                         request.setCharacterEncoding(utf8);
927                         PrintWriter out = response.getWriter();
928                         out.write(PolicyUtils.CATCH_EXCEPTION);
929                 }
930                 return null;
931         }
932
933         @RequestMapping(value={"/cl_dictionary/save_varbind"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
934         public ModelAndView saveVarbind(HttpServletRequest request, HttpServletResponse response) throws IOException{
935                 try {
936                         boolean duplicateflag = false;
937             boolean isFakeUpdate = false;
938             boolean fromAPI = false;
939             if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
940                 fromAPI = true;
941             }
942                         ObjectMapper mapper = new ObjectMapper();
943                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
944                         JsonNode root = mapper.readTree(request.getReader());
945             VarbindDictionary varbindDictionary;
946             String userId = null;
947             if (fromAPI) {
948                 varbindDictionary = (VarbindDictionary)mapper.readValue(root.get(dictionaryFields).toString(), VarbindDictionary.class);
949                 userId = "API";
950                 
951                 //check if update operation or create, get id for data to be updated and update attributeData
952                 if ((update).equals(request.getParameter(operation))) {
953                     List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(varbindDictionary.getVarbindName(), varbindName, VarbindDictionary.class);
954                     VarbindDictionary data = (VarbindDictionary) duplicateData.get(0);
955                     int id = data.getId();
956                     if(id==0){
957                         isFakeUpdate=true;
958                         varbindDictionary.setId(1);
959                     } else {
960                         varbindDictionary.setId(id);
961                     }
962                     varbindDictionary.setUserCreatedBy(this.getUserInfo(userId));
963                 }
964             } else {
965                 varbindDictionary = (VarbindDictionary)mapper.readValue(root.get("varbindDictionaryData").toString(), VarbindDictionary.class);
966                 userId = root.get(userid).textValue();
967             }
968                         if(varbindDictionary.getId() == 0){
969                                 List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(varbindDictionary.getVarbindName(), varbindName, VarbindDictionary.class);
970                                 if(!duplicateData.isEmpty()){
971                                         duplicateflag = true;
972                                 }else{
973                                         varbindDictionary.setUserCreatedBy(this.getUserInfo(userId));
974                                         varbindDictionary.setUserModifiedBy(this.getUserInfo(userId));
975                                         commonClassDao.save(varbindDictionary);
976                                 }         
977                         }else{
978                                 if(!isFakeUpdate){
979                                         varbindDictionary.setUserModifiedBy(this.getUserInfo(userId));
980                                         varbindDictionary.setModifiedDate(new Date());
981                                         commonClassDao.update(varbindDictionary);
982                                 }
983                         }
984             String responseString = "";
985             if(duplicateflag){
986                 responseString = duplicateResponseString;
987             }else{
988                 responseString = mapper.writeValueAsString(commonClassDao.getData(VarbindDictionary.class));
989             }
990             
991             if (fromAPI) {
992                 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
993                     if(isFakeUpdate){
994                         responseString = "Exists";
995                     } else {
996                         responseString = successMsg;
997                     }
998                 }
999                 ModelAndView result = new ModelAndView();
1000                 result.setViewName(responseString);
1001                 return result;
1002             } else {
1003                 response.setCharacterEncoding(utf8);
1004                 response.setContentType(applicationJsonContentType);
1005                 request.setCharacterEncoding(utf8);
1006  
1007                 PrintWriter out = response.getWriter();
1008                 JSONObject j = new JSONObject("{varbindDictionaryDatas: " + responseString + "}");
1009                 out.write(j.toString());
1010                 return null;
1011             }
1012         }catch (Exception e){
1013                 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1014                         response.setCharacterEncoding(utf8);
1015                         request.setCharacterEncoding(utf8);
1016                         PrintWriter out = response.getWriter();
1017                         out.write(PolicyUtils.CATCH_EXCEPTION);
1018                 }
1019                 return null;
1020         }
1021
1022         @RequestMapping(value={"/cl_dictionary/remove_varbindDict"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1023         public ModelAndView removeVarbind(HttpServletRequest request, HttpServletResponse response) throws IOException{
1024                 try{
1025                         ObjectMapper mapper = new ObjectMapper();
1026                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1027                         JsonNode root = mapper.readTree(request.getReader());
1028                         VarbindDictionary varbindDictionary = (VarbindDictionary)mapper.readValue(root.get("data").toString(), VarbindDictionary.class);
1029                         commonClassDao.delete(varbindDictionary);
1030                         response.setCharacterEncoding(utf8);
1031                         response.setContentType(applicationJsonContentType);
1032                         request.setCharacterEncoding(utf8);
1033
1034                         PrintWriter out = response.getWriter();
1035
1036                         String responseString = mapper.writeValueAsString(commonClassDao.getData(VarbindDictionary.class));
1037                         JSONObject j = new JSONObject("{varbindDictionaryDatas: " + responseString + "}");
1038                         out.write(j.toString());
1039
1040                         return null;
1041                 }
1042                 catch (Exception e){
1043                         LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1044                         response.setCharacterEncoding(utf8);
1045                         request.setCharacterEncoding(utf8);
1046                         PrintWriter out = response.getWriter();
1047                         out.write(PolicyUtils.CATCH_EXCEPTION);
1048                 }
1049                 return null;
1050         }
1051         
1052     public static void setCommonClassDao(CommonClassDaoImpl commonClassDaoImpl) {
1053         commonClassDao = commonClassDaoImpl;
1054     }
1055
1056 }
1057