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