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.IOException;
24 import java.io.PrintWriter;
25 import java.net.UnknownHostException;
26 import java.util.ArrayList;
27 import java.util.Date;
28 import java.util.HashMap;
29 import java.util.LinkedHashMap;
30 import java.util.List;
33 import javax.servlet.http.HttpServletRequest;
34 import javax.servlet.http.HttpServletResponse;
36 import org.jboss.netty.handler.ipfilter.CIDR;
37 import org.json.JSONObject;
38 import org.onap.policy.common.logging.flexlogger.FlexLogger;
39 import org.onap.policy.common.logging.flexlogger.Logger;
40 import org.onap.policy.pap.xacml.rest.adapters.GridData;
41 import org.onap.policy.pap.xacml.rest.util.JsonMessage;
42 import org.onap.policy.rest.dao.CommonClassDao;
43 import org.onap.policy.rest.jpa.ActionList;
44 import org.onap.policy.rest.jpa.AddressGroup;
45 import org.onap.policy.rest.jpa.FWTag;
46 import org.onap.policy.rest.jpa.FWTagPicker;
47 import org.onap.policy.rest.jpa.FirewallDictionaryList;
48 import org.onap.policy.rest.jpa.GroupServiceList;
49 import org.onap.policy.rest.jpa.PrefixList;
50 import org.onap.policy.rest.jpa.PortList;
51 import org.onap.policy.rest.jpa.ProtocolList;
52 import org.onap.policy.rest.jpa.SecurityZone;
53 import org.onap.policy.rest.jpa.ServiceList;
54 import org.onap.policy.rest.jpa.TermList;
55 import org.onap.policy.rest.jpa.UserInfo;
56 import org.onap.policy.rest.jpa.Zone;
57 import org.onap.policy.xacml.api.XACMLErrorConstants;
58 import org.springframework.beans.factory.annotation.Autowired;
59 import org.springframework.http.MediaType;
60 import org.springframework.stereotype.Controller;
61 import org.springframework.web.bind.annotation.RequestMapping;
62 import org.springframework.web.servlet.ModelAndView;
64 import com.fasterxml.jackson.databind.DeserializationFeature;
65 import com.fasterxml.jackson.databind.JsonNode;
66 import com.fasterxml.jackson.databind.ObjectMapper;
70 public class FirewallDictionaryController {
72 private static final Logger LOGGER = FlexLogger.getLogger(FirewallDictionaryController.class);
74 private static CommonClassDao commonClassDao;
75 private static String prefixListName = "prefixListName";
76 private static String successMapKey = "successMapKey";
77 private static String successMessage = "success";
78 private static String operation = "operation";
79 private static String getDictionary = "getDictionary";
80 private static String errorMsg = "error";
81 private static String dictionaryDBQuery = "dictionaryDBQuery";
82 private static String apiflag = "apiflag";
83 private static String dictionaryFields ="dictionaryFields";
84 private static String update = "update";
85 private static String duplicateResponseString = "Duplicate";
86 private static String successMsg = "Success";
87 private static String utf8 = "UTF-8";
88 private static String applicationJsonContentType = "application / json";
89 private static String existsResponseString = "Exists";
90 private static String protocolName = "protocolName";
91 private static String groupNameStart = "Group_";
92 private static String option = "option";
93 private static String zoneName = "zoneName";
94 private static String serviceName = "serviceName";
95 private static String termName = "termName";
96 private static String userid = "userid";
97 private static String tagPickerName = "tagPickerName";
98 private static String fwTagPickerDictionaryData = "fwTagPickerDictionaryData";
99 private static String fwTagDictionaryDatas = "fwTagDictionaryDatas";
103 public FirewallDictionaryController(CommonClassDao commonClassDao){
104 FirewallDictionaryController.commonClassDao = commonClassDao;
107 public static void setCommonClassDao(CommonClassDao clDao){
108 commonClassDao = clDao;
112 * This is an empty constructor
114 public FirewallDictionaryController(){}
116 public UserInfo getUserInfo(String loginId){
117 return (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
121 @RequestMapping(value={"/get_PrefixListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
122 public void getPrefixListDictionaryEntityDataByName(HttpServletResponse response){
124 Map<String, Object> model = new HashMap<>();
125 ObjectMapper mapper = new ObjectMapper();
126 model.put("prefixListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(PrefixList.class, prefixListName)));
127 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
128 JSONObject j = new JSONObject(msg);
129 response.getWriter().write(j.toString());
132 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
136 @RequestMapping(value={"/get_PrefixListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
137 public void getPrefixListDictionaryEntityData(HttpServletResponse response){
139 Map<String, Object> model = new HashMap<>();
140 ObjectMapper mapper = new ObjectMapper();
141 model.put("prefixListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(PrefixList.class)));
142 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
143 JSONObject j = new JSONObject(msg);
144 response.addHeader(successMapKey, successMessage);
145 response.addHeader(operation, getDictionary);
146 response.getWriter().write(j.toString());
149 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW, e);
150 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
151 response.addHeader(errorMsg, dictionaryDBQuery);
155 @RequestMapping(value={"/fw_dictionary/save_prefixList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
156 public ModelAndView savePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
158 boolean duplicateflag = false;
159 boolean isFakeUpdate = false;
160 boolean fromAPI = false;
161 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
164 ObjectMapper mapper = new ObjectMapper();
165 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
166 JsonNode root = mapper.readTree(request.getReader());
167 PrefixList prefixList;
169 prefixList = (PrefixList)mapper.readValue(root.get(dictionaryFields).toString(), PrefixList.class);
171 //check if update operation or create, get id for data to be updated and update attributeData
172 if ((update).equals(request.getParameter(operation))) {
173 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(prefixList.getPrefixListName(), prefixListName, PrefixList.class);
174 PrefixList data = (PrefixList) duplicateData.get(0);
175 int id = data.getId();
180 prefixList.setId(id);
184 prefixList = (PrefixList)mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
186 if(prefixList.getId() == 0){
187 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(prefixList.getPrefixListName(), prefixListName, PrefixList.class);
188 if(!duplicateData.isEmpty()){
189 duplicateflag = true;
191 commonClassDao.save(prefixList);
195 commonClassDao.update(prefixList);
198 String responseString = "";
200 responseString = duplicateResponseString;
202 responseString = mapper.writeValueAsString(commonClassDao.getData(PrefixList.class));
206 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
208 responseString = existsResponseString;
210 responseString = successMsg;
213 ModelAndView result = new ModelAndView();
214 result.setViewName(responseString);
217 response.setCharacterEncoding(utf8);
218 response.setContentType(applicationJsonContentType);
219 request.setCharacterEncoding(utf8);
221 PrintWriter out = response.getWriter();
222 JSONObject j = new JSONObject("{prefixListDictionaryDatas: " + responseString + "}");
223 out.write(j.toString());
226 }catch (Exception e){
227 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW, e);
228 response.setCharacterEncoding(utf8);
229 request.setCharacterEncoding(utf8);
230 PrintWriter out = response.getWriter();
231 out.write(e.getMessage());
236 @RequestMapping(value={"/fw_dictionary/remove_PrefixList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
237 public ModelAndView removePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
239 ObjectMapper mapper = new ObjectMapper();
240 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
241 JsonNode root = mapper.readTree(request.getReader());
242 PrefixList prefixList = (PrefixList)mapper.readValue(root.get("data").toString(), PrefixList.class);
243 commonClassDao.delete(prefixList);
244 response.setCharacterEncoding(utf8);
245 response.setContentType(applicationJsonContentType);
246 request.setCharacterEncoding(utf8);
248 PrintWriter out = response.getWriter();
249 String responseString = mapper.writeValueAsString(commonClassDao.getData(PrefixList.class));
250 JSONObject j = new JSONObject("{prefixListDictionaryDatas: " + responseString + "}");
251 out.write(j.toString());
255 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
256 response.setCharacterEncoding(utf8);
257 request.setCharacterEncoding(utf8);
258 PrintWriter out = response.getWriter();
259 out.write(e.getMessage());
264 @RequestMapping(value={"/fw_dictionary/validate_prefixList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
265 public ModelAndView validatePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
267 ObjectMapper mapper = new ObjectMapper();
268 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
269 JsonNode root = mapper.readTree(request.getReader());
270 PrefixList prefixList = (PrefixList)mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
271 String responseValidation = successMessage;
273 CIDR.newCIDR(prefixList.getPrefixListValue());
274 }catch(UnknownHostException e){
276 responseValidation = errorMsg;
278 response.setCharacterEncoding(utf8);
279 response.setContentType(applicationJsonContentType);
280 request.setCharacterEncoding(utf8);
282 PrintWriter out = response.getWriter();
283 JSONObject j = new JSONObject("{result: " + responseValidation + "}");
284 out.write(j.toString());
288 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
289 response.setCharacterEncoding(utf8);
290 request.setCharacterEncoding(utf8);
291 PrintWriter out = response.getWriter();
292 out.write(e.getMessage());
297 @RequestMapping(value={"/get_PortListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
298 public void getPortListDictionaryEntityData(HttpServletResponse response){
300 Map<String, Object> model = new HashMap<>();
301 ObjectMapper mapper = new ObjectMapper();
302 model.put("portListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(PortList.class)));
303 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
304 JSONObject j = new JSONObject(msg);
305 response.addHeader(successMapKey, successMessage);
306 response.addHeader(operation, getDictionary);
307 response.getWriter().write(j.toString());
310 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
311 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
312 response.addHeader(errorMsg, dictionaryDBQuery);
316 @RequestMapping(value={"/fw_dictionary/save_portName"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
317 public ModelAndView savePortListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
319 boolean duplicateflag = false;
320 ObjectMapper mapper = new ObjectMapper();
321 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
322 JsonNode root = mapper.readTree(request.getReader());
323 PortList portList = (PortList)mapper.readValue(root.get("portListDictionaryData").toString(), PortList.class);
324 if(portList.getId() == 0){
325 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(portList.getPortName(), "portName", PortList.class);
326 if(!duplicateData.isEmpty()){
327 duplicateflag = true;
329 commonClassDao.save(portList);
332 commonClassDao.update(portList);
334 response.setCharacterEncoding(utf8);
335 response.setContentType(applicationJsonContentType);
336 request.setCharacterEncoding(utf8);
338 PrintWriter out = response.getWriter();
339 String responseString = "";
341 responseString = duplicateResponseString;
343 responseString = mapper.writeValueAsString(commonClassDao.getData(PortList.class));
345 JSONObject j = new JSONObject("{portListDictionaryDatas: " + responseString + "}");
347 out.write(j.toString());
352 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
353 response.setCharacterEncoding(utf8);
354 request.setCharacterEncoding(utf8);
355 PrintWriter out = response.getWriter();
356 out.write(e.getMessage());
361 @RequestMapping(value={"/fw_dictionary/remove_PortList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
362 public ModelAndView removePortListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
364 ObjectMapper mapper = new ObjectMapper();
365 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
366 JsonNode root = mapper.readTree(request.getReader());
367 PortList portList = (PortList)mapper.readValue(root.get("data").toString(), PortList.class);
368 commonClassDao.delete(portList);
369 response.setCharacterEncoding(utf8);
370 response.setContentType(applicationJsonContentType);
371 request.setCharacterEncoding(utf8);
373 PrintWriter out = response.getWriter();
374 String responseString = mapper.writeValueAsString(commonClassDao.getData(PortList.class));
375 JSONObject j = new JSONObject("{portListDictionaryDatas: " + responseString + "}");
376 out.write(j.toString());
380 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
381 response.setCharacterEncoding(utf8);
382 request.setCharacterEncoding(utf8);
383 PrintWriter out = response.getWriter();
384 out.write(e.getMessage());
389 @RequestMapping(value={"/get_ProtocolListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
390 public void getProtocolListDictionaryEntityData(HttpServletResponse response){
392 Map<String, Object> model = new HashMap<>();
393 ObjectMapper mapper = new ObjectMapper();
394 model.put("protocolListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(ProtocolList.class)));
395 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
396 JSONObject j = new JSONObject(msg);
397 response.addHeader(successMapKey, successMessage);
398 response.addHeader(operation, getDictionary);
399 response.getWriter().write(j.toString());
402 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
403 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
404 response.addHeader(errorMsg, dictionaryDBQuery);
408 @RequestMapping(value={"/get_ProtocolListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
409 public void getProtocolListDictionaryEntityDataByName(HttpServletResponse response){
411 Map<String, Object> model = new HashMap<>();
412 ObjectMapper mapper = new ObjectMapper();
413 model.put("protocolListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(ProtocolList.class, protocolName)));
414 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
415 JSONObject j = new JSONObject(msg);
416 response.getWriter().write(j.toString());
419 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
423 @RequestMapping(value={"/fw_dictionary/save_protocolList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
424 public ModelAndView saveProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
426 boolean duplicateflag = false;
427 boolean isFakeUpdate = false;
428 boolean fromAPI = false;
429 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
432 ObjectMapper mapper = new ObjectMapper();
433 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
434 JsonNode root = mapper.readTree(request.getReader());
435 ProtocolList protocolList;
437 protocolList = (ProtocolList)mapper.readValue(root.get(dictionaryFields).toString(), ProtocolList.class);
439 //check if update operation or create, get id for data to be updated and update attributeData
440 if ((update).equals(request.getParameter(operation))) {
441 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(protocolList.getProtocolName(), protocolName, ProtocolList.class);
442 ProtocolList data = (ProtocolList) duplicateData.get(0);
443 int id = data.getId();
446 protocolList.setId(1);
448 protocolList.setId(id);
452 protocolList = (ProtocolList)mapper.readValue(root.get("protocolListDictionaryData").toString(), ProtocolList.class);
454 if(protocolList.getId() == 0){
455 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(protocolList.getProtocolName(), protocolName, ProtocolList.class);
456 if(!duplicateData.isEmpty()){
457 duplicateflag = true;
459 commonClassDao.save(protocolList);
463 commonClassDao.update(protocolList);
466 String responseString = "";
468 responseString = duplicateResponseString;
470 responseString = mapper.writeValueAsString(commonClassDao.getData(ProtocolList.class));
474 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
476 responseString = existsResponseString;
478 responseString = successMsg;
481 ModelAndView result = new ModelAndView();
482 result.setViewName(responseString);
485 response.setCharacterEncoding(utf8);
486 response.setContentType(applicationJsonContentType);
487 request.setCharacterEncoding(utf8);
489 PrintWriter out = response.getWriter();
490 JSONObject j = new JSONObject("{protocolListDictionaryDatas: " + responseString + "}");
491 out.write(j.toString());
494 }catch (Exception e){
495 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
496 response.setCharacterEncoding(utf8);
497 request.setCharacterEncoding(utf8);
498 PrintWriter out = response.getWriter();
499 out.write(e.getMessage());
504 @RequestMapping(value={"/fw_dictionary/remove_protocol"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
505 public ModelAndView removeProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
507 ObjectMapper mapper = new ObjectMapper();
508 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
509 JsonNode root = mapper.readTree(request.getReader());
510 ProtocolList protocolList = (ProtocolList)mapper.readValue(root.get("data").toString(), ProtocolList.class);
511 commonClassDao.delete(protocolList);
512 response.setCharacterEncoding(utf8);
513 response.setContentType(applicationJsonContentType);
514 request.setCharacterEncoding(utf8);
516 PrintWriter out = response.getWriter();
518 String responseString = mapper.writeValueAsString(commonClassDao.getData(ProtocolList.class));
519 JSONObject j = new JSONObject("{protocolListDictionaryDatas: " + responseString + "}");
520 out.write(j.toString());
524 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
525 response.setCharacterEncoding(utf8);
526 request.setCharacterEncoding(utf8);
527 PrintWriter out = response.getWriter();
528 out.write(e.getMessage());
533 @RequestMapping(value={"/get_AddressGroupDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
534 public void getAddressGroupDictionaryEntityDataByName(HttpServletResponse response){
536 Map<String, Object> model = new HashMap<>();
537 ObjectMapper mapper = new ObjectMapper();
538 model.put("addressGroupDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(AddressGroup.class, "name")));
539 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
540 JSONObject j = new JSONObject(msg);
541 response.getWriter().write(j.toString());
544 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
548 @RequestMapping(value={"/get_AddressGroupData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
549 public void getAddressGroupDictionaryEntityData(HttpServletResponse response){
551 Map<String, Object> model = new HashMap<>();
552 ObjectMapper mapper = new ObjectMapper();
553 model.put("addressGroupDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(AddressGroup.class)));
554 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
555 JSONObject j = new JSONObject(msg);
556 response.addHeader(successMapKey, successMessage);
557 response.addHeader(operation, getDictionary);
558 response.getWriter().write(j.toString());
561 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
562 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
563 response.addHeader(errorMsg, dictionaryDBQuery);
567 @RequestMapping(value={"/fw_dictionary/save_addressGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
568 public ModelAndView saveAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
570 boolean duplicateflag = false;
571 boolean isFakeUpdate = false;
572 boolean fromAPI = false;
573 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
576 ObjectMapper mapper = new ObjectMapper();
577 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
578 JsonNode root = mapper.readTree(request.getReader());
579 AddressGroup addressGroup;
582 addressGroup = (AddressGroup)mapper.readValue(root.get(dictionaryFields).toString(), AddressGroup.class);
583 gridData = (GridData)mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
585 if(!addressGroup.getGroupName().startsWith(groupNameStart)){
586 String groupName = groupNameStart+addressGroup.getGroupName();
587 addressGroup.setGroupName(groupName);
590 //check if update operation or create, get id for data to be updated and update attributeData
591 if ((update).equals(request.getParameter(operation))) {
592 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(addressGroup.getGroupName(), "name", AddressGroup.class);
593 AddressGroup data = (AddressGroup) duplicateData.get(0);
594 int id = data.getId();
597 addressGroup.setId(1);
599 addressGroup.setId(id);
603 addressGroup = (AddressGroup)mapper.readValue(root.get("addressGroupDictionaryData").toString(), AddressGroup.class);
604 gridData = (GridData)mapper.readValue(root.get("addressGroupDictionaryData").toString(), GridData.class);
605 if(!addressGroup.getGroupName().startsWith(groupNameStart)){
606 String groupName = groupNameStart+addressGroup.getGroupName();
607 addressGroup.setGroupName(groupName);
610 String userValue = "";
612 if(!gridData.getAttributes().isEmpty()){
613 for(Object attribute : gridData.getAttributes()){
614 if(attribute instanceof LinkedHashMap<?, ?>){
615 String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
617 userValue = userValue + ",";
619 userValue = userValue + key ;
624 addressGroup.setServiceList(userValue);
625 if(addressGroup.getId() == 0){
626 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(addressGroup.getGroupName(), "name", AddressGroup.class);
627 if(!duplicateData.isEmpty()){
628 duplicateflag = true;
630 commonClassDao.save(addressGroup);
634 commonClassDao.update(addressGroup);
637 String responseString = "";
639 responseString = duplicateResponseString;
641 responseString = mapper.writeValueAsString(commonClassDao.getData(AddressGroup.class));
644 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
646 responseString = existsResponseString;
648 responseString = successMsg;
651 ModelAndView result = new ModelAndView();
652 result.setViewName(responseString);
655 response.setCharacterEncoding(utf8);
656 response.setContentType(applicationJsonContentType);
657 request.setCharacterEncoding(utf8);
659 PrintWriter out = response.getWriter();
660 JSONObject j = new JSONObject("{addressGroupDictionaryDatas: " + responseString + "}");
661 out.write(j.toString());
664 }catch (Exception e){
665 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
666 response.setCharacterEncoding(utf8);
667 request.setCharacterEncoding(utf8);
668 PrintWriter out = response.getWriter();
669 out.write(e.getMessage());
674 @RequestMapping(value={"/fw_dictionary/remove_AddressGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
675 public ModelAndView removeAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
677 ObjectMapper mapper = new ObjectMapper();
678 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
679 JsonNode root = mapper.readTree(request.getReader());
680 AddressGroup addressGroup = (AddressGroup)mapper.readValue(root.get("data").toString(), AddressGroup.class);
681 commonClassDao.delete(addressGroup);
682 response.setCharacterEncoding(utf8);
683 response.setContentType(applicationJsonContentType);
684 request.setCharacterEncoding(utf8);
686 PrintWriter out = response.getWriter();
688 String responseString = mapper.writeValueAsString(commonClassDao.getData(AddressGroup.class));
689 JSONObject j = new JSONObject("{addressGroupDictionaryDatas: " + responseString + "}");
690 out.write(j.toString());
694 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
695 response.setCharacterEncoding(utf8);
696 request.setCharacterEncoding(utf8);
697 PrintWriter out = response.getWriter();
698 out.write(e.getMessage());
703 @RequestMapping(value={"/get_ActionListDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
704 public void getActionListDictionaryEntityDataByName(HttpServletResponse response){
706 Map<String, Object> model = new HashMap<>();
707 ObjectMapper mapper = new ObjectMapper();
708 List<Object> list = commonClassDao.getData(ActionList.class);
709 List<String> dictList = new ArrayList<>();
710 for(int i = 0; i < list.size(); i++){
711 ActionList dict = (ActionList) list.get(i);
712 dictList.add(dict.getActionName());
714 model.put("actionListDictionaryDatas", mapper.writeValueAsString(dictList));
715 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
716 JSONObject j = new JSONObject(msg);
717 response.getWriter().write(j.toString());
720 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
724 @RequestMapping(value={"/get_ActionListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
725 public void getActionListDictionaryEntityData(HttpServletResponse response){
727 Map<String, Object> model = new HashMap<>();
728 ObjectMapper mapper = new ObjectMapper();
729 model.put("actionListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(ActionList.class)));
730 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
731 JSONObject j = new JSONObject(msg);
732 response.addHeader(successMapKey, successMessage);
733 response.addHeader(operation, getDictionary);
734 response.getWriter().write(j.toString());
737 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
738 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
739 response.addHeader(errorMsg, dictionaryDBQuery);
743 @RequestMapping(value={"/fw_dictionary/save_ActionList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
744 public ModelAndView saveActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
746 boolean duplicateflag = false;
747 boolean isFakeUpdate = false;
748 boolean fromAPI = false;
749 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
752 ObjectMapper mapper = new ObjectMapper();
753 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
754 JsonNode root = mapper.readTree(request.getReader());
755 ActionList actionList;
757 actionList = (ActionList)mapper.readValue(root.get(dictionaryFields).toString(), ActionList.class);
759 //check if update operation or create, get id for data to be updated and update attributeData
760 if ((update).equals(request.getParameter(operation))) {
761 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(actionList.getActionName(), "actionName", ActionList.class);
762 ActionList data = (ActionList) duplicateData.get(0);
763 int id = data.getId();
768 actionList.setId(id);
772 actionList = (ActionList)mapper.readValue(root.get("actionListDictionaryData").toString(), ActionList.class);
774 if(actionList.getId() == 0){
775 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(actionList.getActionName(), "actionName", ActionList.class);
776 if(!duplicateData.isEmpty()){
777 duplicateflag = true;
779 commonClassDao.save(actionList);
783 commonClassDao.update(actionList);
786 String responseString = "";
788 responseString = duplicateResponseString;
790 responseString = mapper.writeValueAsString(commonClassDao.getData(ActionList.class));
794 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
796 responseString = existsResponseString;
798 responseString = successMsg;
801 ModelAndView result = new ModelAndView();
802 result.setViewName(responseString);
805 response.setCharacterEncoding(utf8);
806 response.setContentType(applicationJsonContentType);
807 request.setCharacterEncoding(utf8);
809 PrintWriter out = response.getWriter();
810 JSONObject j = new JSONObject("{actionListDictionaryDatas: " + responseString + "}");
811 out.write(j.toString());
814 }catch (Exception e){
815 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
816 response.setCharacterEncoding(utf8);
817 request.setCharacterEncoding(utf8);
818 PrintWriter out = response.getWriter();
819 out.write(e.getMessage());
824 @RequestMapping(value={"/fw_dictionary/remove_ActionList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
825 public ModelAndView removeActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
827 ObjectMapper mapper = new ObjectMapper();
828 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
829 JsonNode root = mapper.readTree(request.getReader());
830 ActionList actionList = (ActionList)mapper.readValue(root.get("data").toString(), ActionList.class);
831 commonClassDao.delete(actionList);
832 response.setCharacterEncoding(utf8);
833 response.setContentType(applicationJsonContentType);
834 request.setCharacterEncoding(utf8);
836 PrintWriter out = response.getWriter();
837 String responseString = mapper.writeValueAsString(commonClassDao.getData(ActionList.class));
838 JSONObject j = new JSONObject("{actionListDictionaryDatas: " + responseString + "}");
839 out.write(j.toString());
843 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
844 response.setCharacterEncoding(utf8);
845 request.setCharacterEncoding(utf8);
846 PrintWriter out = response.getWriter();
847 out.write(e.getMessage());
852 @RequestMapping(value={"/get_ServiceGroupData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
853 public void getServiceGroupDictionaryEntityData(HttpServletResponse response){
855 Map<String, Object> model = new HashMap<>();
856 ObjectMapper mapper = new ObjectMapper();
857 model.put("serviceGroupDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(GroupServiceList.class)));
858 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
859 JSONObject j = new JSONObject(msg);
860 response.addHeader(successMapKey, successMessage);
861 response.addHeader(operation, getDictionary);
862 response.getWriter().write(j.toString());
865 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
866 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
867 response.addHeader(errorMsg, dictionaryDBQuery);
871 @RequestMapping(value={"/get_ServiceGroupDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
872 public void getServiceGroupDictionaryEntityDataByName(HttpServletResponse response){
874 Map<String, Object> model = new HashMap<>();
875 ObjectMapper mapper = new ObjectMapper();
876 model.put("serviceGroupDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(GroupServiceList.class, "name")));
877 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
878 JSONObject j = new JSONObject(msg);
879 response.getWriter().write(j.toString());
882 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
886 @RequestMapping(value={"/fw_dictionary/save_serviceGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
887 public ModelAndView saveServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
889 boolean duplicateflag = false;
890 boolean isFakeUpdate = false;
891 boolean fromAPI = false;
892 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
895 ObjectMapper mapper = new ObjectMapper();
896 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
897 JsonNode root = mapper.readTree(request.getReader());
898 GroupServiceList groupServiceList;
901 groupServiceList = (GroupServiceList)mapper.readValue(root.get(dictionaryFields).toString(), GroupServiceList.class);
902 gridData = (GridData)mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
904 if(!groupServiceList.getGroupName().startsWith(groupNameStart)){
905 String groupName = groupNameStart+groupServiceList.getGroupName();
906 groupServiceList.setGroupName(groupName);
908 //check if update operation or create, get id for data to be updated and update attributeData
909 if ((update).equals(request.getParameter(operation))) {
910 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(groupServiceList.getGroupName(), "name", GroupServiceList.class);
911 GroupServiceList data = (GroupServiceList) duplicateData.get(0);
912 int id = data.getId();
916 groupServiceList.setId(1);
918 groupServiceList.setId(id);
922 groupServiceList = (GroupServiceList)mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GroupServiceList.class);
923 gridData = (GridData)mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GridData.class);
925 if(!groupServiceList.getGroupName().startsWith(groupNameStart)){
926 String groupName = groupNameStart+groupServiceList.getGroupName();
927 groupServiceList.setGroupName(groupName);
929 String userValue = "";
931 if(!gridData.getAttributes().isEmpty()){
932 for(Object attribute : gridData.getAttributes()){
933 if(attribute instanceof LinkedHashMap<?, ?>){
934 String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
936 userValue = userValue + ",";
938 userValue = userValue + key ;
943 groupServiceList.setServiceList(userValue);
944 if(groupServiceList.getId() == 0){
945 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(groupServiceList.getGroupName(), "name", GroupServiceList.class);
946 if(!duplicateData.isEmpty()){
947 duplicateflag = true;
949 commonClassDao.save(groupServiceList);
953 commonClassDao.update(groupServiceList);
956 String responseString = "";
958 responseString = duplicateResponseString;
960 responseString = mapper.writeValueAsString(commonClassDao.getData(GroupServiceList.class));
964 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
966 responseString = existsResponseString;
968 responseString = successMsg;
971 ModelAndView result = new ModelAndView();
972 result.setViewName(responseString);
975 response.setCharacterEncoding(utf8);
976 response.setContentType(applicationJsonContentType);
977 request.setCharacterEncoding(utf8);
979 PrintWriter out = response.getWriter();
980 JSONObject j = new JSONObject("{serviceGroupDictionaryDatas: " + responseString + "}");
981 out.write(j.toString());
984 }catch (Exception e){
985 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
986 response.setCharacterEncoding(utf8);
987 request.setCharacterEncoding(utf8);
988 PrintWriter out = response.getWriter();
989 out.write(e.getMessage());
994 @RequestMapping(value={"/fw_dictionary/remove_serviceGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
995 public ModelAndView removeServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
997 ObjectMapper mapper = new ObjectMapper();
998 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
999 JsonNode root = mapper.readTree(request.getReader());
1000 GroupServiceList groupServiceList = (GroupServiceList)mapper.readValue(root.get("data").toString(), GroupServiceList.class);
1001 commonClassDao.delete(groupServiceList);
1002 response.setCharacterEncoding(utf8);
1003 response.setContentType(applicationJsonContentType);
1004 request.setCharacterEncoding(utf8);
1006 PrintWriter out = response.getWriter();
1008 String responseString = mapper.writeValueAsString(commonClassDao.getData(GroupServiceList.class));
1009 JSONObject j = new JSONObject("{serviceGroupDictionaryDatas: " + responseString + "}");
1010 out.write(j.toString());
1014 catch (Exception e){
1016 response.setCharacterEncoding(utf8);
1017 request.setCharacterEncoding(utf8);
1018 PrintWriter out = response.getWriter();
1019 out.write(e.getMessage());
1024 @RequestMapping(value={"/get_SecurityZoneDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1025 public void getSecurityZoneDictionaryEntityDataByName(HttpServletResponse response){
1027 Map<String, Object> model = new HashMap<>();
1028 ObjectMapper mapper = new ObjectMapper();
1029 model.put("securityZoneDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(SecurityZone.class, zoneName)));
1030 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1031 JSONObject j = new JSONObject(msg);
1032 response.getWriter().write(j.toString());
1034 catch (Exception e){
1035 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1039 @RequestMapping(value={"/get_SecurityZoneData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1040 public void getSecurityZoneDictionaryEntityData(HttpServletResponse response){
1042 Map<String, Object> model = new HashMap<>();
1043 ObjectMapper mapper = new ObjectMapper();
1044 model.put("securityZoneDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(SecurityZone.class)));
1045 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1046 JSONObject j = new JSONObject(msg);
1047 response.addHeader(successMapKey, successMessage);
1048 response.addHeader(operation, getDictionary);
1049 response.getWriter().write(j.toString());
1051 catch (Exception e){
1052 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1053 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
1054 response.addHeader(errorMsg, dictionaryDBQuery);
1058 @RequestMapping(value={"/fw_dictionary/save_securityZone"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1059 public ModelAndView saveSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
1061 boolean duplicateflag = false;
1062 boolean isFakeUpdate = false;
1063 boolean fromAPI = false;
1064 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
1067 ObjectMapper mapper = new ObjectMapper();
1068 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1069 JsonNode root = mapper.readTree(request.getReader());
1070 SecurityZone securityZone;
1072 securityZone = (SecurityZone)mapper.readValue(root.get(dictionaryFields).toString(), SecurityZone.class);
1074 //check if update operation or create, get id for data to be updated and update attributeData
1075 if ((update).equals(request.getParameter(operation))) {
1076 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(securityZone.getZoneName(), zoneName, SecurityZone.class);
1077 SecurityZone data = (SecurityZone) duplicateData.get(0);
1078 int id = data.getId();
1081 securityZone.setId(1);
1083 securityZone.setId(id);
1087 securityZone = (SecurityZone)mapper.readValue(root.get("securityZoneDictionaryData").toString(), SecurityZone.class);
1089 if(securityZone.getId() == 0){
1090 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(securityZone.getZoneName(), zoneName, SecurityZone.class);
1091 if(!duplicateData.isEmpty()){
1092 duplicateflag = true;
1094 commonClassDao.save(securityZone);
1098 commonClassDao.update(securityZone);
1101 String responseString = "";
1103 responseString = duplicateResponseString;
1105 responseString = mapper.writeValueAsString(commonClassDao.getData(SecurityZone.class));
1109 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
1111 responseString = existsResponseString;
1113 responseString = successMsg;
1116 ModelAndView result = new ModelAndView();
1117 result.setViewName(responseString);
1120 response.setCharacterEncoding(utf8);
1121 response.setContentType(applicationJsonContentType);
1122 request.setCharacterEncoding(utf8);
1124 PrintWriter out = response.getWriter();
1125 JSONObject j = new JSONObject("{securityZoneDictionaryDatas: " + responseString + "}");
1126 out.write(j.toString());
1130 }catch (Exception e){
1131 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1132 response.setCharacterEncoding(utf8);
1133 request.setCharacterEncoding(utf8);
1134 PrintWriter out = response.getWriter();
1135 out.write(e.getMessage());
1140 @RequestMapping(value={"/fw_dictionary/remove_securityZone"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1141 public ModelAndView removeSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
1143 ObjectMapper mapper = new ObjectMapper();
1144 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1145 JsonNode root = mapper.readTree(request.getReader());
1146 SecurityZone securityZone = (SecurityZone)mapper.readValue(root.get("data").toString(), SecurityZone.class);
1147 commonClassDao.delete(securityZone);
1148 response.setCharacterEncoding(utf8);
1149 response.setContentType(applicationJsonContentType);
1150 request.setCharacterEncoding(utf8);
1152 PrintWriter out = response.getWriter();
1154 String responseString = mapper.writeValueAsString(commonClassDao.getData(SecurityZone.class));
1155 JSONObject j = new JSONObject("{securityZoneDictionaryDatas: " + responseString + "}");
1156 out.write(j.toString());
1160 catch (Exception e){
1161 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1162 response.setCharacterEncoding(utf8);
1163 request.setCharacterEncoding(utf8);
1164 PrintWriter out = response.getWriter();
1165 out.write(e.getMessage());
1171 @RequestMapping(value={"/get_ServiceListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1172 public void getServiceListDictionaryEntityData(HttpServletResponse response){
1174 Map<String, Object> model = new HashMap<>();
1175 ObjectMapper mapper = new ObjectMapper();
1176 model.put("serviceListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(ServiceList.class)));
1177 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1178 JSONObject j = new JSONObject(msg);
1179 response.addHeader(successMapKey, successMessage);
1180 response.addHeader(operation, getDictionary);
1181 response.getWriter().write(j.toString());
1183 catch (Exception e){
1184 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1185 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
1186 response.addHeader(errorMsg, dictionaryDBQuery);
1190 @RequestMapping(value={"/get_ServiceListDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1191 public void getServiceListDictionaryEntityDataByName(HttpServletResponse response){
1193 Map<String, Object> model = new HashMap<>();
1194 ObjectMapper mapper = new ObjectMapper();
1195 model.put("serviceListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(ServiceList.class, serviceName)));
1196 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1197 JSONObject j = new JSONObject(msg);
1198 response.getWriter().write(j.toString());
1200 catch (Exception e){
1201 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1205 @RequestMapping(value={"/fw_dictionary/save_serviceList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1206 public ModelAndView saveServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
1208 boolean duplicateflag = false;
1209 boolean isFakeUpdate = false;
1210 boolean fromAPI = false;
1211 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
1214 ObjectMapper mapper = new ObjectMapper();
1215 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1216 JsonNode root = mapper.readTree(request.getReader());
1217 ServiceList serviceList;
1218 GridData serviceListGridData;
1220 serviceList = (ServiceList)mapper.readValue(root.get(dictionaryFields).toString(), ServiceList.class);
1221 serviceListGridData = (GridData)mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
1223 //check if update operation or create, get id for data to be updated and update attributeData
1224 if ((update).equals(request.getParameter(operation))) {
1225 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(serviceList.getServiceName(), serviceName, ServiceList.class);
1226 ServiceList data = (ServiceList) duplicateData.get(0);
1227 int id = data.getId();
1230 serviceList.setId(1);
1232 serviceList.setId(id);
1236 serviceList = (ServiceList)mapper.readValue(root.get("serviceListDictionaryData").toString(), ServiceList.class);
1237 serviceListGridData = (GridData)mapper.readValue(root.get("serviceListDictionaryData").toString(), GridData.class);
1239 String tcpValue = "";
1241 if(!serviceListGridData.getTransportProtocols().isEmpty()){
1242 for(Object attribute : serviceListGridData.getTransportProtocols()){
1243 if(attribute instanceof LinkedHashMap<?, ?>){
1244 String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
1246 tcpValue = tcpValue + ",";
1248 tcpValue = tcpValue + key ;
1253 serviceList.setServiceTransProtocol(tcpValue);
1254 String appValue = "";
1256 if(!serviceListGridData.getAppProtocols().isEmpty()){
1257 for(Object attribute : serviceListGridData.getAppProtocols()){
1258 if(attribute instanceof LinkedHashMap<?, ?>){
1259 String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
1261 appValue = appValue + ",";
1263 appValue = appValue + key ;
1268 serviceList.setServiceAppProtocol(appValue);
1269 serviceList.setServiceType("SERVICE");
1270 if(serviceList.getId() == 0){
1271 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(serviceList.getServiceName(), serviceName, ServiceList.class);
1272 if(!duplicateData.isEmpty()){
1273 duplicateflag = true;
1275 commonClassDao.save(serviceList);
1279 commonClassDao.update(serviceList);
1283 String responseString = "";
1285 responseString = duplicateResponseString;
1287 responseString = mapper.writeValueAsString(commonClassDao.getData(ServiceList.class));
1290 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
1292 responseString = existsResponseString;
1294 responseString = successMsg;
1297 ModelAndView result = new ModelAndView();
1298 result.setViewName(responseString);
1301 response.setCharacterEncoding(utf8);
1302 response.setContentType(applicationJsonContentType);
1303 request.setCharacterEncoding(utf8);
1305 PrintWriter out = response.getWriter();
1306 JSONObject j = new JSONObject("{serviceListDictionaryDatas: " + responseString + "}");
1307 out.write(j.toString());
1310 }catch (Exception e){
1311 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1312 response.setCharacterEncoding(utf8);
1313 request.setCharacterEncoding(utf8);
1314 PrintWriter out = response.getWriter();
1315 out.write(e.getMessage());
1321 @RequestMapping(value={"/fw_dictionary/remove_serviceList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1322 public ModelAndView removeServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
1324 ObjectMapper mapper = new ObjectMapper();
1325 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1326 JsonNode root = mapper.readTree(request.getReader());
1327 ServiceList serviceList = (ServiceList)mapper.readValue(root.get("data").toString(), ServiceList.class);
1328 commonClassDao.delete(serviceList);
1329 response.setCharacterEncoding(utf8);
1330 response.setContentType(applicationJsonContentType);
1331 request.setCharacterEncoding(utf8);
1333 PrintWriter out = response.getWriter();
1335 String responseString = mapper.writeValueAsString(commonClassDao.getData(ServiceList.class));
1336 JSONObject j = new JSONObject("{serviceListDictionaryDatas: " + responseString + "}");
1337 out.write(j.toString());
1341 catch (Exception e){
1343 response.setCharacterEncoding(utf8);
1344 request.setCharacterEncoding(utf8);
1345 PrintWriter out = response.getWriter();
1346 out.write(e.getMessage());
1351 @RequestMapping(value={"/get_ZoneData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1352 public void getZoneDictionaryEntityData(HttpServletResponse response){
1354 Map<String, Object> model = new HashMap<>();
1355 ObjectMapper mapper = new ObjectMapper();
1356 model.put("zoneDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(Zone.class)));
1357 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1358 JSONObject j = new JSONObject(msg);
1359 response.addHeader(successMapKey, successMessage);
1360 response.addHeader(operation, getDictionary);
1361 response.getWriter().write(j.toString());
1363 catch (Exception e){
1364 LOGGER.error("Exception Occured"+e);
1368 @RequestMapping(value={"/get_ZoneDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1369 public void getZoneDictionaryEntityDataByName(HttpServletResponse response){
1371 Map<String, Object> model = new HashMap<>();
1372 ObjectMapper mapper = new ObjectMapper();
1373 model.put("zoneDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(Zone.class, zoneName)));
1374 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1375 JSONObject j = new JSONObject(msg);
1376 response.getWriter().write(j.toString());
1378 catch (Exception e){
1379 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1383 @RequestMapping(value={"/fw_dictionary/save_zoneName"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1384 public ModelAndView saveZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
1386 boolean duplicateflag = false;
1387 boolean isFakeUpdate = false;
1388 boolean fromAPI = false;
1389 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
1392 ObjectMapper mapper = new ObjectMapper();
1393 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1394 JsonNode root = mapper.readTree(request.getReader());
1397 zone = (Zone)mapper.readValue(root.get(dictionaryFields).toString(), Zone.class);
1399 //check if update operation or create, get id for data to be updated and update attributeData
1400 if ((update).equals(request.getParameter(operation))) {
1401 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(zone.getZoneName(), zoneName, Zone.class);
1402 Zone data = (Zone) duplicateData.get(0);
1403 int id = data.getId();
1412 zone = (Zone)mapper.readValue(root.get("zoneDictionaryData").toString(), Zone.class);
1414 if(zone.getId() == 0){
1415 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(zone.getZoneName(), zoneName, Zone.class);
1416 if(!duplicateData.isEmpty()){
1417 duplicateflag = true;
1419 commonClassDao.save(zone);
1423 commonClassDao.update(zone);
1426 String responseString = "";
1428 responseString = duplicateResponseString;
1430 responseString = mapper.writeValueAsString(commonClassDao.getData(Zone.class));
1434 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
1436 responseString = existsResponseString;
1438 responseString = successMsg;
1441 ModelAndView result = new ModelAndView();
1442 result.setViewName(responseString);
1445 response.setCharacterEncoding(utf8);
1446 response.setContentType(applicationJsonContentType);
1447 request.setCharacterEncoding(utf8);
1449 PrintWriter out = response.getWriter();
1450 JSONObject j = new JSONObject("{zoneDictionaryDatas: " + responseString + "}");
1451 out.write(j.toString());
1454 }catch (Exception e){
1455 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1456 response.setCharacterEncoding(utf8);
1457 request.setCharacterEncoding(utf8);
1458 PrintWriter out = response.getWriter();
1459 out.write(e.getMessage());
1464 @RequestMapping(value={"/fw_dictionary/remove_zone"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1465 public ModelAndView removeZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
1467 ObjectMapper mapper = new ObjectMapper();
1468 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1469 JsonNode root = mapper.readTree(request.getReader());
1470 Zone zone = (Zone)mapper.readValue(root.get("data").toString(), Zone.class);
1471 commonClassDao.delete(zone);
1472 response.setCharacterEncoding(utf8);
1473 response.setContentType(applicationJsonContentType);
1474 request.setCharacterEncoding(utf8);
1476 PrintWriter out = response.getWriter();
1478 String responseString = mapper.writeValueAsString(commonClassDao.getData(Zone.class));
1479 JSONObject j = new JSONObject("{zoneDictionaryDatas: " + responseString + "}");
1480 out.write(j.toString());
1484 catch (Exception e){
1485 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1486 response.setCharacterEncoding(utf8);
1487 request.setCharacterEncoding(utf8);
1488 PrintWriter out = response.getWriter();
1489 out.write(e.getMessage());
1494 @RequestMapping(value={"/get_TermListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1495 public void getTermListDictionaryEntityDataByName(HttpServletResponse response){
1497 Map<String, Object> model = new HashMap<>();
1498 ObjectMapper mapper = new ObjectMapper();
1499 model.put("termListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(TermList.class, termName)));
1500 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1501 JSONObject j = new JSONObject(msg);
1502 response.getWriter().write(j.toString());
1504 catch (Exception e){
1505 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1509 @RequestMapping(value={"/get_TermListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1510 public void getTermListDictionaryEntityData(HttpServletResponse response){
1512 Map<String, Object> model = new HashMap<>();
1513 ObjectMapper mapper = new ObjectMapper();
1514 model.put("termListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(TermList.class)));
1515 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1516 JSONObject j = new JSONObject(msg);
1517 response.addHeader(successMapKey, successMessage);
1518 response.addHeader(operation, getDictionary);
1519 response.getWriter().write(j.toString());
1521 catch (Exception e){
1522 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1523 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
1524 response.addHeader(errorMsg, dictionaryDBQuery);
1528 @RequestMapping(value={"/fw_dictionary/save_termList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1529 public ModelAndView saveTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
1531 boolean duplicateflag = false;
1532 boolean isFakeUpdate = false;
1533 boolean fromAPI = false;
1534 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
1537 ObjectMapper mapper = new ObjectMapper();
1538 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1539 JsonNode root = mapper.readTree(request.getReader());
1541 TermListData termListDatas;
1542 String userId = null;
1544 termList = (TermList)mapper.readValue(root.get(dictionaryFields).toString(), TermList.class);
1545 termListDatas = (TermListData)mapper.readValue(root.get(dictionaryFields).toString(), TermListData.class);
1548 //check if update operation or create, get id for data to be updated and update attributeData
1549 if ((update).equals(request.getParameter(operation))) {
1550 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(termList.getTermName(), termName, TermList.class);
1551 TermList data = (TermList) duplicateData.get(0);
1552 int id = data.getId();
1559 termList.setUserCreatedBy(this.getUserInfo(userId));
1562 termList = (TermList)mapper.readValue(root.get("termListDictionaryData").toString(), TermList.class);
1563 termListDatas = (TermListData)mapper.readValue(root.get("termListDictionaryData").toString(), TermListData.class);
1564 userId = root.get(userid).textValue();
1566 String fromZoneValue = "";
1568 if(!termListDatas.getFromZoneDatas().isEmpty()){
1569 for(Object fromZone : termListDatas.getFromZoneDatas()){
1570 if(fromZone instanceof LinkedHashMap<?, ?>){
1571 String key = ((LinkedHashMap<?, ?>) fromZone).get(option).toString();
1573 fromZoneValue = fromZoneValue + ",";
1575 fromZoneValue = fromZoneValue + key ;
1580 termList.setFromZones(fromZoneValue);
1582 String toZoneValue = "";
1583 int toZonecounter = 0;
1584 if(!termListDatas.getToZoneDatas().isEmpty()){
1585 for(Object toZone : termListDatas.getToZoneDatas()){
1586 if(toZone instanceof LinkedHashMap<?, ?>){
1587 String key = ((LinkedHashMap<?, ?>) toZone).get(option).toString();
1588 if(toZonecounter>0){
1589 toZoneValue = toZoneValue + ",";
1591 toZoneValue = toZoneValue + key ;
1596 termList.setToZones(toZoneValue);
1598 String srcListValues = "";
1599 int srcListcounter = 0;
1600 if(!termListDatas.getSourceListDatas().isEmpty()){
1601 for(Object srcList : termListDatas.getSourceListDatas()){
1602 if(srcList instanceof LinkedHashMap<?, ?>){
1603 String key = ((LinkedHashMap<?, ?>) srcList).get(option).toString();
1604 if(srcListcounter>0){
1605 srcListValues = srcListValues + ",";
1607 srcListValues = srcListValues + key ;
1612 termList.setSrcIPList(srcListValues);
1614 String desListValues = "";
1615 int destListcounter = 0;
1616 if(!termListDatas.getDestinationListDatas().isEmpty()){
1617 for(Object desList : termListDatas.getDestinationListDatas()){
1618 if(desList instanceof LinkedHashMap<?, ?>){
1619 String key = ((LinkedHashMap<?, ?>) desList).get(option).toString();
1620 if(destListcounter>0){
1621 desListValues = desListValues + ",";
1623 desListValues = desListValues + key ;
1628 termList.setDestIPList(desListValues);
1630 String srcSerValue = "";
1631 int srcSercounter = 0;
1632 if(!termListDatas.getSourceServiceDatas().isEmpty()){
1633 for(Object srcSrc : termListDatas.getSourceServiceDatas()){
1634 if(srcSrc instanceof LinkedHashMap<?, ?>){
1635 String key = ((LinkedHashMap<?, ?>) srcSrc).get(option).toString();
1636 if(srcSercounter>0){
1637 srcSerValue = srcSerValue + ",";
1639 srcSerValue = srcSerValue + key ;
1644 termList.setSrcPortList(srcSerValue);
1646 String desSrcValue = "";
1647 int desSrccounter = 0;
1648 if(!termListDatas.getDestinationServiceDatas().isEmpty()){
1649 for(Object desSrc : termListDatas.getDestinationServiceDatas()){
1650 if(desSrc instanceof LinkedHashMap<?, ?>){
1651 String key = ((LinkedHashMap<?, ?>) desSrc).get(option).toString();
1652 if(desSrccounter>0){
1653 desSrcValue = desSrcValue + ",";
1655 desSrcValue = desSrcValue + key ;
1660 termList.setDestPortList(desSrcValue);
1662 String actionValue = "";
1663 int actioncounter = 0;
1664 if(!termListDatas.getActionListDatas().isEmpty()){
1665 for(Object actionList : termListDatas.getActionListDatas()){
1666 if(actionList instanceof LinkedHashMap<?, ?>){
1667 String key = ((LinkedHashMap<?, ?>) actionList).get(option).toString();
1668 if(actioncounter>0){
1669 actionValue = actionValue + ",";
1671 actionValue = actionValue + key ;
1676 termList.setAction(actionValue);
1678 if(termList.getId() == 0){
1679 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(termList.getTermName(), termName, TermList.class);
1680 if(!duplicateData.isEmpty()){
1681 duplicateflag = true;
1683 termList.setUserCreatedBy(this.getUserInfo(userId));
1684 termList.setUserModifiedBy(this.getUserInfo(userId));
1685 commonClassDao.save(termList);
1689 termList.setUserModifiedBy(this.getUserInfo(userId));
1690 commonClassDao.update(termList);
1693 String responseString = "";
1695 responseString = duplicateResponseString;
1697 responseString = mapper.writeValueAsString(commonClassDao.getData(TermList.class));
1701 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
1703 responseString = existsResponseString;
1705 responseString = successMsg;
1708 ModelAndView result = new ModelAndView();
1709 result.setViewName(responseString);
1712 response.setCharacterEncoding(utf8);
1713 response.setContentType(applicationJsonContentType);
1714 request.setCharacterEncoding(utf8);
1716 PrintWriter out = response.getWriter();
1717 JSONObject j = new JSONObject("{termListDictionaryDatas: " + responseString + "}");
1718 out.write(j.toString());
1721 }catch (Exception e){
1722 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1723 response.setCharacterEncoding(utf8);
1724 request.setCharacterEncoding(utf8);
1725 PrintWriter out = response.getWriter();
1726 out.write(e.getMessage());
1731 @RequestMapping(value={"/fw_dictionary/remove_termList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1732 public ModelAndView removeTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
1734 ObjectMapper mapper = new ObjectMapper();
1735 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1736 JsonNode root = mapper.readTree(request.getReader());
1737 TermList termList = (TermList)mapper.readValue(root.get("data").toString(), TermList.class);
1738 commonClassDao.delete(termList);
1739 response.setCharacterEncoding(utf8);
1740 response.setContentType(applicationJsonContentType);
1741 request.setCharacterEncoding(utf8);
1743 PrintWriter out = response.getWriter();
1745 String responseString = mapper.writeValueAsString(commonClassDao.getData(TermList.class));
1746 JSONObject j = new JSONObject("{termListDictionaryDatas: " + responseString + "}");
1747 out.write(j.toString());
1751 catch (Exception e){
1752 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1753 response.setCharacterEncoding(utf8);
1754 request.setCharacterEncoding(utf8);
1755 PrintWriter out = response.getWriter();
1756 out.write(e.getMessage());
1760 //ParentList Dictionary Data
1761 @RequestMapping(value={"/get_FWDictionaryListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1762 public void getFWDictListDictionaryEntityDataByName(HttpServletResponse response){
1764 Map<String, Object> model = new HashMap<>();
1765 ObjectMapper mapper = new ObjectMapper();
1766 model.put("fwDictListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(FirewallDictionaryList.class, "parentItemName")));
1767 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1768 JSONObject j = new JSONObject(msg);
1769 response.getWriter().write(j.toString());
1771 catch (Exception e){
1772 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1776 @RequestMapping(value={"/get_FWDictionaryListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1777 public void getFWDictionaryListEntityData(HttpServletResponse response){
1779 Map<String, Object> model = new HashMap<>();
1780 ObjectMapper mapper = new ObjectMapper();
1781 model.put("fwDictListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class)));
1782 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1783 JSONObject j = new JSONObject(msg);
1784 response.addHeader(successMapKey, successMessage);
1785 response.addHeader(operation, getDictionary);
1786 response.getWriter().write(j.toString());
1788 catch (Exception e){
1789 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1790 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
1791 response.addHeader(errorMsg, dictionaryDBQuery);
1795 @RequestMapping(value={"/fw_dictionary/save_FWDictionaryList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1796 public ModelAndView saveFWDictionaryList(HttpServletRequest request, HttpServletResponse response) throws IOException{
1798 boolean duplicateflag = false;
1799 ObjectMapper mapper = new ObjectMapper();
1800 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1801 JsonNode root = mapper.readTree(request.getReader());
1802 FirewallDictionaryList fwDictList = (FirewallDictionaryList)mapper.readValue(root.get("fwDictListDictionaryData").toString(), FirewallDictionaryList.class);
1803 GridData gridData = (GridData)mapper.readValue(root.get("fwDictListDictionaryData").toString(), GridData.class);
1804 String userSLValue = "";
1806 if(!gridData.getAttributes().isEmpty()){
1807 for(Object attribute : gridData.getAttributes()){
1808 if(attribute instanceof LinkedHashMap<?, ?>){
1809 String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
1811 userSLValue = userSLValue + ",";
1813 userSLValue = userSLValue + key ;
1818 fwDictList.setServiceList(userSLValue);
1819 String userALValue = "";
1821 if(!gridData.getAlAttributes().isEmpty()){
1822 for(Object attribute : gridData.getAlAttributes()){
1823 if(attribute instanceof LinkedHashMap<?, ?>){
1824 String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
1826 userALValue = userALValue + ",";
1828 userALValue = userALValue + key ;
1833 fwDictList.setAddressList(userALValue);
1834 if(fwDictList.getId() == 0){
1835 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwDictList.getParentItemName(), "parentItemName", FirewallDictionaryList.class);
1836 if(!duplicateData.isEmpty()){
1837 duplicateflag = true;
1839 commonClassDao.save(fwDictList);
1842 commonClassDao.update(fwDictList);
1844 response.setCharacterEncoding(utf8);
1845 response.setContentType(applicationJsonContentType);
1846 request.setCharacterEncoding(utf8);
1848 PrintWriter out = response.getWriter();
1849 String responseString = "";
1851 responseString = duplicateResponseString;
1853 responseString = mapper.writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class));
1855 JSONObject j = new JSONObject("{fwDictListDictionaryDatas: " + responseString + "}");
1857 out.write(j.toString());
1861 catch (Exception e){
1862 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1863 response.setCharacterEncoding(utf8);
1864 request.setCharacterEncoding(utf8);
1865 PrintWriter out = response.getWriter();
1866 out.write(e.getMessage());
1871 @RequestMapping(value={"/fw_dictionary/remove_FWDictionaryList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1872 public ModelAndView removeFWDictionaryListy(HttpServletRequest request, HttpServletResponse response) throws IOException {
1874 ObjectMapper mapper = new ObjectMapper();
1875 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1876 JsonNode root = mapper.readTree(request.getReader());
1877 FirewallDictionaryList fwDictList = (FirewallDictionaryList)mapper.readValue(root.get("data").toString(), FirewallDictionaryList.class);
1878 commonClassDao.delete(fwDictList);
1879 response.setCharacterEncoding(utf8);
1880 response.setContentType(applicationJsonContentType);
1881 request.setCharacterEncoding(utf8);
1883 PrintWriter out = response.getWriter();
1885 String responseString = mapper.writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class));
1886 JSONObject j = new JSONObject("{fwDictListDictionaryDatas: " + responseString + "}");
1887 out.write(j.toString());
1891 catch (Exception e){
1892 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1893 response.setCharacterEncoding(utf8);
1894 request.setCharacterEncoding(utf8);
1895 PrintWriter out = response.getWriter();
1896 out.write(e.getMessage());
1902 @RequestMapping(value={"/get_TagPickerNameByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1903 public void getTagPickerNameEntityDataByName(HttpServletResponse response){
1905 Map<String, Object> model = new HashMap<>();
1906 ObjectMapper mapper = new ObjectMapper();
1907 model.put("fwTagPickerDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(FWTagPicker.class, tagPickerName)));
1908 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1909 JSONObject j = new JSONObject(msg);
1910 response.getWriter().write(j.toString());
1912 catch (Exception e){
1913 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1917 @RequestMapping(value={"/get_TagPickerListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1918 public void getTagPickerDictionaryEntityData(HttpServletResponse response){
1920 Map<String, Object> model = new HashMap<>();
1921 ObjectMapper mapper = new ObjectMapper();
1922 model.put("fwTagPickerDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(FWTagPicker.class)));
1923 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1924 JSONObject j = new JSONObject(msg);
1925 response.getWriter().write(j.toString());
1927 catch (Exception e){
1928 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1932 @RequestMapping(value={"/fw_dictionary/save_fwTagPicker"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1933 public ModelAndView saveFirewallTagPickerDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
1935 boolean duplicateflag = false;
1936 boolean fromAPI = false;
1937 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
1941 ObjectMapper mapper = new ObjectMapper();
1942 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1943 JsonNode root = mapper.readTree(request.getReader());
1946 FWTagPicker fwTagPicker;
1948 String userId = null;
1950 fwTagPicker = (FWTagPicker)mapper.readValue(root.get(fwTagPickerDictionaryData).toString(), FWTagPicker.class);
1951 data = (TagGridValues)mapper.readValue(root.get(fwTagPickerDictionaryData).toString(), TagGridValues.class);
1954 //check if update operation or create, get id for data to be updated and update attributeData
1955 if ((update).equals(request.getParameter(operation))) {
1956 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTagPicker.getTagPickerName(), tagPickerName, FWTagPicker.class);
1957 FWTagPicker dbdata = (FWTagPicker) duplicateData.get(0);
1958 int id = dbdata.getId();
1959 fwTagPicker.setId(id);
1960 fwTagPicker.setUserCreatedBy(this.getUserInfo(userId));
1964 fwTagPicker = (FWTagPicker)mapper.readValue(root.get(fwTagPickerDictionaryData).toString(), FWTagPicker.class);
1965 data = (TagGridValues)mapper.readValue(root.get(fwTagPickerDictionaryData).toString(), TagGridValues.class);
1966 userId = root.get(userid).textValue();
1971 if(!data.getTags().isEmpty()){
1972 for(Object attribute : data.getTags()){
1973 if(attribute instanceof LinkedHashMap<?, ?>){
1974 String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
1975 String value = ((LinkedHashMap<?, ?>) attribute).get("number").toString();
1977 header = header + "#";
1979 header = header + key + ":";
1980 header = header + value;
1985 fwTagPicker.setTagValues(header);
1986 if(fwTagPicker.getId() == 0){
1987 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTagPicker.getTagPickerName(), tagPickerName, FWTagPicker.class);
1988 if(!duplicateData.isEmpty()){
1989 duplicateflag = true;
1991 fwTagPicker.setUserCreatedBy(this.getUserInfo(userId));
1992 fwTagPicker.setUserModifiedBy(this.getUserInfo(userId));
1993 commonClassDao.save(fwTagPicker);
1996 fwTagPicker.setUserModifiedBy(this.getUserInfo(userId));
1997 fwTagPicker.setModifiedDate(new Date());
1998 commonClassDao.update(fwTagPicker);
2001 String responseString = "";
2003 responseString = duplicateResponseString;
2005 responseString = mapper.writeValueAsString(commonClassDao.getData(FWTagPicker.class));
2009 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
2010 responseString = successMsg;
2012 ModelAndView result = new ModelAndView();
2013 result.setViewName(responseString);
2016 response.setCharacterEncoding(utf8);
2017 response.setContentType(applicationJsonContentType);
2018 request.setCharacterEncoding(utf8);
2020 PrintWriter out = response.getWriter();
2021 JSONObject j = new JSONObject("{fwTagPickerDictionaryDatas: " + responseString + "}");
2022 out.write(j.toString());
2026 catch (Exception e){
2027 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2028 response.setCharacterEncoding(utf8);
2029 request.setCharacterEncoding(utf8);
2030 PrintWriter out = response.getWriter();
2031 out.write(e.getMessage());
2036 @RequestMapping(value={"/fw_dictionary/remove_tagPicker"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
2037 public ModelAndView removeFirewallTagPickerDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
2039 ObjectMapper mapper = new ObjectMapper();
2040 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2041 JsonNode root = mapper.readTree(request.getReader());
2042 FWTagPicker fwTagPicker = (FWTagPicker)mapper.readValue(root.get("data").toString(), FWTagPicker.class);
2043 commonClassDao.delete(fwTagPicker);
2044 response.setCharacterEncoding(utf8);
2045 response.setContentType(applicationJsonContentType);
2046 request.setCharacterEncoding(utf8);
2048 PrintWriter out = response.getWriter();
2049 String responseString = mapper.writeValueAsString(commonClassDao.getData(FWTagPicker.class));
2050 JSONObject j = new JSONObject("{fwTagPickerDictionaryDatas: " + responseString + "}");
2051 out.write(j.toString());
2054 catch (Exception e){
2055 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2056 response.setCharacterEncoding(utf8);
2057 request.setCharacterEncoding(utf8);
2058 PrintWriter out = response.getWriter();
2059 out.write(e.getMessage());
2065 @RequestMapping(value={"/get_TagNameByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
2066 public void getTagNameEntityDataByName(HttpServletResponse response){
2068 Map<String, Object> model = new HashMap<>();
2069 ObjectMapper mapper = new ObjectMapper();
2070 model.put(fwTagDictionaryDatas, mapper.writeValueAsString(commonClassDao.getDataByColumn(FWTag.class, "fwTagName")));
2071 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
2072 JSONObject j = new JSONObject(msg);
2073 response.getWriter().write(j.toString());
2075 catch (Exception e){
2076 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2080 @RequestMapping(value={"/get_TagListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
2081 public void getTagDictionaryEntityData(HttpServletResponse response){
2083 Map<String, Object> model = new HashMap<>();
2084 ObjectMapper mapper = new ObjectMapper();
2085 model.put(fwTagDictionaryDatas, mapper.writeValueAsString(commonClassDao.getData(FWTag.class)));
2086 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
2087 JSONObject j = new JSONObject(msg);
2088 response.getWriter().write(j.toString());
2090 catch (Exception e){
2091 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2095 @RequestMapping(value={"/fw_dictionary/save_fwTag"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
2096 public ModelAndView saveFirewallTagDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
2098 boolean duplicateflag = false;
2099 boolean fromAPI = false;
2100 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
2104 ObjectMapper mapper = new ObjectMapper();
2105 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2106 JsonNode root = mapper.readTree(request.getReader());
2110 TagGridValues tagGridValues;
2111 String userId = null;
2113 fwTag = (FWTag)mapper.readValue(root.get(fwTagDictionaryDatas).toString(), FWTag.class);
2114 tagGridValues = (TagGridValues)mapper.readValue(root.get(fwTagDictionaryDatas).toString(), TagGridValues.class);
2117 //check if update operation or create, get id for data to be updated and update attributeData
2118 if ((update).equals(request.getParameter(operation))) {
2119 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTag.getFwTagName(), "tagName", FWTag.class);
2120 FWTag data = (FWTag) duplicateData.get(0);
2121 int id = data.getId();
2123 fwTag.setUserCreatedBy(this.getUserInfo(userId));
2127 fwTag = (FWTag)mapper.readValue(root.get("fwTagDictionaryData").toString(), FWTag.class);
2128 tagGridValues = (TagGridValues)mapper.readValue(root.get("fwTagDictionaryData").toString(), TagGridValues.class);
2129 userId = root.get(userid).textValue();
2132 String userValue = "";
2134 if(!tagGridValues.getTags().isEmpty()){
2135 for(Object attribute : tagGridValues.getTags()){
2136 if(attribute instanceof LinkedHashMap<?, ?>){
2137 String key = ((LinkedHashMap<?, ?>) attribute).get("tags").toString();
2139 userValue = userValue + ",";
2141 userValue = userValue + key ;
2146 fwTag.setTagValues(userValue);
2147 if(fwTag.getId() == 0){
2148 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTag.getFwTagName(), "fwTagName", FWTag.class);
2149 if(!duplicateData.isEmpty()){
2150 duplicateflag = true;
2152 fwTag.setUserCreatedBy(this.getUserInfo(userId));
2153 fwTag.setUserModifiedBy(this.getUserInfo(userId));
2154 commonClassDao.save(fwTag);
2157 fwTag.setUserModifiedBy(this.getUserInfo(userId));
2158 fwTag.setModifiedDate(new Date());
2159 commonClassDao.update(fwTag);
2162 String responseString = "";
2164 responseString = duplicateResponseString;
2166 responseString = mapper.writeValueAsString(commonClassDao.getData(FWTag.class));
2169 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
2170 responseString = successMsg;
2172 ModelAndView result = new ModelAndView();
2173 result.setViewName(responseString);
2177 response.setCharacterEncoding(utf8);
2178 response.setContentType(applicationJsonContentType);
2179 request.setCharacterEncoding(utf8);
2181 PrintWriter out = response.getWriter();
2182 JSONObject j = new JSONObject("{fwTagDictionaryDatas: " + responseString + "}");
2183 out.write(j.toString());
2187 catch (Exception e){
2188 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2189 response.setCharacterEncoding(utf8);
2190 request.setCharacterEncoding(utf8);
2191 PrintWriter out = response.getWriter();
2192 out.write(e.getMessage());
2197 @RequestMapping(value={"/fw_dictionary/remove_tagList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
2198 public ModelAndView removeFirewallTagDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
2200 ObjectMapper mapper = new ObjectMapper();
2201 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2202 JsonNode root = mapper.readTree(request.getReader());
2203 FWTag fwTag = (FWTag)mapper.readValue(root.get("data").toString(), FWTag.class);
2204 commonClassDao.delete(fwTag);
2205 response.setCharacterEncoding(utf8);
2206 response.setContentType(applicationJsonContentType);
2207 request.setCharacterEncoding(utf8);
2209 PrintWriter out = response.getWriter();
2211 String responseString = mapper.writeValueAsString(commonClassDao.getData(FWTag.class));
2212 JSONObject j = new JSONObject("{fwTagDictionaryDatas: " + responseString + "}");
2213 out.write(j.toString());
2217 catch (Exception e){
2218 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2219 response.setCharacterEncoding(utf8);
2220 request.setCharacterEncoding(utf8);
2221 PrintWriter out = response.getWriter();
2222 out.write(e.getMessage());
2228 class TagGridValues{
2229 private List<Object> tags;
2231 public List<Object> getTags() {
2235 public void setTags(List<Object> tags) {
2241 private List<Object> attributes;
2243 public List<Object> getAttributes() {
2247 public void setAttributes(List<Object> attributes) {
2248 this.attributes = attributes;
2253 private List<Object> fromZoneDatas;
2254 private List<Object> toZoneDatas;
2255 private List<Object> sourceListDatas;
2256 private List<Object> destinationListDatas;
2257 private List<Object> sourceServiceDatas;
2258 private List<Object> destinationServiceDatas;
2259 private List<Object> actionListDatas;
2260 public List<Object> getFromZoneDatas() {
2261 return fromZoneDatas;
2263 public void setFromZoneDatas(List<Object> fromZoneDatas) {
2264 this.fromZoneDatas = fromZoneDatas;
2266 public List<Object> getToZoneDatas() {
2269 public void setToZoneDatas(List<Object> toZoneDatas) {
2270 this.toZoneDatas = toZoneDatas;
2272 public List<Object> getSourceListDatas() {
2273 return sourceListDatas;
2275 public void setSourceListDatas(List<Object> sourceListDatas) {
2276 this.sourceListDatas = sourceListDatas;
2278 public List<Object> getDestinationListDatas() {
2279 return destinationListDatas;
2281 public void setDestinationListDatas(List<Object> destinationListDatas) {
2282 this.destinationListDatas = destinationListDatas;
2284 public List<Object> getSourceServiceDatas() {
2285 return sourceServiceDatas;
2287 public void setSourceServiceDatas(List<Object> sourceServiceDatas) {
2288 this.sourceServiceDatas = sourceServiceDatas;
2290 public List<Object> getDestinationServiceDatas() {
2291 return destinationServiceDatas;
2293 public void setDestinationServiceDatas(List<Object> destinationServiceDatas) {
2294 this.destinationServiceDatas = destinationServiceDatas;
2296 public List<Object> getActionListDatas() {
2297 return actionListDatas;
2299 public void setActionListDatas(List<Object> actionListDatas) {
2300 this.actionListDatas = actionListDatas;