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