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