2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policy.pap.xacml.rest.controller;
23 import java.io.PrintWriter;
24 import java.net.UnknownHostException;
25 import java.util.ArrayList;
26 import java.util.Date;
27 import java.util.HashMap;
28 import java.util.LinkedHashMap;
29 import java.util.List;
32 import javax.servlet.http.HttpServletRequest;
33 import javax.servlet.http.HttpServletResponse;
35 import org.jboss.netty.handler.ipfilter.CIDR;
36 import org.json.JSONObject;
37 import org.onap.policy.common.logging.flexlogger.FlexLogger;
38 import org.onap.policy.common.logging.flexlogger.Logger;
39 import org.onap.policy.pap.xacml.rest.adapters.GridData;
40 import org.onap.policy.pap.xacml.rest.util.JsonMessage;
41 import org.onap.policy.rest.dao.CommonClassDao;
42 import org.onap.policy.rest.jpa.ActionList;
43 import org.onap.policy.rest.jpa.AddressGroup;
44 import org.onap.policy.rest.jpa.FWTag;
45 import org.onap.policy.rest.jpa.FWTagPicker;
46 import org.onap.policy.rest.jpa.FirewallDictionaryList;
47 import org.onap.policy.rest.jpa.GroupServiceList;
48 import org.onap.policy.rest.jpa.PrefixList;
49 import org.onap.policy.rest.jpa.PortList;
50 import org.onap.policy.rest.jpa.ProtocolList;
51 import org.onap.policy.rest.jpa.SecurityZone;
52 import org.onap.policy.rest.jpa.ServiceList;
53 import org.onap.policy.rest.jpa.TermList;
54 import org.onap.policy.rest.jpa.UserInfo;
55 import org.onap.policy.rest.jpa.Zone;
56 import org.onap.policy.xacml.api.XACMLErrorConstants;
57 import org.springframework.beans.factory.annotation.Autowired;
58 import org.springframework.http.MediaType;
59 import org.springframework.stereotype.Controller;
60 import org.springframework.web.bind.annotation.RequestMapping;
61 import org.springframework.web.servlet.ModelAndView;
63 import com.fasterxml.jackson.databind.DeserializationFeature;
64 import com.fasterxml.jackson.databind.JsonNode;
65 import com.fasterxml.jackson.databind.ObjectMapper;
69 public class FirewallDictionaryController {
71 private static final Logger LOGGER = FlexLogger.getLogger(FirewallDictionaryController.class);
73 private static CommonClassDao commonClassDao;
76 public FirewallDictionaryController(CommonClassDao commonClassDao){
77 FirewallDictionaryController.commonClassDao = commonClassDao;
80 public FirewallDictionaryController(){}
82 public UserInfo getUserInfo(String loginId){
83 UserInfo name = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
88 @RequestMapping(value={"/get_PrefixListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
89 public void getPrefixListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
91 Map<String, Object> model = new HashMap<>();
92 ObjectMapper mapper = new ObjectMapper();
93 model.put("prefixListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(PrefixList.class, "prefixListName")));
94 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
95 JSONObject j = new JSONObject(msg);
96 response.getWriter().write(j.toString());
99 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
103 @RequestMapping(value={"/get_PrefixListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
104 public void getPrefixListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
106 Map<String, Object> model = new HashMap<>();
107 ObjectMapper mapper = new ObjectMapper();
108 model.put("prefixListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(PrefixList.class)));
109 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
110 JSONObject j = new JSONObject(msg);
111 response.addHeader("successMapKey", "success");
112 response.addHeader("operation", "getDictionary");
113 response.getWriter().write(j.toString());
116 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
117 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
118 response.addHeader("error", "dictionaryDBQuery");
122 @RequestMapping(value={"/fw_dictionary/save_prefixList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
123 public ModelAndView savePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
125 boolean duplicateflag = false;
126 boolean isFakeUpdate = false;
127 boolean fromAPI = false;
128 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
131 ObjectMapper mapper = new ObjectMapper();
132 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
133 JsonNode root = mapper.readTree(request.getReader());
134 PrefixList prefixList;
136 prefixList = (PrefixList)mapper.readValue(root.get("dictionaryFields").toString(), PrefixList.class);
138 //check if update operation or create, get id for data to be updated and update attributeData
139 if (request.getParameter("operation").equals("update")) {
140 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(prefixList.getPrefixListName(), "prefixListName", PrefixList.class);
142 PrefixList data = (PrefixList) duplicateData.get(0);
148 prefixList.setId(id);
152 prefixList = (PrefixList)mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
154 if(prefixList.getId() == 0){
155 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(prefixList.getPrefixListName(), "prefixListName", PrefixList.class);
156 if(!duplicateData.isEmpty()){
157 duplicateflag = true;
159 commonClassDao.save(prefixList);
163 commonClassDao.update(prefixList);
166 String responseString = "";
168 responseString = "Duplicate";
170 responseString = mapper.writeValueAsString(commonClassDao.getData(PrefixList.class));
174 if (responseString!=null && !responseString.equals("Duplicate")) {
176 responseString = "Exists";
178 responseString = "Success";
181 ModelAndView result = new ModelAndView();
182 result.setViewName(responseString);
185 response.setCharacterEncoding("UTF-8");
186 response.setContentType("application / json");
187 request.setCharacterEncoding("UTF-8");
189 PrintWriter out = response.getWriter();
190 JSONObject j = new JSONObject("{prefixListDictionaryDatas: " + responseString + "}");
191 out.write(j.toString());
194 }catch (Exception e){
195 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
196 response.setCharacterEncoding("UTF-8");
197 request.setCharacterEncoding("UTF-8");
198 PrintWriter out = response.getWriter();
199 out.write(e.getMessage());
204 @RequestMapping(value={"/fw_dictionary/remove_PrefixList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
205 public ModelAndView removePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
207 ObjectMapper mapper = new ObjectMapper();
208 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
209 JsonNode root = mapper.readTree(request.getReader());
210 PrefixList prefixList = (PrefixList)mapper.readValue(root.get("data").toString(), PrefixList.class);
211 commonClassDao.delete(prefixList);
212 response.setCharacterEncoding("UTF-8");
213 response.setContentType("application / json");
214 request.setCharacterEncoding("UTF-8");
216 PrintWriter out = response.getWriter();
217 String responseString = mapper.writeValueAsString(commonClassDao.getData(PrefixList.class));
218 JSONObject j = new JSONObject("{prefixListDictionaryDatas: " + responseString + "}");
219 out.write(j.toString());
223 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
224 response.setCharacterEncoding("UTF-8");
225 request.setCharacterEncoding("UTF-8");
226 PrintWriter out = response.getWriter();
227 out.write(e.getMessage());
232 @RequestMapping(value={"/fw_dictionary/validate_prefixList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
233 public ModelAndView validatePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
235 ObjectMapper mapper = new ObjectMapper();
236 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
237 JsonNode root = mapper.readTree(request.getReader());
238 PrefixList prefixList = (PrefixList)mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
239 String responseValidation = "success";
241 CIDR.newCIDR(prefixList.getPrefixListValue());
242 }catch(UnknownHostException e){
243 responseValidation = "error";
245 response.setCharacterEncoding("UTF-8");
246 response.setContentType("application / json");
247 request.setCharacterEncoding("UTF-8");
249 PrintWriter out = response.getWriter();
250 JSONObject j = new JSONObject("{result: " + responseValidation + "}");
251 out.write(j.toString());
255 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
256 response.setCharacterEncoding("UTF-8");
257 request.setCharacterEncoding("UTF-8");
258 PrintWriter out = response.getWriter();
259 out.write(e.getMessage());
264 @RequestMapping(value={"/get_PortListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
265 public void getPortListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
267 Map<String, Object> model = new HashMap<>();
268 ObjectMapper mapper = new ObjectMapper();
269 model.put("portListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(PortList.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());
277 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
278 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
279 response.addHeader("error", "dictionaryDBQuery");
283 @RequestMapping(value={"/fw_dictionary/save_portName"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
284 public ModelAndView savePortListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
286 boolean duplicateflag = false;
287 ObjectMapper mapper = new ObjectMapper();
288 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
289 JsonNode root = mapper.readTree(request.getReader());
290 PortList portList = (PortList)mapper.readValue(root.get("portListDictionaryData").toString(), PortList.class);
291 if(portList.getId() == 0){
292 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(portList.getPortName(), "portName", PortList.class);
293 if(!duplicateData.isEmpty()){
294 duplicateflag = true;
296 commonClassDao.save(portList);
299 commonClassDao.update(portList);
301 response.setCharacterEncoding("UTF-8");
302 response.setContentType("application / json");
303 request.setCharacterEncoding("UTF-8");
305 PrintWriter out = response.getWriter();
306 String responseString = "";
308 responseString = "Duplicate";
310 responseString = mapper.writeValueAsString(commonClassDao.getData(PortList.class));
312 JSONObject j = new JSONObject("{portListDictionaryDatas: " + responseString + "}");
314 out.write(j.toString());
319 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
320 response.setCharacterEncoding("UTF-8");
321 request.setCharacterEncoding("UTF-8");
322 PrintWriter out = response.getWriter();
323 out.write(e.getMessage());
328 @RequestMapping(value={"/fw_dictionary/remove_PortList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
329 public ModelAndView removePortListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
331 ObjectMapper mapper = new ObjectMapper();
332 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
333 JsonNode root = mapper.readTree(request.getReader());
334 PortList portList = (PortList)mapper.readValue(root.get("data").toString(), PortList.class);
335 commonClassDao.delete(portList);
336 response.setCharacterEncoding("UTF-8");
337 response.setContentType("application / json");
338 request.setCharacterEncoding("UTF-8");
340 PrintWriter out = response.getWriter();
341 String responseString = mapper.writeValueAsString(commonClassDao.getData(PortList.class));
342 JSONObject j = new JSONObject("{portListDictionaryDatas: " + responseString + "}");
343 out.write(j.toString());
347 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
348 response.setCharacterEncoding("UTF-8");
349 request.setCharacterEncoding("UTF-8");
350 PrintWriter out = response.getWriter();
351 out.write(e.getMessage());
356 @RequestMapping(value={"/get_ProtocolListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
357 public void getProtocolListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
359 Map<String, Object> model = new HashMap<String, Object>();
360 ObjectMapper mapper = new ObjectMapper();
361 model.put("protocolListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(ProtocolList.class)));
362 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
363 JSONObject j = new JSONObject(msg);
364 response.addHeader("successMapKey", "success");
365 response.addHeader("operation", "getDictionary");
366 response.getWriter().write(j.toString());
369 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
370 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
371 response.addHeader("error", "dictionaryDBQuery");
375 @RequestMapping(value={"/get_ProtocolListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
376 public void getProtocolListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
378 Map<String, Object> model = new HashMap<String, Object>();
379 ObjectMapper mapper = new ObjectMapper();
380 model.put("protocolListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(ProtocolList.class, "protocolName")));
381 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
382 JSONObject j = new JSONObject(msg);
383 response.getWriter().write(j.toString());
386 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
390 @RequestMapping(value={"/fw_dictionary/save_protocolList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
391 public ModelAndView saveProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
393 boolean duplicateflag = false;
394 boolean isFakeUpdate = false;
395 boolean fromAPI = false;
396 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
399 ObjectMapper mapper = new ObjectMapper();
400 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
401 JsonNode root = mapper.readTree(request.getReader());
402 ProtocolList protocolList;
404 protocolList = (ProtocolList)mapper.readValue(root.get("dictionaryFields").toString(), ProtocolList.class);
406 //check if update operation or create, get id for data to be updated and update attributeData
407 if (request.getParameter("operation").equals("update")) {
408 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(protocolList.getProtocolName(), "protocolName", ProtocolList.class);
410 ProtocolList data = (ProtocolList) duplicateData.get(0);
414 protocolList.setId(1);
416 protocolList.setId(id);
420 protocolList = (ProtocolList)mapper.readValue(root.get("protocolListDictionaryData").toString(), ProtocolList.class);
422 if(protocolList.getId() == 0){
423 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(protocolList.getProtocolName(), "protocolName", ProtocolList.class);
424 if(!duplicateData.isEmpty()){
425 duplicateflag = true;
427 commonClassDao.save(protocolList);
431 commonClassDao.update(protocolList);
434 String responseString = "";
436 responseString = "Duplicate";
438 responseString = mapper.writeValueAsString(commonClassDao.getData(ProtocolList.class));
442 if (responseString!=null && !responseString.equals("Duplicate")) {
444 responseString = "Exists";
446 responseString = "Success";
449 ModelAndView result = new ModelAndView();
450 result.setViewName(responseString);
453 response.setCharacterEncoding("UTF-8");
454 response.setContentType("application / json");
455 request.setCharacterEncoding("UTF-8");
457 PrintWriter out = response.getWriter();
458 JSONObject j = new JSONObject("{protocolListDictionaryDatas: " + responseString + "}");
459 out.write(j.toString());
462 }catch (Exception e){
463 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
464 response.setCharacterEncoding("UTF-8");
465 request.setCharacterEncoding("UTF-8");
466 PrintWriter out = response.getWriter();
467 out.write(e.getMessage());
472 @RequestMapping(value={"/fw_dictionary/remove_protocol"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
473 public ModelAndView removeProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
475 ObjectMapper mapper = new ObjectMapper();
476 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
477 JsonNode root = mapper.readTree(request.getReader());
478 ProtocolList protocolList = (ProtocolList)mapper.readValue(root.get("data").toString(), ProtocolList.class);
479 commonClassDao.delete(protocolList);
480 response.setCharacterEncoding("UTF-8");
481 response.setContentType("application / json");
482 request.setCharacterEncoding("UTF-8");
484 PrintWriter out = response.getWriter();
486 String responseString = mapper.writeValueAsString(commonClassDao.getData(ProtocolList.class));
487 JSONObject j = new JSONObject("{protocolListDictionaryDatas: " + responseString + "}");
488 out.write(j.toString());
492 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
493 response.setCharacterEncoding("UTF-8");
494 request.setCharacterEncoding("UTF-8");
495 PrintWriter out = response.getWriter();
496 out.write(e.getMessage());
501 @RequestMapping(value={"/get_AddressGroupDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
502 public void getAddressGroupDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
504 Map<String, Object> model = new HashMap<>();
505 ObjectMapper mapper = new ObjectMapper();
506 model.put("addressGroupDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(AddressGroup.class, "name")));
507 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
508 JSONObject j = new JSONObject(msg);
509 response.getWriter().write(j.toString());
512 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
516 @RequestMapping(value={"/get_AddressGroupData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
517 public void getAddressGroupDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
519 Map<String, Object> model = new HashMap<>();
520 ObjectMapper mapper = new ObjectMapper();
521 model.put("addressGroupDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(AddressGroup.class)));
522 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
523 JSONObject j = new JSONObject(msg);
524 response.addHeader("successMapKey", "success");
525 response.addHeader("operation", "getDictionary");
526 response.getWriter().write(j.toString());
529 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
530 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
531 response.addHeader("error", "dictionaryDBQuery");
535 @RequestMapping(value={"/fw_dictionary/save_addressGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
536 public ModelAndView saveAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
538 boolean duplicateflag = false;
539 boolean isFakeUpdate = false;
540 boolean fromAPI = false;
541 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
544 ObjectMapper mapper = new ObjectMapper();
545 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
546 JsonNode root = mapper.readTree(request.getReader());
547 AddressGroup addressGroup;
550 addressGroup = (AddressGroup)mapper.readValue(root.get("dictionaryFields").toString(), AddressGroup.class);
551 gridData = (GridData)mapper.readValue(root.get("dictionaryFields").toString(), GridData.class);
553 if(!addressGroup.getGroupName().startsWith("Group_")){
554 String groupName = "Group_"+addressGroup.getGroupName();
555 addressGroup.setGroupName(groupName);
558 //check if update operation or create, get id for data to be updated and update attributeData
559 if (request.getParameter("operation").equals("update")) {
560 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(addressGroup.getGroupName(), "name", AddressGroup.class);
562 AddressGroup data = (AddressGroup) duplicateData.get(0);
566 addressGroup.setId(1);
568 addressGroup.setId(id);
572 addressGroup = (AddressGroup)mapper.readValue(root.get("addressGroupDictionaryData").toString(), AddressGroup.class);
573 gridData = (GridData)mapper.readValue(root.get("addressGroupDictionaryData").toString(), GridData.class);
574 if(!addressGroup.getGroupName().startsWith("Group_")){
575 String groupName = "Group_"+addressGroup.getGroupName();
576 addressGroup.setGroupName(groupName);
579 String userValue = "";
581 if(gridData.getAttributes().size() > 0){
582 for(Object attribute : gridData.getAttributes()){
583 if(attribute instanceof LinkedHashMap<?, ?>){
584 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
586 userValue = userValue + ",";
588 userValue = userValue + key ;
593 addressGroup.setServiceList(userValue);
594 if(addressGroup.getId() == 0){
595 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(addressGroup.getGroupName(), "name", AddressGroup.class);
596 if(!duplicateData.isEmpty()){
597 duplicateflag = true;
599 commonClassDao.save(addressGroup);
603 commonClassDao.update(addressGroup);
606 String responseString = "";
608 responseString = "Duplicate";
610 responseString = mapper.writeValueAsString(commonClassDao.getData(AddressGroup.class));
613 if (responseString!=null && !responseString.equals("Duplicate")) {
615 responseString = "Exists";
617 responseString = "Success";
620 ModelAndView result = new ModelAndView();
621 result.setViewName(responseString);
624 response.setCharacterEncoding("UTF-8");
625 response.setContentType("application / json");
626 request.setCharacterEncoding("UTF-8");
628 PrintWriter out = response.getWriter();
629 JSONObject j = new JSONObject("{addressGroupDictionaryDatas: " + responseString + "}");
630 out.write(j.toString());
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());
643 @RequestMapping(value={"/fw_dictionary/remove_AddressGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
644 public ModelAndView removeAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
646 ObjectMapper mapper = new ObjectMapper();
647 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
648 JsonNode root = mapper.readTree(request.getReader());
649 AddressGroup addressGroup = (AddressGroup)mapper.readValue(root.get("data").toString(), AddressGroup.class);
650 commonClassDao.delete(addressGroup);
651 response.setCharacterEncoding("UTF-8");
652 response.setContentType("application / json");
653 request.setCharacterEncoding("UTF-8");
655 PrintWriter out = response.getWriter();
657 String responseString = mapper.writeValueAsString(commonClassDao.getData(AddressGroup.class));
658 JSONObject j = new JSONObject("{addressGroupDictionaryDatas: " + responseString + "}");
659 out.write(j.toString());
663 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
664 response.setCharacterEncoding("UTF-8");
665 request.setCharacterEncoding("UTF-8");
666 PrintWriter out = response.getWriter();
667 out.write(e.getMessage());
672 @RequestMapping(value={"/get_ActionListDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
673 public void getActionListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
675 Map<String, Object> model = new HashMap<>();
676 ObjectMapper mapper = new ObjectMapper();
677 List<Object> list = commonClassDao.getData(ActionList.class);
678 List<String> dictList = new ArrayList<>();
679 for(int i = 0; i < list.size(); i++){
680 ActionList dict = (ActionList) list.get(i);
681 dictList.add(dict.getActionName());
683 model.put("actionListDictionaryDatas", mapper.writeValueAsString(dictList));
684 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
685 JSONObject j = new JSONObject(msg);
686 response.getWriter().write(j.toString());
689 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
693 @RequestMapping(value={"/get_ActionListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
694 public void getActionListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
696 Map<String, Object> model = new HashMap<>();
697 ObjectMapper mapper = new ObjectMapper();
698 model.put("actionListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(ActionList.class)));
699 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
700 JSONObject j = new JSONObject(msg);
701 response.addHeader("successMapKey", "success");
702 response.addHeader("operation", "getDictionary");
703 response.getWriter().write(j.toString());
706 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
707 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
708 response.addHeader("error", "dictionaryDBQuery");
712 @RequestMapping(value={"/fw_dictionary/save_ActionList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
713 public ModelAndView saveActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
715 boolean duplicateflag = false;
716 boolean isFakeUpdate = false;
717 boolean fromAPI = false;
718 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
721 ObjectMapper mapper = new ObjectMapper();
722 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
723 JsonNode root = mapper.readTree(request.getReader());
724 ActionList actionList;
726 actionList = (ActionList)mapper.readValue(root.get("dictionaryFields").toString(), ActionList.class);
728 //check if update operation or create, get id for data to be updated and update attributeData
729 if (request.getParameter("operation").equals("update")) {
730 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(actionList.getActionName(), "actionName", ActionList.class);
732 ActionList data = (ActionList) duplicateData.get(0);
738 actionList.setId(id);
742 actionList = (ActionList)mapper.readValue(root.get("actionListDictionaryData").toString(), ActionList.class);
744 if(actionList.getId() == 0){
745 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(actionList.getActionName(), "actionName", ActionList.class);
746 if(!duplicateData.isEmpty()){
747 duplicateflag = true;
749 commonClassDao.save(actionList);
753 commonClassDao.update(actionList);
756 String responseString = "";
758 responseString = "Duplicate";
760 responseString = mapper.writeValueAsString(commonClassDao.getData(ActionList.class));
764 if (responseString!=null && !responseString.equals("Duplicate")) {
766 responseString = "Exists";
768 responseString = "Success";
771 ModelAndView result = new ModelAndView();
772 result.setViewName(responseString);
775 response.setCharacterEncoding("UTF-8");
776 response.setContentType("application / json");
777 request.setCharacterEncoding("UTF-8");
779 PrintWriter out = response.getWriter();
780 JSONObject j = new JSONObject("{actionListDictionaryDatas: " + responseString + "}");
781 out.write(j.toString());
784 }catch (Exception e){
785 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
786 response.setCharacterEncoding("UTF-8");
787 request.setCharacterEncoding("UTF-8");
788 PrintWriter out = response.getWriter();
789 out.write(e.getMessage());
794 @RequestMapping(value={"/fw_dictionary/remove_ActionList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
795 public ModelAndView removeActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
797 ObjectMapper mapper = new ObjectMapper();
798 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
799 JsonNode root = mapper.readTree(request.getReader());
800 ActionList actionList = (ActionList)mapper.readValue(root.get("data").toString(), ActionList.class);
801 commonClassDao.delete(actionList);
802 response.setCharacterEncoding("UTF-8");
803 response.setContentType("application / json");
804 request.setCharacterEncoding("UTF-8");
806 PrintWriter out = response.getWriter();
807 String responseString = mapper.writeValueAsString(commonClassDao.getData(ActionList.class));
808 JSONObject j = new JSONObject("{actionListDictionaryDatas: " + responseString + "}");
809 out.write(j.toString());
813 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
814 response.setCharacterEncoding("UTF-8");
815 request.setCharacterEncoding("UTF-8");
816 PrintWriter out = response.getWriter();
817 out.write(e.getMessage());
822 @RequestMapping(value={"/get_ServiceGroupData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
823 public void getServiceGroupDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
825 Map<String, Object> model = new HashMap<>();
826 ObjectMapper mapper = new ObjectMapper();
827 model.put("serviceGroupDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(GroupServiceList.class)));
828 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
829 JSONObject j = new JSONObject(msg);
830 response.addHeader("successMapKey", "success");
831 response.addHeader("operation", "getDictionary");
832 response.getWriter().write(j.toString());
835 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
836 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
837 response.addHeader("error", "dictionaryDBQuery");
841 @RequestMapping(value={"/get_ServiceGroupDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
842 public void getServiceGroupDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
844 Map<String, Object> model = new HashMap<>();
845 ObjectMapper mapper = new ObjectMapper();
846 model.put("serviceGroupDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(GroupServiceList.class, "name")));
847 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
848 JSONObject j = new JSONObject(msg);
849 response.getWriter().write(j.toString());
852 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
856 @RequestMapping(value={"/fw_dictionary/save_serviceGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
857 public ModelAndView saveServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
859 boolean duplicateflag = false;
860 boolean isFakeUpdate = false;
861 boolean fromAPI = false;
862 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
865 ObjectMapper mapper = new ObjectMapper();
866 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
867 JsonNode root = mapper.readTree(request.getReader());
868 GroupServiceList groupServiceList;
871 groupServiceList = (GroupServiceList)mapper.readValue(root.get("dictionaryFields").toString(), GroupServiceList.class);
872 gridData = (GridData)mapper.readValue(root.get("dictionaryFields").toString(), GridData.class);
874 if(!groupServiceList.getGroupName().startsWith("Group_")){
875 String groupName = "Group_"+groupServiceList.getGroupName();
876 groupServiceList.setGroupName(groupName);
878 //check if update operation or create, get id for data to be updated and update attributeData
879 if (request.getParameter("operation").equals("update")) {
880 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(groupServiceList.getGroupName(), "name", GroupServiceList.class);
882 GroupServiceList data = (GroupServiceList) duplicateData.get(0);
887 groupServiceList.setId(1);
889 groupServiceList.setId(id);
893 groupServiceList = (GroupServiceList)mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GroupServiceList.class);
894 gridData = (GridData)mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GridData.class);
896 if(!groupServiceList.getGroupName().startsWith("Group_")){
897 String groupName = "Group_"+groupServiceList.getGroupName();
898 groupServiceList.setGroupName(groupName);
900 String userValue = "";
902 if(gridData.getAttributes().size() > 0){
903 for(Object attribute : gridData.getAttributes()){
904 if(attribute instanceof LinkedHashMap<?, ?>){
905 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
907 userValue = userValue + ",";
909 userValue = userValue + key ;
914 groupServiceList.setServiceList(userValue);
915 if(groupServiceList.getId() == 0){
916 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(groupServiceList.getGroupName(), "name", GroupServiceList.class);
917 if(!duplicateData.isEmpty()){
918 duplicateflag = true;
920 commonClassDao.save(groupServiceList);
924 commonClassDao.update(groupServiceList);
927 String responseString = "";
929 responseString = "Duplicate";
931 responseString = mapper.writeValueAsString(commonClassDao.getData(GroupServiceList.class));
935 if (responseString!=null && !responseString.equals("Duplicate")) {
937 responseString = "Exists";
939 responseString = "Success";
942 ModelAndView result = new ModelAndView();
943 result.setViewName(responseString);
946 response.setCharacterEncoding("UTF-8");
947 response.setContentType("application / json");
948 request.setCharacterEncoding("UTF-8");
950 PrintWriter out = response.getWriter();
951 JSONObject j = new JSONObject("{serviceGroupDictionaryDatas: " + responseString + "}");
952 out.write(j.toString());
955 }catch (Exception e){
956 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
957 response.setCharacterEncoding("UTF-8");
958 request.setCharacterEncoding("UTF-8");
959 PrintWriter out = response.getWriter();
960 out.write(e.getMessage());
965 @RequestMapping(value={"/fw_dictionary/remove_serviceGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
966 public ModelAndView removeServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
968 ObjectMapper mapper = new ObjectMapper();
969 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
970 JsonNode root = mapper.readTree(request.getReader());
971 GroupServiceList groupServiceList = (GroupServiceList)mapper.readValue(root.get("data").toString(), GroupServiceList.class);
972 commonClassDao.delete(groupServiceList);
973 response.setCharacterEncoding("UTF-8");
974 response.setContentType("application / json");
975 request.setCharacterEncoding("UTF-8");
977 PrintWriter out = response.getWriter();
979 String responseString = mapper.writeValueAsString(commonClassDao.getData(GroupServiceList.class));
980 JSONObject j = new JSONObject("{serviceGroupDictionaryDatas: " + responseString + "}");
981 out.write(j.toString());
986 System.out.println(e);
987 response.setCharacterEncoding("UTF-8");
988 request.setCharacterEncoding("UTF-8");
989 PrintWriter out = response.getWriter();
990 out.write(e.getMessage());
995 @RequestMapping(value={"/get_SecurityZoneDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
996 public void getSecurityZoneDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
998 Map<String, Object> model = new HashMap<>();
999 ObjectMapper mapper = new ObjectMapper();
1000 model.put("securityZoneDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(SecurityZone.class, "zoneName")));
1001 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1002 JSONObject j = new JSONObject(msg);
1003 response.getWriter().write(j.toString());
1005 catch (Exception e){
1006 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1010 @RequestMapping(value={"/get_SecurityZoneData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1011 public void getSecurityZoneDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
1013 Map<String, Object> model = new HashMap<>();
1014 ObjectMapper mapper = new ObjectMapper();
1015 model.put("securityZoneDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(SecurityZone.class)));
1016 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1017 JSONObject j = new JSONObject(msg);
1018 response.addHeader("successMapKey", "success");
1019 response.addHeader("operation", "getDictionary");
1020 response.getWriter().write(j.toString());
1022 catch (Exception e){
1023 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1024 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
1025 response.addHeader("error", "dictionaryDBQuery");
1029 @RequestMapping(value={"/fw_dictionary/save_securityZone"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1030 public ModelAndView saveSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
1032 boolean duplicateflag = false;
1033 boolean isFakeUpdate = false;
1034 boolean fromAPI = false;
1035 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
1038 ObjectMapper mapper = new ObjectMapper();
1039 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1040 JsonNode root = mapper.readTree(request.getReader());
1041 SecurityZone securityZone;
1043 securityZone = (SecurityZone)mapper.readValue(root.get("dictionaryFields").toString(), SecurityZone.class);
1045 //check if update operation or create, get id for data to be updated and update attributeData
1046 if (request.getParameter("operation").equals("update")) {
1047 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(securityZone.getZoneName(), "zoneName", SecurityZone.class);
1049 SecurityZone data = (SecurityZone) duplicateData.get(0);
1053 securityZone.setId(1);
1055 securityZone.setId(id);
1059 securityZone = (SecurityZone)mapper.readValue(root.get("securityZoneDictionaryData").toString(), SecurityZone.class);
1061 if(securityZone.getId() == 0){
1062 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(securityZone.getZoneName(), "zoneName", SecurityZone.class);
1063 if(!duplicateData.isEmpty()){
1064 duplicateflag = true;
1066 commonClassDao.save(securityZone);
1070 commonClassDao.update(securityZone);
1073 String responseString = "";
1075 responseString = "Duplicate";
1077 responseString = mapper.writeValueAsString(commonClassDao.getData(SecurityZone.class));
1081 if (responseString!=null && !responseString.equals("Duplicate")) {
1083 responseString = "Exists";
1085 responseString = "Success";
1088 ModelAndView result = new ModelAndView();
1089 result.setViewName(responseString);
1092 response.setCharacterEncoding("UTF-8");
1093 response.setContentType("application / json");
1094 request.setCharacterEncoding("UTF-8");
1096 PrintWriter out = response.getWriter();
1097 JSONObject j = new JSONObject("{securityZoneDictionaryDatas: " + responseString + "}");
1098 out.write(j.toString());
1102 }catch (Exception e){
1103 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1104 response.setCharacterEncoding("UTF-8");
1105 request.setCharacterEncoding("UTF-8");
1106 PrintWriter out = response.getWriter();
1107 out.write(e.getMessage());
1112 @RequestMapping(value={"/fw_dictionary/remove_securityZone"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1113 public ModelAndView removeSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
1115 ObjectMapper mapper = new ObjectMapper();
1116 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1117 JsonNode root = mapper.readTree(request.getReader());
1118 SecurityZone securityZone = (SecurityZone)mapper.readValue(root.get("data").toString(), SecurityZone.class);
1119 commonClassDao.delete(securityZone);
1120 response.setCharacterEncoding("UTF-8");
1121 response.setContentType("application / json");
1122 request.setCharacterEncoding("UTF-8");
1124 PrintWriter out = response.getWriter();
1126 String responseString = mapper.writeValueAsString(commonClassDao.getData(SecurityZone.class));
1127 JSONObject j = new JSONObject("{securityZoneDictionaryDatas: " + responseString + "}");
1128 out.write(j.toString());
1132 catch (Exception e){
1133 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1134 response.setCharacterEncoding("UTF-8");
1135 request.setCharacterEncoding("UTF-8");
1136 PrintWriter out = response.getWriter();
1137 out.write(e.getMessage());
1143 @RequestMapping(value={"/get_ServiceListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1144 public void getServiceListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
1146 Map<String, Object> model = new HashMap<>();
1147 ObjectMapper mapper = new ObjectMapper();
1148 model.put("serviceListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(ServiceList.class)));
1149 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1150 JSONObject j = new JSONObject(msg);
1151 response.addHeader("successMapKey", "success");
1152 response.addHeader("operation", "getDictionary");
1153 response.getWriter().write(j.toString());
1155 catch (Exception e){
1156 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1157 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
1158 response.addHeader("error", "dictionaryDBQuery");
1162 @RequestMapping(value={"/get_ServiceListDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1163 public void getServiceListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
1165 Map<String, Object> model = new HashMap<>();
1166 ObjectMapper mapper = new ObjectMapper();
1167 model.put("serviceListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(ServiceList.class, "serviceName")));
1168 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1169 JSONObject j = new JSONObject(msg);
1170 response.getWriter().write(j.toString());
1172 catch (Exception e){
1173 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1177 @RequestMapping(value={"/fw_dictionary/save_serviceList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1178 public ModelAndView saveServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
1180 boolean duplicateflag = false;
1181 boolean isFakeUpdate = false;
1182 boolean fromAPI = false;
1183 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
1186 ObjectMapper mapper = new ObjectMapper();
1187 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1188 JsonNode root = mapper.readTree(request.getReader());
1189 ServiceList serviceList;
1190 GridData serviceListGridData;
1192 serviceList = (ServiceList)mapper.readValue(root.get("dictionaryFields").toString(), ServiceList.class);
1193 serviceListGridData = (GridData)mapper.readValue(root.get("dictionaryFields").toString(), GridData.class);
1195 //check if update operation or create, get id for data to be updated and update attributeData
1196 if (request.getParameter("operation").equals("update")) {
1197 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(serviceList.getServiceName(), "serviceName", ServiceList.class);
1199 ServiceList data = (ServiceList) duplicateData.get(0);
1203 serviceList.setId(1);
1205 serviceList.setId(id);
1209 serviceList = (ServiceList)mapper.readValue(root.get("serviceListDictionaryData").toString(), ServiceList.class);
1210 serviceListGridData = (GridData)mapper.readValue(root.get("serviceListDictionaryData").toString(), GridData.class);
1212 String tcpValue = "";
1214 if(serviceListGridData.getTransportProtocols().size() > 0){
1215 for(Object attribute : serviceListGridData.getTransportProtocols()){
1216 if(attribute instanceof LinkedHashMap<?, ?>){
1217 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
1219 tcpValue = tcpValue + ",";
1221 tcpValue = tcpValue + key ;
1226 serviceList.setServiceTransProtocol(tcpValue);
1227 String appValue = "";
1229 if(serviceListGridData.getAppProtocols().size() > 0){
1230 for(Object attribute : serviceListGridData.getAppProtocols()){
1231 if(attribute instanceof LinkedHashMap<?, ?>){
1232 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
1234 appValue = appValue + ",";
1236 appValue = appValue + key ;
1241 serviceList.setServiceAppProtocol(appValue);
1242 serviceList.setServiceType("SERVICE");
1243 if(serviceList.getId() == 0){
1244 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(serviceList.getServiceName(), "serviceName", ServiceList.class);
1245 if(!duplicateData.isEmpty()){
1246 duplicateflag = true;
1248 commonClassDao.save(serviceList);
1252 commonClassDao.update(serviceList);
1256 String responseString = "";
1258 responseString = "Duplicate";
1260 responseString = mapper.writeValueAsString(commonClassDao.getData(ServiceList.class));
1263 if (responseString!=null && !responseString.equals("Duplicate")) {
1265 responseString = "Exists";
1267 responseString = "Success";
1270 ModelAndView result = new ModelAndView();
1271 result.setViewName(responseString);
1274 response.setCharacterEncoding("UTF-8");
1275 response.setContentType("application / json");
1276 request.setCharacterEncoding("UTF-8");
1278 PrintWriter out = response.getWriter();
1279 JSONObject j = new JSONObject("{serviceListDictionaryDatas: " + responseString + "}");
1280 out.write(j.toString());
1283 }catch (Exception e){
1284 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1285 response.setCharacterEncoding("UTF-8");
1286 request.setCharacterEncoding("UTF-8");
1287 PrintWriter out = response.getWriter();
1288 out.write(e.getMessage());
1294 @RequestMapping(value={"/fw_dictionary/remove_serviceList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1295 public ModelAndView removeServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
1297 ObjectMapper mapper = new ObjectMapper();
1298 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1299 JsonNode root = mapper.readTree(request.getReader());
1300 ServiceList serviceList = (ServiceList)mapper.readValue(root.get("data").toString(), ServiceList.class);
1301 commonClassDao.delete(serviceList);
1302 response.setCharacterEncoding("UTF-8");
1303 response.setContentType("application / json");
1304 request.setCharacterEncoding("UTF-8");
1306 PrintWriter out = response.getWriter();
1308 String responseString = mapper.writeValueAsString(commonClassDao.getData(ServiceList.class));
1309 JSONObject j = new JSONObject("{serviceListDictionaryDatas: " + responseString + "}");
1310 out.write(j.toString());
1314 catch (Exception e){
1315 System.out.println(e);
1316 response.setCharacterEncoding("UTF-8");
1317 request.setCharacterEncoding("UTF-8");
1318 PrintWriter out = response.getWriter();
1319 out.write(e.getMessage());
1324 @RequestMapping(value={"/get_ZoneData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1325 public void getZoneDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
1327 Map<String, Object> model = new HashMap<>();
1328 ObjectMapper mapper = new ObjectMapper();
1329 model.put("zoneDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(Zone.class)));
1330 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1331 JSONObject j = new JSONObject(msg);
1332 response.addHeader("successMapKey", "success");
1333 response.addHeader("operation", "getDictionary");
1334 response.getWriter().write(j.toString());
1336 catch (Exception e){
1337 LOGGER.error("Exception Occured"+e);
1341 @RequestMapping(value={"/get_ZoneDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1342 public void getZoneDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
1344 Map<String, Object> model = new HashMap<>();
1345 ObjectMapper mapper = new ObjectMapper();
1346 model.put("zoneDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(Zone.class, "zoneName")));
1347 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1348 JSONObject j = new JSONObject(msg);
1349 response.getWriter().write(j.toString());
1351 catch (Exception e){
1352 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1356 @RequestMapping(value={"/fw_dictionary/save_zoneName"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1357 public ModelAndView saveZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
1359 boolean duplicateflag = false;
1360 boolean isFakeUpdate = false;
1361 boolean fromAPI = false;
1362 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
1365 ObjectMapper mapper = new ObjectMapper();
1366 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1367 JsonNode root = mapper.readTree(request.getReader());
1370 zone = (Zone)mapper.readValue(root.get("dictionaryFields").toString(), Zone.class);
1372 //check if update operation or create, get id for data to be updated and update attributeData
1373 if (request.getParameter("operation").equals("update")) {
1374 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(zone.getZoneName(), "zoneName", Zone.class);
1376 Zone data = (Zone) duplicateData.get(0);
1386 zone = (Zone)mapper.readValue(root.get("zoneDictionaryData").toString(), Zone.class);
1388 if(zone.getId() == 0){
1389 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(zone.getZoneName(), "zoneName", Zone.class);
1390 if(!duplicateData.isEmpty()){
1391 duplicateflag = true;
1393 commonClassDao.save(zone);
1397 commonClassDao.update(zone);
1400 String responseString = "";
1402 responseString = "Duplicate";
1404 responseString = mapper.writeValueAsString(commonClassDao.getData(Zone.class));
1408 if (responseString!=null && !responseString.equals("Duplicate")) {
1410 responseString = "Exists";
1412 responseString = "Success";
1415 ModelAndView result = new ModelAndView();
1416 result.setViewName(responseString);
1419 response.setCharacterEncoding("UTF-8");
1420 response.setContentType("application / json");
1421 request.setCharacterEncoding("UTF-8");
1423 PrintWriter out = response.getWriter();
1424 JSONObject j = new JSONObject("{zoneDictionaryDatas: " + responseString + "}");
1425 out.write(j.toString());
1428 }catch (Exception e){
1429 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1430 response.setCharacterEncoding("UTF-8");
1431 request.setCharacterEncoding("UTF-8");
1432 PrintWriter out = response.getWriter();
1433 out.write(e.getMessage());
1438 @RequestMapping(value={"/fw_dictionary/remove_zone"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1439 public ModelAndView removeZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
1441 ObjectMapper mapper = new ObjectMapper();
1442 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1443 JsonNode root = mapper.readTree(request.getReader());
1444 Zone zone = (Zone)mapper.readValue(root.get("data").toString(), Zone.class);
1445 commonClassDao.delete(zone);
1446 response.setCharacterEncoding("UTF-8");
1447 response.setContentType("application / json");
1448 request.setCharacterEncoding("UTF-8");
1450 PrintWriter out = response.getWriter();
1452 String responseString = mapper.writeValueAsString(commonClassDao.getData(Zone.class));
1453 JSONObject j = new JSONObject("{zoneDictionaryDatas: " + responseString + "}");
1454 out.write(j.toString());
1458 catch (Exception e){
1459 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1460 response.setCharacterEncoding("UTF-8");
1461 request.setCharacterEncoding("UTF-8");
1462 PrintWriter out = response.getWriter();
1463 out.write(e.getMessage());
1468 @RequestMapping(value={"/get_TermListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1469 public void getTermListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
1471 Map<String, Object> model = new HashMap<String, Object>();
1472 ObjectMapper mapper = new ObjectMapper();
1473 model.put("termListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(TermList.class, "termName")));
1474 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1475 JSONObject j = new JSONObject(msg);
1476 response.getWriter().write(j.toString());
1478 catch (Exception e){
1479 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1483 @RequestMapping(value={"/get_TermListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1484 public void getTermListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
1486 Map<String, Object> model = new HashMap<String, Object>();
1487 ObjectMapper mapper = new ObjectMapper();
1488 model.put("termListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(TermList.class)));
1489 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1490 JSONObject j = new JSONObject(msg);
1491 response.addHeader("successMapKey", "success");
1492 response.addHeader("operation", "getDictionary");
1493 response.getWriter().write(j.toString());
1495 catch (Exception e){
1496 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1497 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
1498 response.addHeader("error", "dictionaryDBQuery");
1502 @RequestMapping(value={"/fw_dictionary/save_termList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1503 public ModelAndView saveTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
1505 boolean duplicateflag = false;
1506 boolean isFakeUpdate = false;
1507 boolean fromAPI = false;
1508 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
1511 ObjectMapper mapper = new ObjectMapper();
1512 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1513 JsonNode root = mapper.readTree(request.getReader());
1515 TermListData termListDatas;
1516 String userId = null;
1518 termList = (TermList)mapper.readValue(root.get("dictionaryFields").toString(), TermList.class);
1519 termListDatas = (TermListData)mapper.readValue(root.get("dictionaryFields").toString(), TermListData.class);
1522 //check if update operation or create, get id for data to be updated and update attributeData
1523 if (request.getParameter("operation").equals("update")) {
1524 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(termList.getTermName(), "termName", TermList.class);
1526 TermList data = (TermList) duplicateData.get(0);
1534 termList.setUserCreatedBy(this.getUserInfo(userId));
1537 termList = (TermList)mapper.readValue(root.get("termListDictionaryData").toString(), TermList.class);
1538 termListDatas = (TermListData)mapper.readValue(root.get("termListDictionaryData").toString(), TermListData.class);
1539 userId = root.get("userid").textValue();
1541 String fromZoneValue = "";
1543 if(termListDatas.getFromZoneDatas().size() > 0){
1544 for(Object fromZone : termListDatas.getFromZoneDatas()){
1545 if(fromZone instanceof LinkedHashMap<?, ?>){
1546 String key = ((LinkedHashMap<?, ?>) fromZone).get("option").toString();
1548 fromZoneValue = fromZoneValue + ",";
1550 fromZoneValue = fromZoneValue + key ;
1555 termList.setFromZones(fromZoneValue);
1557 String toZoneValue = "";
1558 int toZonecounter = 0;
1559 if(termListDatas.getToZoneDatas().size() > 0){
1560 for(Object toZone : termListDatas.getToZoneDatas()){
1561 if(toZone instanceof LinkedHashMap<?, ?>){
1562 String key = ((LinkedHashMap<?, ?>) toZone).get("option").toString();
1563 if(toZonecounter>0){
1564 toZoneValue = toZoneValue + ",";
1566 toZoneValue = toZoneValue + key ;
1571 termList.setToZones(toZoneValue);
1573 String srcListValues = "";
1574 int srcListcounter = 0;
1575 if(termListDatas.getSourceListDatas().size() > 0){
1576 for(Object srcList : termListDatas.getSourceListDatas()){
1577 if(srcList instanceof LinkedHashMap<?, ?>){
1578 String key = ((LinkedHashMap<?, ?>) srcList).get("option").toString();
1579 if(srcListcounter>0){
1580 srcListValues = srcListValues + ",";
1582 srcListValues = srcListValues + key ;
1587 termList.setSrcIPList(srcListValues);
1589 String desListValues = "";
1590 int destListcounter = 0;
1591 if(termListDatas.getDestinationListDatas().size() > 0){
1592 for(Object desList : termListDatas.getDestinationListDatas()){
1593 if(desList instanceof LinkedHashMap<?, ?>){
1594 String key = ((LinkedHashMap<?, ?>) desList).get("option").toString();
1595 if(destListcounter>0){
1596 desListValues = desListValues + ",";
1598 desListValues = desListValues + key ;
1603 termList.setDestIPList(desListValues);
1605 String srcSerValue = "";
1606 int srcSercounter = 0;
1607 if(termListDatas.getSourceServiceDatas().size() > 0){
1608 for(Object srcSrc : termListDatas.getSourceServiceDatas()){
1609 if(srcSrc instanceof LinkedHashMap<?, ?>){
1610 String key = ((LinkedHashMap<?, ?>) srcSrc).get("option").toString();
1611 if(srcSercounter>0){
1612 srcSerValue = srcSerValue + ",";
1614 srcSerValue = srcSerValue + key ;
1619 termList.setSrcPortList(srcSerValue);
1621 String desSrcValue = "";
1622 int desSrccounter = 0;
1623 if(termListDatas.getDestinationServiceDatas().size() > 0){
1624 for(Object desSrc : termListDatas.getDestinationServiceDatas()){
1625 if(desSrc instanceof LinkedHashMap<?, ?>){
1626 String key = ((LinkedHashMap<?, ?>) desSrc).get("option").toString();
1627 if(desSrccounter>0){
1628 desSrcValue = desSrcValue + ",";
1630 desSrcValue = desSrcValue + key ;
1635 termList.setDestPortList(desSrcValue);
1637 String actionValue = "";
1638 int actioncounter = 0;
1639 if(termListDatas.getActionListDatas().size() > 0){
1640 for(Object actionList : termListDatas.getActionListDatas()){
1641 if(actionList instanceof LinkedHashMap<?, ?>){
1642 String key = ((LinkedHashMap<?, ?>) actionList).get("option").toString();
1643 if(actioncounter>0){
1644 actionValue = actionValue + ",";
1646 actionValue = actionValue + key ;
1651 termList.setAction(actionValue);
1653 if(termList.getId() == 0){
1654 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(termList.getTermName(), "termName", TermList.class);
1655 if(!duplicateData.isEmpty()){
1656 duplicateflag = true;
1658 termList.setUserCreatedBy(this.getUserInfo(userId));
1659 termList.setUserModifiedBy(this.getUserInfo(userId));
1660 commonClassDao.save(termList);
1664 termList.setUserModifiedBy(this.getUserInfo(userId));
1665 commonClassDao.update(termList);
1668 String responseString = "";
1670 responseString = "Duplicate";
1672 responseString = mapper.writeValueAsString(commonClassDao.getData(TermList.class));
1676 if (responseString!=null && !responseString.equals("Duplicate")) {
1678 responseString = "Exists";
1680 responseString = "Success";
1683 ModelAndView result = new ModelAndView();
1684 result.setViewName(responseString);
1687 response.setCharacterEncoding("UTF-8");
1688 response.setContentType("application / json");
1689 request.setCharacterEncoding("UTF-8");
1691 PrintWriter out = response.getWriter();
1692 JSONObject j = new JSONObject("{termListDictionaryDatas: " + responseString + "}");
1693 out.write(j.toString());
1696 }catch (Exception e){
1697 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1698 response.setCharacterEncoding("UTF-8");
1699 request.setCharacterEncoding("UTF-8");
1700 PrintWriter out = response.getWriter();
1701 out.write(e.getMessage());
1706 @RequestMapping(value={"/fw_dictionary/remove_termList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1707 public ModelAndView removeTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
1709 ObjectMapper mapper = new ObjectMapper();
1710 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1711 JsonNode root = mapper.readTree(request.getReader());
1712 TermList termList = (TermList)mapper.readValue(root.get("data").toString(), TermList.class);
1713 commonClassDao.delete(termList);
1714 response.setCharacterEncoding("UTF-8");
1715 response.setContentType("application / json");
1716 request.setCharacterEncoding("UTF-8");
1718 PrintWriter out = response.getWriter();
1720 String responseString = mapper.writeValueAsString(commonClassDao.getData(TermList.class));
1721 JSONObject j = new JSONObject("{termListDictionaryDatas: " + responseString + "}");
1722 out.write(j.toString());
1726 catch (Exception e){
1727 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1728 response.setCharacterEncoding("UTF-8");
1729 request.setCharacterEncoding("UTF-8");
1730 PrintWriter out = response.getWriter();
1731 out.write(e.getMessage());
1735 //ParentList Dictionary Data
1736 @RequestMapping(value={"/get_FWDictionaryListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1737 public void getFWDictListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
1739 Map<String, Object> model = new HashMap<>();
1740 ObjectMapper mapper = new ObjectMapper();
1741 model.put("fwDictListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(FirewallDictionaryList.class, "parentItemName")));
1742 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1743 JSONObject j = new JSONObject(msg);
1744 response.getWriter().write(j.toString());
1746 catch (Exception e){
1747 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1751 @RequestMapping(value={"/get_FWDictionaryListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1752 public void getFWDictionaryListEntityData(HttpServletRequest request, HttpServletResponse response){
1754 Map<String, Object> model = new HashMap<>();
1755 ObjectMapper mapper = new ObjectMapper();
1756 model.put("fwDictListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class)));
1757 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1758 JSONObject j = new JSONObject(msg);
1759 response.addHeader("successMapKey", "success");
1760 response.addHeader("operation", "getDictionary");
1761 response.getWriter().write(j.toString());
1763 catch (Exception e){
1764 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1765 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
1766 response.addHeader("error", "dictionaryDBQuery");
1770 @RequestMapping(value={"/fw_dictionary/save_FWDictionaryList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1771 public ModelAndView saveFWDictionaryList(HttpServletRequest request, HttpServletResponse response) throws Exception{
1773 boolean duplicateflag = false;
1774 ObjectMapper mapper = new ObjectMapper();
1775 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1776 JsonNode root = mapper.readTree(request.getReader());
1777 FirewallDictionaryList fwDictList = (FirewallDictionaryList)mapper.readValue(root.get("fwDictListDictionaryData").toString(), FirewallDictionaryList.class);
1778 GridData gridData = (GridData)mapper.readValue(root.get("fwDictListDictionaryData").toString(), GridData.class);
1779 String userSLValue = "";
1781 if(gridData.getAttributes().size() > 0){
1782 for(Object attribute : gridData.getAttributes()){
1783 if(attribute instanceof LinkedHashMap<?, ?>){
1784 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
1786 userSLValue = userSLValue + ",";
1788 userSLValue = userSLValue + key ;
1793 fwDictList.setServiceList(userSLValue);
1794 String userALValue = "";
1796 if(gridData.getAlAttributes().size() > 0){
1797 for(Object attribute : gridData.getAlAttributes()){
1798 if(attribute instanceof LinkedHashMap<?, ?>){
1799 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
1801 userALValue = userALValue + ",";
1803 userALValue = userALValue + key ;
1808 fwDictList.setAddressList(userALValue);
1809 if(fwDictList.getId() == 0){
1810 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwDictList.getParentItemName(), "parentItemName", FirewallDictionaryList.class);
1811 if(!duplicateData.isEmpty()){
1812 duplicateflag = true;
1814 commonClassDao.save(fwDictList);
1817 commonClassDao.update(fwDictList);
1819 response.setCharacterEncoding("UTF-8");
1820 response.setContentType("application / json");
1821 request.setCharacterEncoding("UTF-8");
1823 PrintWriter out = response.getWriter();
1824 String responseString = "";
1826 responseString = "Duplicate";
1828 responseString = mapper.writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class));
1830 JSONObject j = new JSONObject("{fwDictListDictionaryDatas: " + responseString + "}");
1832 out.write(j.toString());
1836 catch (Exception e){
1837 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1838 response.setCharacterEncoding("UTF-8");
1839 request.setCharacterEncoding("UTF-8");
1840 PrintWriter out = response.getWriter();
1841 out.write(e.getMessage());
1846 @RequestMapping(value={"/fw_dictionary/remove_FWDictionaryList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1847 public ModelAndView removeFWDictionaryListy(HttpServletRequest request, HttpServletResponse response) throws Exception {
1849 ObjectMapper mapper = new ObjectMapper();
1850 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1851 JsonNode root = mapper.readTree(request.getReader());
1852 FirewallDictionaryList fwDictList = (FirewallDictionaryList)mapper.readValue(root.get("data").toString(), FirewallDictionaryList.class);
1853 commonClassDao.delete(fwDictList);
1854 response.setCharacterEncoding("UTF-8");
1855 response.setContentType("application / json");
1856 request.setCharacterEncoding("UTF-8");
1858 PrintWriter out = response.getWriter();
1860 String responseString = mapper.writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class));
1861 JSONObject j = new JSONObject("{fwDictListDictionaryDatas: " + responseString + "}");
1862 out.write(j.toString());
1866 catch (Exception e){
1867 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1868 response.setCharacterEncoding("UTF-8");
1869 request.setCharacterEncoding("UTF-8");
1870 PrintWriter out = response.getWriter();
1871 out.write(e.getMessage());
1877 @RequestMapping(value={"/get_TagPickerNameByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1878 public void getTagPickerNameEntityDataByName(HttpServletRequest request, HttpServletResponse response){
1880 Map<String, Object> model = new HashMap<String, Object>();
1881 ObjectMapper mapper = new ObjectMapper();
1882 model.put("fwTagPickerDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(FWTagPicker.class, "tagPickerName")));
1883 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1884 JSONObject j = new JSONObject(msg);
1885 response.getWriter().write(j.toString());
1887 catch (Exception e){
1888 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1892 @RequestMapping(value={"/get_TagPickerListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1893 public void getTagPickerDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
1895 Map<String, Object> model = new HashMap<String, Object>();
1896 ObjectMapper mapper = new ObjectMapper();
1897 model.put("fwTagPickerDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(FWTagPicker.class)));
1898 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1899 JSONObject j = new JSONObject(msg);
1900 response.getWriter().write(j.toString());
1902 catch (Exception e){
1903 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1907 @RequestMapping(value={"/fw_dictionary/save_fwTagPicker"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1908 public ModelAndView saveFirewallTagPickerDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
1910 boolean duplicateflag = false;
1911 boolean fromAPI = false;
1912 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
1916 ObjectMapper mapper = new ObjectMapper();
1917 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1918 JsonNode root = mapper.readTree(request.getReader());
1921 FWTagPicker fwTagPicker;
1923 String userId = null;
1925 fwTagPicker = (FWTagPicker)mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), FWTagPicker.class);
1926 data = (TagGridValues)mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), TagGridValues.class);
1929 //check if update operation or create, get id for data to be updated and update attributeData
1930 if (request.getParameter("operation").equals("update")) {
1931 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTagPicker.getTagPickerName(), "tagPickerName", FWTagPicker.class);
1933 FWTagPicker dbdata = (FWTagPicker) duplicateData.get(0);
1934 id = dbdata.getId();
1935 fwTagPicker.setId(id);
1936 fwTagPicker.setUserCreatedBy(this.getUserInfo(userId));
1940 fwTagPicker = (FWTagPicker)mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), FWTagPicker.class);
1941 data = (TagGridValues)mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), TagGridValues.class);
1942 userId = root.get("userid").textValue();
1947 if(data.getTags().size() > 0){
1948 for(Object attribute : data.getTags()){
1949 if(attribute instanceof LinkedHashMap<?, ?>){
1950 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
1951 String value = ((LinkedHashMap<?, ?>) attribute).get("number").toString();
1953 header = header + "#";
1955 header = header + key + ":";
1956 header = header + value;
1961 fwTagPicker.setTagValues(header);
1962 if(fwTagPicker.getId() == 0){
1963 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTagPicker.getTagPickerName(), "tagPickerName", FWTagPicker.class);
1964 if(!duplicateData.isEmpty()){
1965 duplicateflag = true;
1967 fwTagPicker.setUserCreatedBy(this.getUserInfo(userId));
1968 fwTagPicker.setUserModifiedBy(this.getUserInfo(userId));
1969 commonClassDao.save(fwTagPicker);
1972 fwTagPicker.setUserModifiedBy(this.getUserInfo(userId));
1973 fwTagPicker.setModifiedDate(new Date());
1974 commonClassDao.update(fwTagPicker);
1977 String responseString = "";
1979 responseString = "Duplicate";
1981 responseString = mapper.writeValueAsString(commonClassDao.getData(FWTagPicker.class));
1985 if (responseString!=null && !responseString.equals("Duplicate")) {
1986 responseString = "Success";
1988 ModelAndView result = new ModelAndView();
1989 result.setViewName(responseString);
1992 response.setCharacterEncoding("UTF-8");
1993 response.setContentType("application / json");
1994 request.setCharacterEncoding("UTF-8");
1996 PrintWriter out = response.getWriter();
1997 JSONObject j = new JSONObject("{fwTagPickerDictionaryDatas: " + responseString + "}");
1998 out.write(j.toString());
2002 catch (Exception e){
2003 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2004 response.setCharacterEncoding("UTF-8");
2005 request.setCharacterEncoding("UTF-8");
2006 PrintWriter out = response.getWriter();
2007 out.write(e.getMessage());
2012 @RequestMapping(value={"/fw_dictionary/remove_tagPicker"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
2013 public ModelAndView removeFirewallTagPickerDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
2015 ObjectMapper mapper = new ObjectMapper();
2016 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2017 JsonNode root = mapper.readTree(request.getReader());
2018 FWTagPicker fwTagPicker = (FWTagPicker)mapper.readValue(root.get("data").toString(), FWTagPicker.class);
2019 commonClassDao.delete(fwTagPicker);
2020 response.setCharacterEncoding("UTF-8");
2021 response.setContentType("application / json");
2022 request.setCharacterEncoding("UTF-8");
2024 PrintWriter out = response.getWriter();
2025 String responseString = mapper.writeValueAsString(commonClassDao.getData(FWTagPicker.class));
2026 JSONObject j = new JSONObject("{fwTagPickerDictionaryDatas: " + responseString + "}");
2027 out.write(j.toString());
2030 catch (Exception e){
2031 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2032 response.setCharacterEncoding("UTF-8");
2033 request.setCharacterEncoding("UTF-8");
2034 PrintWriter out = response.getWriter();
2035 out.write(e.getMessage());
2041 @RequestMapping(value={"/get_TagNameByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
2042 public void getTagNameEntityDataByName(HttpServletRequest request, HttpServletResponse response){
2044 Map<String, Object> model = new HashMap<>();
2045 ObjectMapper mapper = new ObjectMapper();
2046 model.put("fwTagDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(FWTag.class, "fwTagName")));
2047 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
2048 JSONObject j = new JSONObject(msg);
2049 response.getWriter().write(j.toString());
2051 catch (Exception e){
2052 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2056 @RequestMapping(value={"/get_TagListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
2057 public void getTagDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
2059 Map<String, Object> model = new HashMap<>();
2060 ObjectMapper mapper = new ObjectMapper();
2061 model.put("fwTagDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(FWTag.class)));
2062 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
2063 JSONObject j = new JSONObject(msg);
2064 response.getWriter().write(j.toString());
2066 catch (Exception e){
2067 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2071 @RequestMapping(value={"/fw_dictionary/save_fwTag"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
2072 public ModelAndView saveFirewallTagDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
2074 boolean duplicateflag = false;
2075 boolean fromAPI = false;
2076 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
2080 ObjectMapper mapper = new ObjectMapper();
2081 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2082 JsonNode root = mapper.readTree(request.getReader());
2086 TagGridValues tagGridValues;
2087 String userId = null;
2089 fwTag = (FWTag)mapper.readValue(root.get("fwTagDictionaryDatas").toString(), FWTag.class);
2090 tagGridValues = (TagGridValues)mapper.readValue(root.get("fwTagDictionaryDatas").toString(), TagGridValues.class);
2093 //check if update operation or create, get id for data to be updated and update attributeData
2094 if (request.getParameter("operation").equals("update")) {
2095 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTag.getFwTagName(), "tagName", FWTag.class);
2097 FWTag data = (FWTag) duplicateData.get(0);
2100 fwTag.setUserCreatedBy(this.getUserInfo(userId));
2104 fwTag = (FWTag)mapper.readValue(root.get("fwTagDictionaryData").toString(), FWTag.class);
2105 tagGridValues = (TagGridValues)mapper.readValue(root.get("fwTagDictionaryData").toString(), TagGridValues.class);
2106 userId = root.get("userid").textValue();
2109 String userValue = "";
2111 if(tagGridValues.getTags().size() > 0){
2112 for(Object attribute : tagGridValues.getTags()){
2113 if(attribute instanceof LinkedHashMap<?, ?>){
2114 String key = ((LinkedHashMap<?, ?>) attribute).get("tags").toString();
2116 userValue = userValue + ",";
2118 userValue = userValue + key ;
2123 fwTag.setTagValues(userValue);
2124 if(fwTag.getId() == 0){
2125 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTag.getFwTagName(), "fwTagName", FWTag.class);
2126 if(!duplicateData.isEmpty()){
2127 duplicateflag = true;
2129 fwTag.setUserCreatedBy(this.getUserInfo(userId));
2130 fwTag.setUserModifiedBy(this.getUserInfo(userId));
2131 commonClassDao.save(fwTag);
2134 fwTag.setUserModifiedBy(this.getUserInfo(userId));
2135 fwTag.setModifiedDate(new Date());
2136 commonClassDao.update(fwTag);
2139 String responseString = "";
2141 responseString = "Duplicate";
2143 responseString = mapper.writeValueAsString(commonClassDao.getData(FWTag.class));
2146 if (responseString!=null && !responseString.equals("Duplicate")) {
2147 responseString = "Success";
2149 ModelAndView result = new ModelAndView();
2150 result.setViewName(responseString);
2154 response.setCharacterEncoding("UTF-8");
2155 response.setContentType("application / json");
2156 request.setCharacterEncoding("UTF-8");
2158 PrintWriter out = response.getWriter();
2159 JSONObject j = new JSONObject("{fwTagDictionaryDatas: " + responseString + "}");
2160 out.write(j.toString());
2164 catch (Exception e){
2165 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2166 response.setCharacterEncoding("UTF-8");
2167 request.setCharacterEncoding("UTF-8");
2168 PrintWriter out = response.getWriter();
2169 out.write(e.getMessage());
2174 @RequestMapping(value={"/fw_dictionary/remove_tagList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
2175 public ModelAndView removeFirewallTagDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
2177 ObjectMapper mapper = new ObjectMapper();
2178 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2179 JsonNode root = mapper.readTree(request.getReader());
2180 FWTag fwTag = (FWTag)mapper.readValue(root.get("data").toString(), FWTag.class);
2181 commonClassDao.delete(fwTag);
2182 response.setCharacterEncoding("UTF-8");
2183 response.setContentType("application / json");
2184 request.setCharacterEncoding("UTF-8");
2186 PrintWriter out = response.getWriter();
2188 String responseString = mapper.writeValueAsString(commonClassDao.getData(FWTag.class));
2189 JSONObject j = new JSONObject("{fwTagDictionaryDatas: " + responseString + "}");
2190 out.write(j.toString());
2194 catch (Exception e){
2195 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2196 response.setCharacterEncoding("UTF-8");
2197 request.setCharacterEncoding("UTF-8");
2198 PrintWriter out = response.getWriter();
2199 out.write(e.getMessage());
2205 class TagGridValues{
2206 private ArrayList<Object> tags;
2208 public ArrayList<Object> getTags() {
2212 public void setTags(ArrayList<Object> tags) {
2218 private ArrayList<Object> attributes;
2220 public ArrayList<Object> getAttributes() {
2224 public void setAttributes(ArrayList<Object> attributes) {
2225 this.attributes = attributes;
2230 private ArrayList<Object> fromZoneDatas;
2231 private ArrayList<Object> toZoneDatas;
2232 private ArrayList<Object> sourceListDatas;
2233 private ArrayList<Object> destinationListDatas;
2234 private ArrayList<Object> sourceServiceDatas;
2235 private ArrayList<Object> destinationServiceDatas;
2236 private ArrayList<Object> actionListDatas;
2237 public ArrayList<Object> getFromZoneDatas() {
2238 return fromZoneDatas;
2240 public void setFromZoneDatas(ArrayList<Object> fromZoneDatas) {
2241 this.fromZoneDatas = fromZoneDatas;
2243 public ArrayList<Object> getToZoneDatas() {
2246 public void setToZoneDatas(ArrayList<Object> toZoneDatas) {
2247 this.toZoneDatas = toZoneDatas;
2249 public ArrayList<Object> getSourceListDatas() {
2250 return sourceListDatas;
2252 public void setSourceListDatas(ArrayList<Object> sourceListDatas) {
2253 this.sourceListDatas = sourceListDatas;
2255 public ArrayList<Object> getDestinationListDatas() {
2256 return destinationListDatas;
2258 public void setDestinationListDatas(ArrayList<Object> destinationListDatas) {
2259 this.destinationListDatas = destinationListDatas;
2261 public ArrayList<Object> getSourceServiceDatas() {
2262 return sourceServiceDatas;
2264 public void setSourceServiceDatas(ArrayList<Object> sourceServiceDatas) {
2265 this.sourceServiceDatas = sourceServiceDatas;
2267 public ArrayList<Object> getDestinationServiceDatas() {
2268 return destinationServiceDatas;
2270 public void setDestinationServiceDatas(ArrayList<Object> destinationServiceDatas) {
2271 this.destinationServiceDatas = destinationServiceDatas;
2273 public ArrayList<Object> getActionListDatas() {
2274 return actionListDatas;
2276 public void setActionListDatas(ArrayList<Object> actionListDatas) {
2277 this.actionListDatas = actionListDatas;