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.openecomp.policy.pap.xacml.rest.controller;
23 import java.io.PrintWriter;
24 import java.net.UnknownHostException;
25 import java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.LinkedHashMap;
28 import java.util.List;
31 import javax.servlet.http.HttpServletRequest;
32 import javax.servlet.http.HttpServletResponse;
34 import org.jboss.netty.handler.ipfilter.CIDR;
35 import org.json.JSONObject;
36 import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
37 import org.openecomp.policy.common.logging.flexlogger.Logger;
38 import org.openecomp.policy.pap.xacml.rest.adapters.GridData;
39 import org.openecomp.policy.pap.xacml.rest.util.JsonMessage;
40 import org.openecomp.policy.rest.dao.CommonClassDao;
41 import org.openecomp.policy.rest.jpa.ActionList;
42 import org.openecomp.policy.rest.jpa.AddressGroup;
43 import org.openecomp.policy.rest.jpa.FWTag;
44 import org.openecomp.policy.rest.jpa.FWTagPicker;
45 import org.openecomp.policy.rest.jpa.FirewallDictionaryList;
46 import org.openecomp.policy.rest.jpa.GroupServiceList;
47 import org.openecomp.policy.rest.jpa.PrefixList;
48 import org.openecomp.policy.rest.jpa.PortList;
49 import org.openecomp.policy.rest.jpa.ProtocolList;
50 import org.openecomp.policy.rest.jpa.SecurityZone;
51 import org.openecomp.policy.rest.jpa.ServiceList;
52 import org.openecomp.policy.rest.jpa.TermList;
53 import org.openecomp.policy.rest.jpa.UserInfo;
54 import org.openecomp.policy.rest.jpa.Zone;
55 import org.openecomp.policy.xacml.api.XACMLErrorConstants;
56 import org.springframework.beans.factory.annotation.Autowired;
57 import org.springframework.http.MediaType;
58 import org.springframework.stereotype.Controller;
59 import org.springframework.web.bind.annotation.RequestMapping;
60 import org.springframework.web.servlet.ModelAndView;
62 import com.fasterxml.jackson.databind.DeserializationFeature;
63 import com.fasterxml.jackson.databind.JsonNode;
64 import com.fasterxml.jackson.databind.ObjectMapper;
68 public class FirewallDictionaryController {
70 private static final Logger LOGGER = FlexLogger.getLogger(FirewallDictionaryController.class);
72 private static CommonClassDao commonClassDao;
75 public FirewallDictionaryController(CommonClassDao commonClassDao){
76 FirewallDictionaryController.commonClassDao = commonClassDao;
79 public FirewallDictionaryController(){}
81 public UserInfo getUserInfo(String loginId){
82 UserInfo name = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
87 @RequestMapping(value={"/get_PrefixListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
88 public void getPrefixListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
90 Map<String, Object> model = new HashMap<>();
91 ObjectMapper mapper = new ObjectMapper();
92 model.put("prefixListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(PrefixList.class, "prefixListName")));
93 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
94 JSONObject j = new JSONObject(msg);
95 response.getWriter().write(j.toString());
98 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
102 @RequestMapping(value={"/get_PrefixListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
103 public void getPrefixListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
105 Map<String, Object> model = new HashMap<>();
106 ObjectMapper mapper = new ObjectMapper();
107 model.put("prefixListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(PrefixList.class)));
108 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
109 JSONObject j = new JSONObject(msg);
110 response.addHeader("successMapKey", "success");
111 response.addHeader("operation", "getDictionary");
112 response.getWriter().write(j.toString());
115 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
116 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
117 response.addHeader("error", "dictionaryDBQuery");
121 @RequestMapping(value={"/fw_dictionary/save_prefixList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
122 public ModelAndView savePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
124 boolean duplicateflag = false;
125 boolean isFakeUpdate = false;
126 boolean fromAPI = false;
127 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
130 ObjectMapper mapper = new ObjectMapper();
131 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
132 JsonNode root = mapper.readTree(request.getReader());
133 PrefixList prefixList;
135 prefixList = (PrefixList)mapper.readValue(root.get("dictionaryFields").toString(), PrefixList.class);
137 //check if update operation or create, get id for data to be updated and update attributeData
138 if (request.getParameter("operation").equals("update")) {
139 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(prefixList.getPrefixListName(), "prefixListName", PrefixList.class);
141 PrefixList data = (PrefixList) duplicateData.get(0);
147 prefixList.setId(id);
151 prefixList = (PrefixList)mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
153 if(prefixList.getId() == 0){
154 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(prefixList.getPrefixListName(), "prefixListName", PrefixList.class);
155 if(!duplicateData.isEmpty()){
156 duplicateflag = true;
158 commonClassDao.save(prefixList);
162 commonClassDao.update(prefixList);
165 String responseString = "";
167 responseString = "Duplicate";
169 responseString = mapper.writeValueAsString(commonClassDao.getData(PrefixList.class));
173 if (responseString!=null && !responseString.equals("Duplicate")) {
175 responseString = "Exists";
177 responseString = "Success";
180 ModelAndView result = new ModelAndView();
181 result.setViewName(responseString);
184 response.setCharacterEncoding("UTF-8");
185 response.setContentType("application / json");
186 request.setCharacterEncoding("UTF-8");
188 PrintWriter out = response.getWriter();
189 JSONObject j = new JSONObject("{prefixListDictionaryDatas: " + responseString + "}");
190 out.write(j.toString());
193 }catch (Exception e){
194 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
195 response.setCharacterEncoding("UTF-8");
196 request.setCharacterEncoding("UTF-8");
197 PrintWriter out = response.getWriter();
198 out.write(e.getMessage());
203 @RequestMapping(value={"/fw_dictionary/remove_PrefixList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
204 public ModelAndView removePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
206 ObjectMapper mapper = new ObjectMapper();
207 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
208 JsonNode root = mapper.readTree(request.getReader());
209 PrefixList prefixList = (PrefixList)mapper.readValue(root.get("data").toString(), PrefixList.class);
210 commonClassDao.delete(prefixList);
211 response.setCharacterEncoding("UTF-8");
212 response.setContentType("application / json");
213 request.setCharacterEncoding("UTF-8");
215 PrintWriter out = response.getWriter();
216 String responseString = mapper.writeValueAsString(commonClassDao.getData(PrefixList.class));
217 JSONObject j = new JSONObject("{prefixListDictionaryDatas: " + responseString + "}");
218 out.write(j.toString());
222 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
223 response.setCharacterEncoding("UTF-8");
224 request.setCharacterEncoding("UTF-8");
225 PrintWriter out = response.getWriter();
226 out.write(e.getMessage());
231 @RequestMapping(value={"/fw_dictionary/validate_prefixList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
232 public ModelAndView validatePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
234 ObjectMapper mapper = new ObjectMapper();
235 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
236 JsonNode root = mapper.readTree(request.getReader());
237 PrefixList prefixList = (PrefixList)mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
238 String responseValidation = "success";
240 CIDR.newCIDR(prefixList.getPrefixListValue());
241 }catch(UnknownHostException e){
242 responseValidation = "error";
244 response.setCharacterEncoding("UTF-8");
245 response.setContentType("application / json");
246 request.setCharacterEncoding("UTF-8");
248 PrintWriter out = response.getWriter();
249 JSONObject j = new JSONObject("{result: " + responseValidation + "}");
250 out.write(j.toString());
254 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
255 response.setCharacterEncoding("UTF-8");
256 request.setCharacterEncoding("UTF-8");
257 PrintWriter out = response.getWriter();
258 out.write(e.getMessage());
263 @RequestMapping(value={"/get_PortListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
264 public void getPortListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
266 Map<String, Object> model = new HashMap<>();
267 ObjectMapper mapper = new ObjectMapper();
268 model.put("portListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(PortList.class)));
269 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
270 JSONObject j = new JSONObject(msg);
271 response.addHeader("successMapKey", "success");
272 response.addHeader("operation", "getDictionary");
273 response.getWriter().write(j.toString());
276 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
277 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
278 response.addHeader("error", "dictionaryDBQuery");
282 @RequestMapping(value={"/fw_dictionary/save_portName"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
283 public ModelAndView savePortListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
285 boolean duplicateflag = false;
286 ObjectMapper mapper = new ObjectMapper();
287 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
288 JsonNode root = mapper.readTree(request.getReader());
289 PortList portList = (PortList)mapper.readValue(root.get("portListDictionaryData").toString(), PortList.class);
290 if(portList.getId() == 0){
291 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(portList.getPortName(), "portName", PortList.class);
292 if(!duplicateData.isEmpty()){
293 duplicateflag = true;
295 commonClassDao.save(portList);
298 commonClassDao.update(portList);
300 response.setCharacterEncoding("UTF-8");
301 response.setContentType("application / json");
302 request.setCharacterEncoding("UTF-8");
304 PrintWriter out = response.getWriter();
305 String responseString = "";
307 responseString = "Duplicate";
309 responseString = mapper.writeValueAsString(commonClassDao.getData(PortList.class));
311 JSONObject j = new JSONObject("{portListDictionaryDatas: " + responseString + "}");
313 out.write(j.toString());
318 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
319 response.setCharacterEncoding("UTF-8");
320 request.setCharacterEncoding("UTF-8");
321 PrintWriter out = response.getWriter();
322 out.write(e.getMessage());
327 @RequestMapping(value={"/fw_dictionary/remove_PortList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
328 public ModelAndView removePortListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
330 ObjectMapper mapper = new ObjectMapper();
331 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
332 JsonNode root = mapper.readTree(request.getReader());
333 PortList portList = (PortList)mapper.readValue(root.get("data").toString(), PortList.class);
334 commonClassDao.delete(portList);
335 response.setCharacterEncoding("UTF-8");
336 response.setContentType("application / json");
337 request.setCharacterEncoding("UTF-8");
339 PrintWriter out = response.getWriter();
340 String responseString = mapper.writeValueAsString(commonClassDao.getData(PortList.class));
341 JSONObject j = new JSONObject("{portListDictionaryDatas: " + responseString + "}");
342 out.write(j.toString());
346 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
347 response.setCharacterEncoding("UTF-8");
348 request.setCharacterEncoding("UTF-8");
349 PrintWriter out = response.getWriter();
350 out.write(e.getMessage());
355 @RequestMapping(value={"/get_ProtocolListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
356 public void getProtocolListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
358 Map<String, Object> model = new HashMap<String, Object>();
359 ObjectMapper mapper = new ObjectMapper();
360 model.put("protocolListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(ProtocolList.class)));
361 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
362 JSONObject j = new JSONObject(msg);
363 response.addHeader("successMapKey", "success");
364 response.addHeader("operation", "getDictionary");
365 response.getWriter().write(j.toString());
368 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
369 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
370 response.addHeader("error", "dictionaryDBQuery");
374 @RequestMapping(value={"/get_ProtocolListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
375 public void getProtocolListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
377 Map<String, Object> model = new HashMap<String, Object>();
378 ObjectMapper mapper = new ObjectMapper();
379 model.put("protocolListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(ProtocolList.class, "protocolName")));
380 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
381 JSONObject j = new JSONObject(msg);
382 response.getWriter().write(j.toString());
385 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
389 @RequestMapping(value={"/fw_dictionary/save_protocolList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
390 public ModelAndView saveProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
392 boolean duplicateflag = false;
393 boolean isFakeUpdate = false;
394 boolean fromAPI = false;
395 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
398 ObjectMapper mapper = new ObjectMapper();
399 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
400 JsonNode root = mapper.readTree(request.getReader());
401 ProtocolList protocolList;
403 protocolList = (ProtocolList)mapper.readValue(root.get("dictionaryFields").toString(), ProtocolList.class);
405 //check if update operation or create, get id for data to be updated and update attributeData
406 if (request.getParameter("operation").equals("update")) {
407 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(protocolList.getProtocolName(), "protocolName", ProtocolList.class);
409 ProtocolList data = (ProtocolList) duplicateData.get(0);
413 protocolList.setId(1);
415 protocolList.setId(id);
419 protocolList = (ProtocolList)mapper.readValue(root.get("protocolListDictionaryData").toString(), ProtocolList.class);
421 if(protocolList.getId() == 0){
422 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(protocolList.getProtocolName(), "protocolName", ProtocolList.class);
423 if(!duplicateData.isEmpty()){
424 duplicateflag = true;
426 commonClassDao.save(protocolList);
430 commonClassDao.update(protocolList);
433 String responseString = "";
435 responseString = "Duplicate";
437 responseString = mapper.writeValueAsString(commonClassDao.getData(ProtocolList.class));
441 if (responseString!=null && !responseString.equals("Duplicate")) {
443 responseString = "Exists";
445 responseString = "Success";
448 ModelAndView result = new ModelAndView();
449 result.setViewName(responseString);
452 response.setCharacterEncoding("UTF-8");
453 response.setContentType("application / json");
454 request.setCharacterEncoding("UTF-8");
456 PrintWriter out = response.getWriter();
457 JSONObject j = new JSONObject("{protocolListDictionaryDatas: " + responseString + "}");
458 out.write(j.toString());
461 }catch (Exception e){
462 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
463 response.setCharacterEncoding("UTF-8");
464 request.setCharacterEncoding("UTF-8");
465 PrintWriter out = response.getWriter();
466 out.write(e.getMessage());
471 @RequestMapping(value={"/fw_dictionary/remove_protocol"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
472 public ModelAndView removeProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
474 ObjectMapper mapper = new ObjectMapper();
475 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
476 JsonNode root = mapper.readTree(request.getReader());
477 ProtocolList protocolList = (ProtocolList)mapper.readValue(root.get("data").toString(), ProtocolList.class);
478 commonClassDao.delete(protocolList);
479 response.setCharacterEncoding("UTF-8");
480 response.setContentType("application / json");
481 request.setCharacterEncoding("UTF-8");
483 PrintWriter out = response.getWriter();
485 String responseString = mapper.writeValueAsString(commonClassDao.getData(ProtocolList.class));
486 JSONObject j = new JSONObject("{protocolListDictionaryDatas: " + responseString + "}");
487 out.write(j.toString());
491 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
492 response.setCharacterEncoding("UTF-8");
493 request.setCharacterEncoding("UTF-8");
494 PrintWriter out = response.getWriter();
495 out.write(e.getMessage());
500 @RequestMapping(value={"/get_AddressGroupDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
501 public void getAddressGroupDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
503 Map<String, Object> model = new HashMap<>();
504 ObjectMapper mapper = new ObjectMapper();
505 model.put("addressGroupDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(AddressGroup.class, "name")));
506 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
507 JSONObject j = new JSONObject(msg);
508 response.getWriter().write(j.toString());
511 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
515 @RequestMapping(value={"/get_AddressGroupData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
516 public void getAddressGroupDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
518 Map<String, Object> model = new HashMap<>();
519 ObjectMapper mapper = new ObjectMapper();
520 model.put("addressGroupDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(AddressGroup.class)));
521 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
522 JSONObject j = new JSONObject(msg);
523 response.addHeader("successMapKey", "success");
524 response.addHeader("operation", "getDictionary");
525 response.getWriter().write(j.toString());
528 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
529 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
530 response.addHeader("error", "dictionaryDBQuery");
534 @RequestMapping(value={"/fw_dictionary/save_addressGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
535 public ModelAndView saveAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
537 boolean duplicateflag = false;
538 boolean isFakeUpdate = false;
539 boolean fromAPI = false;
540 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
543 ObjectMapper mapper = new ObjectMapper();
544 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
545 JsonNode root = mapper.readTree(request.getReader());
546 AddressGroup addressGroup;
549 addressGroup = (AddressGroup)mapper.readValue(root.get("dictionaryFields").toString(), AddressGroup.class);
550 gridData = (GridData)mapper.readValue(root.get("dictionaryFields").toString(), GridData.class);
552 if(!addressGroup.getGroupName().startsWith("Group_")){
553 String groupName = "Group_"+addressGroup.getGroupName();
554 addressGroup.setGroupName(groupName);
557 //check if update operation or create, get id for data to be updated and update attributeData
558 if (request.getParameter("operation").equals("update")) {
559 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(addressGroup.getGroupName(), "name", AddressGroup.class);
561 AddressGroup data = (AddressGroup) duplicateData.get(0);
565 addressGroup.setId(1);
567 addressGroup.setId(id);
571 addressGroup = (AddressGroup)mapper.readValue(root.get("addressGroupDictionaryData").toString(), AddressGroup.class);
572 gridData = (GridData)mapper.readValue(root.get("addressGroupDictionaryData").toString(), GridData.class);
573 if(!addressGroup.getGroupName().startsWith("Group_")){
574 String groupName = "Group_"+addressGroup.getGroupName();
575 addressGroup.setGroupName(groupName);
578 String userValue = "";
580 if(gridData.getAttributes().size() > 0){
581 for(Object attribute : gridData.getAttributes()){
582 if(attribute instanceof LinkedHashMap<?, ?>){
583 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
585 userValue = userValue + ",";
587 userValue = userValue + key ;
592 addressGroup.setServiceList(userValue);
593 if(addressGroup.getId() == 0){
594 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(addressGroup.getGroupName(), "name", AddressGroup.class);
595 if(!duplicateData.isEmpty()){
596 duplicateflag = true;
598 commonClassDao.save(addressGroup);
602 commonClassDao.update(addressGroup);
605 String responseString = "";
607 responseString = "Duplicate";
609 responseString = mapper.writeValueAsString(commonClassDao.getData(AddressGroup.class));
612 if (responseString!=null && !responseString.equals("Duplicate")) {
614 responseString = "Exists";
616 responseString = "Success";
619 ModelAndView result = new ModelAndView();
620 result.setViewName(responseString);
623 response.setCharacterEncoding("UTF-8");
624 response.setContentType("application / json");
625 request.setCharacterEncoding("UTF-8");
627 PrintWriter out = response.getWriter();
628 JSONObject j = new JSONObject("{addressGroupDictionaryDatas: " + responseString + "}");
629 out.write(j.toString());
632 }catch (Exception e){
633 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
634 response.setCharacterEncoding("UTF-8");
635 request.setCharacterEncoding("UTF-8");
636 PrintWriter out = response.getWriter();
637 out.write(e.getMessage());
642 @RequestMapping(value={"/fw_dictionary/remove_AddressGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
643 public ModelAndView removeAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
645 ObjectMapper mapper = new ObjectMapper();
646 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
647 JsonNode root = mapper.readTree(request.getReader());
648 AddressGroup addressGroup = (AddressGroup)mapper.readValue(root.get("data").toString(), AddressGroup.class);
649 commonClassDao.delete(addressGroup);
650 response.setCharacterEncoding("UTF-8");
651 response.setContentType("application / json");
652 request.setCharacterEncoding("UTF-8");
654 PrintWriter out = response.getWriter();
656 String responseString = mapper.writeValueAsString(commonClassDao.getData(AddressGroup.class));
657 JSONObject j = new JSONObject("{addressGroupDictionaryDatas: " + responseString + "}");
658 out.write(j.toString());
662 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
663 response.setCharacterEncoding("UTF-8");
664 request.setCharacterEncoding("UTF-8");
665 PrintWriter out = response.getWriter();
666 out.write(e.getMessage());
671 @RequestMapping(value={"/get_ActionListDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
672 public void getActionListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
674 Map<String, Object> model = new HashMap<>();
675 ObjectMapper mapper = new ObjectMapper();
676 List<Object> list = commonClassDao.getData(ActionList.class);
677 List<String> dictList = new ArrayList<>();
678 for(int i = 0; i < list.size(); i++){
679 ActionList dict = (ActionList) list.get(i);
680 dictList.add(dict.getActionName());
682 model.put("actionListDictionaryDatas", mapper.writeValueAsString(dictList));
683 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
684 JSONObject j = new JSONObject(msg);
685 response.getWriter().write(j.toString());
688 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
692 @RequestMapping(value={"/get_ActionListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
693 public void getActionListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
695 Map<String, Object> model = new HashMap<>();
696 ObjectMapper mapper = new ObjectMapper();
697 model.put("actionListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(ActionList.class)));
698 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
699 JSONObject j = new JSONObject(msg);
700 response.addHeader("successMapKey", "success");
701 response.addHeader("operation", "getDictionary");
702 response.getWriter().write(j.toString());
705 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
706 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
707 response.addHeader("error", "dictionaryDBQuery");
711 @RequestMapping(value={"/fw_dictionary/save_ActionList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
712 public ModelAndView saveActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
714 boolean duplicateflag = false;
715 boolean isFakeUpdate = false;
716 boolean fromAPI = false;
717 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
720 ObjectMapper mapper = new ObjectMapper();
721 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
722 JsonNode root = mapper.readTree(request.getReader());
723 ActionList actionList;
725 actionList = (ActionList)mapper.readValue(root.get("dictionaryFields").toString(), ActionList.class);
727 //check if update operation or create, get id for data to be updated and update attributeData
728 if (request.getParameter("operation").equals("update")) {
729 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(actionList.getActionName(), "actionName", ActionList.class);
731 ActionList data = (ActionList) duplicateData.get(0);
737 actionList.setId(id);
741 actionList = (ActionList)mapper.readValue(root.get("actionListDictionaryData").toString(), ActionList.class);
743 if(actionList.getId() == 0){
744 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(actionList.getActionName(), "actionName", ActionList.class);
745 if(!duplicateData.isEmpty()){
746 duplicateflag = true;
748 commonClassDao.save(actionList);
752 commonClassDao.update(actionList);
755 String responseString = "";
757 responseString = "Duplicate";
759 responseString = mapper.writeValueAsString(commonClassDao.getData(ActionList.class));
763 if (responseString!=null && !responseString.equals("Duplicate")) {
765 responseString = "Exists";
767 responseString = "Success";
770 ModelAndView result = new ModelAndView();
771 result.setViewName(responseString);
774 response.setCharacterEncoding("UTF-8");
775 response.setContentType("application / json");
776 request.setCharacterEncoding("UTF-8");
778 PrintWriter out = response.getWriter();
779 JSONObject j = new JSONObject("{actionListDictionaryDatas: " + responseString + "}");
780 out.write(j.toString());
783 }catch (Exception e){
784 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
785 response.setCharacterEncoding("UTF-8");
786 request.setCharacterEncoding("UTF-8");
787 PrintWriter out = response.getWriter();
788 out.write(e.getMessage());
793 @RequestMapping(value={"/fw_dictionary/remove_ActionList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
794 public ModelAndView removeActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
796 ObjectMapper mapper = new ObjectMapper();
797 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
798 JsonNode root = mapper.readTree(request.getReader());
799 ActionList actionList = (ActionList)mapper.readValue(root.get("data").toString(), ActionList.class);
800 commonClassDao.delete(actionList);
801 response.setCharacterEncoding("UTF-8");
802 response.setContentType("application / json");
803 request.setCharacterEncoding("UTF-8");
805 PrintWriter out = response.getWriter();
806 String responseString = mapper.writeValueAsString(commonClassDao.getData(ActionList.class));
807 JSONObject j = new JSONObject("{actionListDictionaryDatas: " + responseString + "}");
808 out.write(j.toString());
812 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
813 response.setCharacterEncoding("UTF-8");
814 request.setCharacterEncoding("UTF-8");
815 PrintWriter out = response.getWriter();
816 out.write(e.getMessage());
821 @RequestMapping(value={"/get_ServiceGroupData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
822 public void getServiceGroupDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
824 Map<String, Object> model = new HashMap<>();
825 ObjectMapper mapper = new ObjectMapper();
826 model.put("serviceGroupDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(GroupServiceList.class)));
827 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
828 JSONObject j = new JSONObject(msg);
829 response.addHeader("successMapKey", "success");
830 response.addHeader("operation", "getDictionary");
831 response.getWriter().write(j.toString());
834 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
835 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
836 response.addHeader("error", "dictionaryDBQuery");
840 @RequestMapping(value={"/get_ServiceGroupDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
841 public void getServiceGroupDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
843 Map<String, Object> model = new HashMap<>();
844 ObjectMapper mapper = new ObjectMapper();
845 model.put("serviceGroupDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(GroupServiceList.class, "name")));
846 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
847 JSONObject j = new JSONObject(msg);
848 response.getWriter().write(j.toString());
851 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
855 @RequestMapping(value={"/fw_dictionary/save_serviceGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
856 public ModelAndView saveServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
858 boolean duplicateflag = false;
859 boolean isFakeUpdate = false;
860 boolean fromAPI = false;
861 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
864 ObjectMapper mapper = new ObjectMapper();
865 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
866 JsonNode root = mapper.readTree(request.getReader());
867 GroupServiceList groupServiceList;
870 groupServiceList = (GroupServiceList)mapper.readValue(root.get("dictionaryFields").toString(), GroupServiceList.class);
871 gridData = (GridData)mapper.readValue(root.get("dictionaryFields").toString(), GridData.class);
873 if(!groupServiceList.getGroupName().startsWith("Group_")){
874 String groupName = "Group_"+groupServiceList.getGroupName();
875 groupServiceList.setGroupName(groupName);
877 //check if update operation or create, get id for data to be updated and update attributeData
878 if (request.getParameter("operation").equals("update")) {
879 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(groupServiceList.getGroupName(), "name", GroupServiceList.class);
881 GroupServiceList data = (GroupServiceList) duplicateData.get(0);
886 groupServiceList.setId(1);
888 groupServiceList.setId(id);
892 groupServiceList = (GroupServiceList)mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GroupServiceList.class);
893 gridData = (GridData)mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GridData.class);
895 if(!groupServiceList.getGroupName().startsWith("Group_")){
896 String groupName = "Group_"+groupServiceList.getGroupName();
897 groupServiceList.setGroupName(groupName);
899 String userValue = "";
901 if(gridData.getAttributes().size() > 0){
902 for(Object attribute : gridData.getAttributes()){
903 if(attribute instanceof LinkedHashMap<?, ?>){
904 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
906 userValue = userValue + ",";
908 userValue = userValue + key ;
913 groupServiceList.setServiceList(userValue);
914 if(groupServiceList.getId() == 0){
915 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(groupServiceList.getGroupName(), "name", GroupServiceList.class);
916 if(!duplicateData.isEmpty()){
917 duplicateflag = true;
919 commonClassDao.save(groupServiceList);
923 commonClassDao.update(groupServiceList);
926 String responseString = "";
928 responseString = "Duplicate";
930 responseString = mapper.writeValueAsString(commonClassDao.getData(GroupServiceList.class));
934 if (responseString!=null && !responseString.equals("Duplicate")) {
936 responseString = "Exists";
938 responseString = "Success";
941 ModelAndView result = new ModelAndView();
942 result.setViewName(responseString);
945 response.setCharacterEncoding("UTF-8");
946 response.setContentType("application / json");
947 request.setCharacterEncoding("UTF-8");
949 PrintWriter out = response.getWriter();
950 JSONObject j = new JSONObject("{serviceGroupDictionaryDatas: " + responseString + "}");
951 out.write(j.toString());
954 }catch (Exception e){
955 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
956 response.setCharacterEncoding("UTF-8");
957 request.setCharacterEncoding("UTF-8");
958 PrintWriter out = response.getWriter();
959 out.write(e.getMessage());
964 @RequestMapping(value={"/fw_dictionary/remove_serviceGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
965 public ModelAndView removeServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
967 ObjectMapper mapper = new ObjectMapper();
968 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
969 JsonNode root = mapper.readTree(request.getReader());
970 GroupServiceList groupServiceList = (GroupServiceList)mapper.readValue(root.get("data").toString(), GroupServiceList.class);
971 commonClassDao.delete(groupServiceList);
972 response.setCharacterEncoding("UTF-8");
973 response.setContentType("application / json");
974 request.setCharacterEncoding("UTF-8");
976 PrintWriter out = response.getWriter();
978 String responseString = mapper.writeValueAsString(commonClassDao.getData(GroupServiceList.class));
979 JSONObject j = new JSONObject("{serviceGroupDictionaryDatas: " + responseString + "}");
980 out.write(j.toString());
985 System.out.println(e);
986 response.setCharacterEncoding("UTF-8");
987 request.setCharacterEncoding("UTF-8");
988 PrintWriter out = response.getWriter();
989 out.write(e.getMessage());
994 @RequestMapping(value={"/get_SecurityZoneDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
995 public void getSecurityZoneDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
997 Map<String, Object> model = new HashMap<>();
998 ObjectMapper mapper = new ObjectMapper();
999 model.put("securityZoneDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(SecurityZone.class, "zoneName")));
1000 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1001 JSONObject j = new JSONObject(msg);
1002 response.getWriter().write(j.toString());
1004 catch (Exception e){
1005 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1009 @RequestMapping(value={"/get_SecurityZoneData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1010 public void getSecurityZoneDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
1012 Map<String, Object> model = new HashMap<>();
1013 ObjectMapper mapper = new ObjectMapper();
1014 model.put("securityZoneDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(SecurityZone.class)));
1015 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1016 JSONObject j = new JSONObject(msg);
1017 response.addHeader("successMapKey", "success");
1018 response.addHeader("operation", "getDictionary");
1019 response.getWriter().write(j.toString());
1021 catch (Exception e){
1022 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1023 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
1024 response.addHeader("error", "dictionaryDBQuery");
1028 @RequestMapping(value={"/fw_dictionary/save_securityZone"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1029 public ModelAndView saveSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
1031 boolean duplicateflag = false;
1032 boolean isFakeUpdate = false;
1033 boolean fromAPI = false;
1034 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
1037 ObjectMapper mapper = new ObjectMapper();
1038 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1039 JsonNode root = mapper.readTree(request.getReader());
1040 SecurityZone securityZone;
1042 securityZone = (SecurityZone)mapper.readValue(root.get("dictionaryFields").toString(), SecurityZone.class);
1044 //check if update operation or create, get id for data to be updated and update attributeData
1045 if (request.getParameter("operation").equals("update")) {
1046 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(securityZone.getZoneName(), "zoneName", SecurityZone.class);
1048 SecurityZone data = (SecurityZone) duplicateData.get(0);
1052 securityZone.setId(1);
1054 securityZone.setId(id);
1058 securityZone = (SecurityZone)mapper.readValue(root.get("securityZoneDictionaryData").toString(), SecurityZone.class);
1060 if(securityZone.getId() == 0){
1061 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(securityZone.getZoneName(), "zoneName", SecurityZone.class);
1062 if(!duplicateData.isEmpty()){
1063 duplicateflag = true;
1065 commonClassDao.save(securityZone);
1069 commonClassDao.update(securityZone);
1072 String responseString = "";
1074 responseString = "Duplicate";
1076 responseString = mapper.writeValueAsString(commonClassDao.getData(SecurityZone.class));
1080 if (responseString!=null && !responseString.equals("Duplicate")) {
1082 responseString = "Exists";
1084 responseString = "Success";
1087 ModelAndView result = new ModelAndView();
1088 result.setViewName(responseString);
1091 response.setCharacterEncoding("UTF-8");
1092 response.setContentType("application / json");
1093 request.setCharacterEncoding("UTF-8");
1095 PrintWriter out = response.getWriter();
1096 JSONObject j = new JSONObject("{securityZoneDictionaryDatas: " + responseString + "}");
1097 out.write(j.toString());
1101 }catch (Exception e){
1102 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1103 response.setCharacterEncoding("UTF-8");
1104 request.setCharacterEncoding("UTF-8");
1105 PrintWriter out = response.getWriter();
1106 out.write(e.getMessage());
1111 @RequestMapping(value={"/fw_dictionary/remove_securityZone"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1112 public ModelAndView removeSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
1114 ObjectMapper mapper = new ObjectMapper();
1115 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1116 JsonNode root = mapper.readTree(request.getReader());
1117 SecurityZone securityZone = (SecurityZone)mapper.readValue(root.get("data").toString(), SecurityZone.class);
1118 commonClassDao.delete(securityZone);
1119 response.setCharacterEncoding("UTF-8");
1120 response.setContentType("application / json");
1121 request.setCharacterEncoding("UTF-8");
1123 PrintWriter out = response.getWriter();
1125 String responseString = mapper.writeValueAsString(commonClassDao.getData(SecurityZone.class));
1126 JSONObject j = new JSONObject("{securityZoneDictionaryDatas: " + responseString + "}");
1127 out.write(j.toString());
1131 catch (Exception e){
1132 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1133 response.setCharacterEncoding("UTF-8");
1134 request.setCharacterEncoding("UTF-8");
1135 PrintWriter out = response.getWriter();
1136 out.write(e.getMessage());
1142 @RequestMapping(value={"/get_ServiceListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1143 public void getServiceListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
1145 Map<String, Object> model = new HashMap<>();
1146 ObjectMapper mapper = new ObjectMapper();
1147 model.put("serviceListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(ServiceList.class)));
1148 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1149 JSONObject j = new JSONObject(msg);
1150 response.addHeader("successMapKey", "success");
1151 response.addHeader("operation", "getDictionary");
1152 response.getWriter().write(j.toString());
1154 catch (Exception e){
1155 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1156 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
1157 response.addHeader("error", "dictionaryDBQuery");
1161 @RequestMapping(value={"/get_ServiceListDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1162 public void getServiceListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
1164 Map<String, Object> model = new HashMap<>();
1165 ObjectMapper mapper = new ObjectMapper();
1166 model.put("serviceListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(ServiceList.class, "serviceName")));
1167 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1168 JSONObject j = new JSONObject(msg);
1169 response.getWriter().write(j.toString());
1171 catch (Exception e){
1172 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1176 @RequestMapping(value={"/fw_dictionary/save_serviceList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1177 public ModelAndView saveServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
1179 boolean duplicateflag = false;
1180 boolean isFakeUpdate = false;
1181 boolean fromAPI = false;
1182 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
1185 ObjectMapper mapper = new ObjectMapper();
1186 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1187 JsonNode root = mapper.readTree(request.getReader());
1188 ServiceList serviceList;
1189 GridData serviceListGridData;
1191 serviceList = (ServiceList)mapper.readValue(root.get("dictionaryFields").toString(), ServiceList.class);
1192 serviceListGridData = (GridData)mapper.readValue(root.get("dictionaryFields").toString(), GridData.class);
1194 //check if update operation or create, get id for data to be updated and update attributeData
1195 if (request.getParameter("operation").equals("update")) {
1196 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(serviceList.getServiceName(), "serviceName", ServiceList.class);
1198 ServiceList data = (ServiceList) duplicateData.get(0);
1202 serviceList.setId(1);
1204 serviceList.setId(id);
1208 serviceList = (ServiceList)mapper.readValue(root.get("serviceListDictionaryData").toString(), ServiceList.class);
1209 serviceListGridData = (GridData)mapper.readValue(root.get("serviceListDictionaryData").toString(), GridData.class);
1211 String tcpValue = "";
1213 if(serviceListGridData.getTransportProtocols().size() > 0){
1214 for(Object attribute : serviceListGridData.getTransportProtocols()){
1215 if(attribute instanceof LinkedHashMap<?, ?>){
1216 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
1218 tcpValue = tcpValue + ",";
1220 tcpValue = tcpValue + key ;
1225 serviceList.setServiceTransProtocol(tcpValue);
1226 String appValue = "";
1228 if(serviceListGridData.getAppProtocols().size() > 0){
1229 for(Object attribute : serviceListGridData.getAppProtocols()){
1230 if(attribute instanceof LinkedHashMap<?, ?>){
1231 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
1233 appValue = appValue + ",";
1235 appValue = appValue + key ;
1240 serviceList.setServiceAppProtocol(appValue);
1241 serviceList.setServiceType("SERVICE");
1242 if(serviceList.getId() == 0){
1243 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(serviceList.getServiceName(), "serviceName", ServiceList.class);
1244 if(!duplicateData.isEmpty()){
1245 duplicateflag = true;
1247 commonClassDao.save(serviceList);
1251 commonClassDao.update(serviceList);
1255 String responseString = "";
1257 responseString = "Duplicate";
1259 responseString = mapper.writeValueAsString(commonClassDao.getData(ServiceList.class));
1262 if (responseString!=null && !responseString.equals("Duplicate")) {
1264 responseString = "Exists";
1266 responseString = "Success";
1269 ModelAndView result = new ModelAndView();
1270 result.setViewName(responseString);
1273 response.setCharacterEncoding("UTF-8");
1274 response.setContentType("application / json");
1275 request.setCharacterEncoding("UTF-8");
1277 PrintWriter out = response.getWriter();
1278 JSONObject j = new JSONObject("{serviceListDictionaryDatas: " + responseString + "}");
1279 out.write(j.toString());
1282 }catch (Exception e){
1283 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1284 response.setCharacterEncoding("UTF-8");
1285 request.setCharacterEncoding("UTF-8");
1286 PrintWriter out = response.getWriter();
1287 out.write(e.getMessage());
1293 @RequestMapping(value={"/fw_dictionary/remove_serviceList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1294 public ModelAndView removeServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
1296 ObjectMapper mapper = new ObjectMapper();
1297 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1298 JsonNode root = mapper.readTree(request.getReader());
1299 ServiceList serviceList = (ServiceList)mapper.readValue(root.get("data").toString(), ServiceList.class);
1300 commonClassDao.delete(serviceList);
1301 response.setCharacterEncoding("UTF-8");
1302 response.setContentType("application / json");
1303 request.setCharacterEncoding("UTF-8");
1305 PrintWriter out = response.getWriter();
1307 String responseString = mapper.writeValueAsString(commonClassDao.getData(ServiceList.class));
1308 JSONObject j = new JSONObject("{serviceListDictionaryDatas: " + responseString + "}");
1309 out.write(j.toString());
1313 catch (Exception e){
1314 System.out.println(e);
1315 response.setCharacterEncoding("UTF-8");
1316 request.setCharacterEncoding("UTF-8");
1317 PrintWriter out = response.getWriter();
1318 out.write(e.getMessage());
1323 @RequestMapping(value={"/get_ZoneData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1324 public void getZoneDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
1326 Map<String, Object> model = new HashMap<>();
1327 ObjectMapper mapper = new ObjectMapper();
1328 model.put("zoneDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(Zone.class)));
1329 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1330 JSONObject j = new JSONObject(msg);
1331 response.addHeader("successMapKey", "success");
1332 response.addHeader("operation", "getDictionary");
1333 response.getWriter().write(j.toString());
1335 catch (Exception e){
1336 LOGGER.error("Exception Occured"+e);
1340 @RequestMapping(value={"/get_ZoneDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1341 public void getZoneDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
1343 Map<String, Object> model = new HashMap<>();
1344 ObjectMapper mapper = new ObjectMapper();
1345 model.put("zoneDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(Zone.class, "zoneName")));
1346 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1347 JSONObject j = new JSONObject(msg);
1348 response.getWriter().write(j.toString());
1350 catch (Exception e){
1351 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1355 @RequestMapping(value={"/fw_dictionary/save_zoneName"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1356 public ModelAndView saveZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
1358 boolean duplicateflag = false;
1359 boolean isFakeUpdate = false;
1360 boolean fromAPI = false;
1361 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
1364 ObjectMapper mapper = new ObjectMapper();
1365 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1366 JsonNode root = mapper.readTree(request.getReader());
1369 zone = (Zone)mapper.readValue(root.get("dictionaryFields").toString(), Zone.class);
1371 //check if update operation or create, get id for data to be updated and update attributeData
1372 if (request.getParameter("operation").equals("update")) {
1373 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(zone.getZoneName(), "zoneName", Zone.class);
1375 Zone data = (Zone) duplicateData.get(0);
1385 zone = (Zone)mapper.readValue(root.get("zoneDictionaryData").toString(), Zone.class);
1387 if(zone.getId() == 0){
1388 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(zone.getZoneName(), "zoneName", Zone.class);
1389 if(!duplicateData.isEmpty()){
1390 duplicateflag = true;
1392 commonClassDao.save(zone);
1396 commonClassDao.update(zone);
1399 String responseString = "";
1401 responseString = "Duplicate";
1403 responseString = mapper.writeValueAsString(commonClassDao.getData(Zone.class));
1407 if (responseString!=null && !responseString.equals("Duplicate")) {
1409 responseString = "Exists";
1411 responseString = "Success";
1414 ModelAndView result = new ModelAndView();
1415 result.setViewName(responseString);
1418 response.setCharacterEncoding("UTF-8");
1419 response.setContentType("application / json");
1420 request.setCharacterEncoding("UTF-8");
1422 PrintWriter out = response.getWriter();
1423 JSONObject j = new JSONObject("{zoneDictionaryDatas: " + responseString + "}");
1424 out.write(j.toString());
1427 }catch (Exception e){
1428 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1429 response.setCharacterEncoding("UTF-8");
1430 request.setCharacterEncoding("UTF-8");
1431 PrintWriter out = response.getWriter();
1432 out.write(e.getMessage());
1437 @RequestMapping(value={"/fw_dictionary/remove_zone"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1438 public ModelAndView removeZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
1440 ObjectMapper mapper = new ObjectMapper();
1441 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1442 JsonNode root = mapper.readTree(request.getReader());
1443 Zone zone = (Zone)mapper.readValue(root.get("data").toString(), Zone.class);
1444 commonClassDao.delete(zone);
1445 response.setCharacterEncoding("UTF-8");
1446 response.setContentType("application / json");
1447 request.setCharacterEncoding("UTF-8");
1449 PrintWriter out = response.getWriter();
1451 String responseString = mapper.writeValueAsString(commonClassDao.getData(Zone.class));
1452 JSONObject j = new JSONObject("{zoneDictionaryDatas: " + responseString + "}");
1453 out.write(j.toString());
1457 catch (Exception e){
1458 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1459 response.setCharacterEncoding("UTF-8");
1460 request.setCharacterEncoding("UTF-8");
1461 PrintWriter out = response.getWriter();
1462 out.write(e.getMessage());
1467 @RequestMapping(value={"/get_TermListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1468 public void getTermListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
1470 Map<String, Object> model = new HashMap<String, Object>();
1471 ObjectMapper mapper = new ObjectMapper();
1472 model.put("termListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(TermList.class, "termName")));
1473 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1474 JSONObject j = new JSONObject(msg);
1475 response.getWriter().write(j.toString());
1477 catch (Exception e){
1478 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1482 @RequestMapping(value={"/get_TermListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1483 public void getTermListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
1485 Map<String, Object> model = new HashMap<String, Object>();
1486 ObjectMapper mapper = new ObjectMapper();
1487 model.put("termListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(TermList.class)));
1488 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1489 JSONObject j = new JSONObject(msg);
1490 response.addHeader("successMapKey", "success");
1491 response.addHeader("operation", "getDictionary");
1492 response.getWriter().write(j.toString());
1494 catch (Exception e){
1495 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1496 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
1497 response.addHeader("error", "dictionaryDBQuery");
1501 @RequestMapping(value={"/fw_dictionary/save_termList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1502 public ModelAndView saveTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
1504 boolean duplicateflag = false;
1505 boolean isFakeUpdate = false;
1506 boolean fromAPI = false;
1507 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
1510 ObjectMapper mapper = new ObjectMapper();
1511 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1512 JsonNode root = mapper.readTree(request.getReader());
1514 TermListData termListDatas;
1515 String userId = null;
1517 termList = (TermList)mapper.readValue(root.get("dictionaryFields").toString(), TermList.class);
1518 termListDatas = (TermListData)mapper.readValue(root.get("dictionaryFields").toString(), TermListData.class);
1521 //check if update operation or create, get id for data to be updated and update attributeData
1522 if (request.getParameter("operation").equals("update")) {
1523 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(termList.getTermName(), "termName", TermList.class);
1525 TermList data = (TermList) duplicateData.get(0);
1533 termList.setUserCreatedBy(this.getUserInfo(userId));
1536 termList = (TermList)mapper.readValue(root.get("termListDictionaryData").toString(), TermList.class);
1537 termListDatas = (TermListData)mapper.readValue(root.get("termListDictionaryData").toString(), TermListData.class);
1538 userId = root.get("userid").textValue();
1540 String fromZoneValue = "";
1542 if(termListDatas.getFromZoneDatas().size() > 0){
1543 for(Object fromZone : termListDatas.getFromZoneDatas()){
1544 if(fromZone instanceof LinkedHashMap<?, ?>){
1545 String key = ((LinkedHashMap<?, ?>) fromZone).get("option").toString();
1547 fromZoneValue = fromZoneValue + ",";
1549 fromZoneValue = fromZoneValue + key ;
1554 termList.setFromZones(fromZoneValue);
1556 String toZoneValue = "";
1557 int toZonecounter = 0;
1558 if(termListDatas.getToZoneDatas().size() > 0){
1559 for(Object toZone : termListDatas.getToZoneDatas()){
1560 if(toZone instanceof LinkedHashMap<?, ?>){
1561 String key = ((LinkedHashMap<?, ?>) toZone).get("option").toString();
1562 if(toZonecounter>0){
1563 toZoneValue = toZoneValue + ",";
1565 toZoneValue = toZoneValue + key ;
1570 termList.setToZones(toZoneValue);
1572 String srcListValues = "";
1573 int srcListcounter = 0;
1574 if(termListDatas.getSourceListDatas().size() > 0){
1575 for(Object srcList : termListDatas.getSourceListDatas()){
1576 if(srcList instanceof LinkedHashMap<?, ?>){
1577 String key = ((LinkedHashMap<?, ?>) srcList).get("option").toString();
1578 if(srcListcounter>0){
1579 srcListValues = srcListValues + ",";
1581 srcListValues = srcListValues + key ;
1586 termList.setSrcIPList(srcListValues);
1588 String desListValues = "";
1589 int destListcounter = 0;
1590 if(termListDatas.getDestinationListDatas().size() > 0){
1591 for(Object desList : termListDatas.getDestinationListDatas()){
1592 if(desList instanceof LinkedHashMap<?, ?>){
1593 String key = ((LinkedHashMap<?, ?>) desList).get("option").toString();
1594 if(destListcounter>0){
1595 desListValues = desListValues + ",";
1597 desListValues = desListValues + key ;
1602 termList.setDestIPList(desListValues);
1604 String srcSerValue = "";
1605 int srcSercounter = 0;
1606 if(termListDatas.getSourceServiceDatas().size() > 0){
1607 for(Object srcSrc : termListDatas.getSourceServiceDatas()){
1608 if(srcSrc instanceof LinkedHashMap<?, ?>){
1609 String key = ((LinkedHashMap<?, ?>) srcSrc).get("option").toString();
1610 if(srcSercounter>0){
1611 srcSerValue = srcSerValue + ",";
1613 srcSerValue = srcSerValue + key ;
1618 termList.setSrcPortList(srcSerValue);
1620 String desSrcValue = "";
1621 int desSrccounter = 0;
1622 if(termListDatas.getDestinationServiceDatas().size() > 0){
1623 for(Object desSrc : termListDatas.getDestinationServiceDatas()){
1624 if(desSrc instanceof LinkedHashMap<?, ?>){
1625 String key = ((LinkedHashMap<?, ?>) desSrc).get("option").toString();
1626 if(desSrccounter>0){
1627 desSrcValue = desSrcValue + ",";
1629 desSrcValue = desSrcValue + key ;
1634 termList.setDestPortList(desSrcValue);
1636 String actionValue = "";
1637 int actioncounter = 0;
1638 if(termListDatas.getActionListDatas().size() > 0){
1639 for(Object actionList : termListDatas.getActionListDatas()){
1640 if(actionList instanceof LinkedHashMap<?, ?>){
1641 String key = ((LinkedHashMap<?, ?>) actionList).get("option").toString();
1642 if(actioncounter>0){
1643 actionValue = actionValue + ",";
1645 actionValue = actionValue + key ;
1650 termList.setAction(actionValue);
1652 if(termList.getId() == 0){
1653 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(termList.getTermName(), "termName", TermList.class);
1654 if(!duplicateData.isEmpty()){
1655 duplicateflag = true;
1657 termList.setUserCreatedBy(this.getUserInfo(userId));
1658 termList.setUserModifiedBy(this.getUserInfo(userId));
1659 commonClassDao.save(termList);
1663 termList.setUserModifiedBy(this.getUserInfo(userId));
1664 commonClassDao.update(termList);
1667 String responseString = "";
1669 responseString = "Duplicate";
1671 responseString = mapper.writeValueAsString(commonClassDao.getData(TermList.class));
1675 if (responseString!=null && !responseString.equals("Duplicate")) {
1677 responseString = "Exists";
1679 responseString = "Success";
1682 ModelAndView result = new ModelAndView();
1683 result.setViewName(responseString);
1686 response.setCharacterEncoding("UTF-8");
1687 response.setContentType("application / json");
1688 request.setCharacterEncoding("UTF-8");
1690 PrintWriter out = response.getWriter();
1691 JSONObject j = new JSONObject("{termListDictionaryDatas: " + responseString + "}");
1692 out.write(j.toString());
1695 }catch (Exception e){
1696 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1697 response.setCharacterEncoding("UTF-8");
1698 request.setCharacterEncoding("UTF-8");
1699 PrintWriter out = response.getWriter();
1700 out.write(e.getMessage());
1705 @RequestMapping(value={"/fw_dictionary/remove_termList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1706 public ModelAndView removeTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
1708 ObjectMapper mapper = new ObjectMapper();
1709 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1710 JsonNode root = mapper.readTree(request.getReader());
1711 TermList termList = (TermList)mapper.readValue(root.get("data").toString(), TermList.class);
1712 commonClassDao.delete(termList);
1713 response.setCharacterEncoding("UTF-8");
1714 response.setContentType("application / json");
1715 request.setCharacterEncoding("UTF-8");
1717 PrintWriter out = response.getWriter();
1719 String responseString = mapper.writeValueAsString(commonClassDao.getData(TermList.class));
1720 JSONObject j = new JSONObject("{termListDictionaryDatas: " + responseString + "}");
1721 out.write(j.toString());
1725 catch (Exception e){
1726 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1727 response.setCharacterEncoding("UTF-8");
1728 request.setCharacterEncoding("UTF-8");
1729 PrintWriter out = response.getWriter();
1730 out.write(e.getMessage());
1734 //ParentList Dictionary Data
1735 @RequestMapping(value={"/get_FWDictionaryListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1736 public void getFWDictListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
1738 Map<String, Object> model = new HashMap<>();
1739 ObjectMapper mapper = new ObjectMapper();
1740 model.put("fwDictListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(FirewallDictionaryList.class, "parentItemName")));
1741 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1742 JSONObject j = new JSONObject(msg);
1743 response.getWriter().write(j.toString());
1745 catch (Exception e){
1746 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1750 @RequestMapping(value={"/get_FWDictionaryListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1751 public void getFWDictionaryListEntityData(HttpServletRequest request, HttpServletResponse response){
1753 Map<String, Object> model = new HashMap<>();
1754 ObjectMapper mapper = new ObjectMapper();
1755 model.put("fwDictListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class)));
1756 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1757 JSONObject j = new JSONObject(msg);
1758 response.addHeader("successMapKey", "success");
1759 response.addHeader("operation", "getDictionary");
1760 response.getWriter().write(j.toString());
1762 catch (Exception e){
1763 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1764 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
1765 response.addHeader("error", "dictionaryDBQuery");
1769 @RequestMapping(value={"/fw_dictionary/save_FWDictionaryList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1770 public ModelAndView saveFWDictionaryList(HttpServletRequest request, HttpServletResponse response) throws Exception{
1772 boolean duplicateflag = false;
1773 ObjectMapper mapper = new ObjectMapper();
1774 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1775 JsonNode root = mapper.readTree(request.getReader());
1776 FirewallDictionaryList fwDictList = (FirewallDictionaryList)mapper.readValue(root.get("fwDictListDictionaryData").toString(), FirewallDictionaryList.class);
1777 GridData gridData = (GridData)mapper.readValue(root.get("fwDictListDictionaryData").toString(), GridData.class);
1778 String userSLValue = "";
1780 if(gridData.getAttributes().size() > 0){
1781 for(Object attribute : gridData.getAttributes()){
1782 if(attribute instanceof LinkedHashMap<?, ?>){
1783 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
1785 userSLValue = userSLValue + ",";
1787 userSLValue = userSLValue + key ;
1792 fwDictList.setServiceList(userSLValue);
1793 String userALValue = "";
1795 if(gridData.getAlAttributes().size() > 0){
1796 for(Object attribute : gridData.getAlAttributes()){
1797 if(attribute instanceof LinkedHashMap<?, ?>){
1798 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
1800 userALValue = userALValue + ",";
1802 userALValue = userALValue + key ;
1807 fwDictList.setAddressList(userALValue);
1808 if(fwDictList.getId() == 0){
1809 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwDictList.getParentItemName(), "parentItemName", FirewallDictionaryList.class);
1810 if(!duplicateData.isEmpty()){
1811 duplicateflag = true;
1813 commonClassDao.save(fwDictList);
1816 commonClassDao.update(fwDictList);
1818 response.setCharacterEncoding("UTF-8");
1819 response.setContentType("application / json");
1820 request.setCharacterEncoding("UTF-8");
1822 PrintWriter out = response.getWriter();
1823 String responseString = "";
1825 responseString = "Duplicate";
1827 responseString = mapper.writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class));
1829 JSONObject j = new JSONObject("{fwDictListDictionaryDatas: " + responseString + "}");
1831 out.write(j.toString());
1835 catch (Exception e){
1836 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1837 response.setCharacterEncoding("UTF-8");
1838 request.setCharacterEncoding("UTF-8");
1839 PrintWriter out = response.getWriter();
1840 out.write(e.getMessage());
1845 @RequestMapping(value={"/fw_dictionary/remove_FWDictionaryList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1846 public ModelAndView removeFWDictionaryListy(HttpServletRequest request, HttpServletResponse response) throws Exception {
1848 ObjectMapper mapper = new ObjectMapper();
1849 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1850 JsonNode root = mapper.readTree(request.getReader());
1851 FirewallDictionaryList fwDictList = (FirewallDictionaryList)mapper.readValue(root.get("data").toString(), FirewallDictionaryList.class);
1852 commonClassDao.delete(fwDictList);
1853 response.setCharacterEncoding("UTF-8");
1854 response.setContentType("application / json");
1855 request.setCharacterEncoding("UTF-8");
1857 PrintWriter out = response.getWriter();
1859 String responseString = mapper.writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class));
1860 JSONObject j = new JSONObject("{fwDictListDictionaryDatas: " + responseString + "}");
1861 out.write(j.toString());
1865 catch (Exception e){
1866 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1867 response.setCharacterEncoding("UTF-8");
1868 request.setCharacterEncoding("UTF-8");
1869 PrintWriter out = response.getWriter();
1870 out.write(e.getMessage());
1876 @RequestMapping(value={"/get_TagPickerNameByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1877 public void getTagPickerNameEntityDataByName(HttpServletRequest request, HttpServletResponse response){
1879 Map<String, Object> model = new HashMap<String, Object>();
1880 ObjectMapper mapper = new ObjectMapper();
1881 model.put("fwTagPickerDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(FWTagPicker.class, "tagPickerName")));
1882 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1883 JSONObject j = new JSONObject(msg);
1884 response.getWriter().write(j.toString());
1886 catch (Exception e){
1887 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1891 @RequestMapping(value={"/get_TagPickerListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1892 public void getTagPickerDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
1894 Map<String, Object> model = new HashMap<String, Object>();
1895 ObjectMapper mapper = new ObjectMapper();
1896 model.put("fwTagPickerDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(FWTagPicker.class)));
1897 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1898 JSONObject j = new JSONObject(msg);
1899 response.getWriter().write(j.toString());
1901 catch (Exception e){
1902 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1906 @RequestMapping(value={"/fw_dictionary/save_fwTagPicker"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1907 public ModelAndView saveFirewallTagPickerDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
1909 boolean duplicateflag = false;
1910 boolean fromAPI = false;
1911 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
1915 ObjectMapper mapper = new ObjectMapper();
1916 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1917 JsonNode root = mapper.readTree(request.getReader());
1920 FWTagPicker fwTagPicker;
1922 String userId = null;
1924 fwTagPicker = (FWTagPicker)mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), FWTagPicker.class);
1925 data = (TagGridValues)mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), TagGridValues.class);
1928 //check if update operation or create, get id for data to be updated and update attributeData
1929 if (request.getParameter("operation").equals("update")) {
1930 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTagPicker.getTagPickerName(), "tagPickerName", FWTagPicker.class);
1932 FWTagPicker dbdata = (FWTagPicker) duplicateData.get(0);
1933 id = dbdata.getId();
1934 fwTagPicker.setId(id);
1935 fwTagPicker.setUserCreatedBy(this.getUserInfo(userId));
1939 fwTagPicker = (FWTagPicker)mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), FWTagPicker.class);
1940 data = (TagGridValues)mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), TagGridValues.class);
1941 userId = root.get("userid").textValue();
1946 if(data.getTags().size() > 0){
1947 for(Object attribute : data.getTags()){
1948 if(attribute instanceof LinkedHashMap<?, ?>){
1949 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
1950 String value = ((LinkedHashMap<?, ?>) attribute).get("number").toString();
1952 header = header + "#";
1954 header = header + key + ":";
1955 header = header + value;
1960 fwTagPicker.setTagValues(header);
1961 if(fwTagPicker.getId() == 0){
1962 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTagPicker.getTagPickerName(), "tagPickerName", FWTagPicker.class);
1963 if(!duplicateData.isEmpty()){
1964 duplicateflag = true;
1966 fwTagPicker.setUserCreatedBy(this.getUserInfo(userId));
1967 fwTagPicker.setUserModifiedBy(this.getUserInfo(userId));
1968 commonClassDao.save(fwTagPicker);
1971 fwTagPicker.setUserModifiedBy(this.getUserInfo(userId));
1972 commonClassDao.update(fwTagPicker);
1975 String responseString = "";
1977 responseString = "Duplicate";
1979 responseString = mapper.writeValueAsString(commonClassDao.getData(FWTagPicker.class));
1983 if (responseString!=null && !responseString.equals("Duplicate")) {
1984 responseString = "Success";
1986 ModelAndView result = new ModelAndView();
1987 result.setViewName(responseString);
1990 response.setCharacterEncoding("UTF-8");
1991 response.setContentType("application / json");
1992 request.setCharacterEncoding("UTF-8");
1994 PrintWriter out = response.getWriter();
1995 JSONObject j = new JSONObject("{fwTagPickerDictionaryDatas: " + responseString + "}");
1996 out.write(j.toString());
2000 catch (Exception e){
2001 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2002 response.setCharacterEncoding("UTF-8");
2003 request.setCharacterEncoding("UTF-8");
2004 PrintWriter out = response.getWriter();
2005 out.write(e.getMessage());
2010 @RequestMapping(value={"/fw_dictionary/remove_tagPicker"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
2011 public ModelAndView removeFirewallTagPickerDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
2013 ObjectMapper mapper = new ObjectMapper();
2014 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2015 JsonNode root = mapper.readTree(request.getReader());
2016 FWTagPicker fwTagPicker = (FWTagPicker)mapper.readValue(root.get("data").toString(), FWTagPicker.class);
2017 commonClassDao.delete(fwTagPicker);
2018 response.setCharacterEncoding("UTF-8");
2019 response.setContentType("application / json");
2020 request.setCharacterEncoding("UTF-8");
2022 PrintWriter out = response.getWriter();
2023 String responseString = mapper.writeValueAsString(commonClassDao.getData(FWTagPicker.class));
2024 JSONObject j = new JSONObject("{fwTagPickerDictionaryDatas: " + responseString + "}");
2025 out.write(j.toString());
2028 catch (Exception e){
2029 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2030 response.setCharacterEncoding("UTF-8");
2031 request.setCharacterEncoding("UTF-8");
2032 PrintWriter out = response.getWriter();
2033 out.write(e.getMessage());
2039 @RequestMapping(value={"/get_TagNameByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
2040 public void getTagNameEntityDataByName(HttpServletRequest request, HttpServletResponse response){
2042 Map<String, Object> model = new HashMap<>();
2043 ObjectMapper mapper = new ObjectMapper();
2044 model.put("fwTagDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(FWTag.class, "fwTagName")));
2045 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
2046 JSONObject j = new JSONObject(msg);
2047 response.getWriter().write(j.toString());
2049 catch (Exception e){
2050 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2054 @RequestMapping(value={"/get_TagListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
2055 public void getTagDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
2057 Map<String, Object> model = new HashMap<>();
2058 ObjectMapper mapper = new ObjectMapper();
2059 model.put("fwTagDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(FWTag.class)));
2060 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
2061 JSONObject j = new JSONObject(msg);
2062 response.getWriter().write(j.toString());
2064 catch (Exception e){
2065 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2069 @RequestMapping(value={"/fw_dictionary/save_fwTag"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
2070 public ModelAndView saveFirewallTagDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
2072 boolean duplicateflag = false;
2073 boolean fromAPI = false;
2074 if (request.getParameter("apiflag")!=null && request.getParameter("apiflag").equalsIgnoreCase("api")) {
2078 ObjectMapper mapper = new ObjectMapper();
2079 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2080 JsonNode root = mapper.readTree(request.getReader());
2084 TagGridValues tagGridValues;
2085 String userId = null;
2087 fwTag = (FWTag)mapper.readValue(root.get("fwTagDictionaryDatas").toString(), FWTag.class);
2088 tagGridValues = (TagGridValues)mapper.readValue(root.get("fwTagDictionaryDatas").toString(), TagGridValues.class);
2091 //check if update operation or create, get id for data to be updated and update attributeData
2092 if (request.getParameter("operation").equals("update")) {
2093 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTag.getFwTagName(), "tagName", FWTag.class);
2095 FWTag data = (FWTag) duplicateData.get(0);
2098 fwTag.setUserCreatedBy(this.getUserInfo(userId));
2102 fwTag = (FWTag)mapper.readValue(root.get("fwTagDictionaryData").toString(), FWTag.class);
2103 tagGridValues = (TagGridValues)mapper.readValue(root.get("fwTagDictionaryData").toString(), TagGridValues.class);
2104 userId = root.get("userid").textValue();
2107 String userValue = "";
2109 if(tagGridValues.getTags().size() > 0){
2110 for(Object attribute : tagGridValues.getTags()){
2111 if(attribute instanceof LinkedHashMap<?, ?>){
2112 String key = ((LinkedHashMap<?, ?>) attribute).get("tags").toString();
2114 userValue = userValue + ",";
2116 userValue = userValue + key ;
2121 fwTag.setTagValues(userValue);
2122 if(fwTag.getId() == 0){
2123 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTag.getFwTagName(), "fwTagName", FWTag.class);
2124 if(!duplicateData.isEmpty()){
2125 duplicateflag = true;
2127 fwTag.setUserCreatedBy(this.getUserInfo(userId));
2128 fwTag.setUserModifiedBy(this.getUserInfo(userId));
2129 commonClassDao.save(fwTag);
2132 fwTag.setUserModifiedBy(this.getUserInfo(userId));
2133 commonClassDao.update(fwTag);
2136 String responseString = "";
2138 responseString = "Duplicate";
2140 responseString = mapper.writeValueAsString(commonClassDao.getData(FWTag.class));
2143 if (responseString!=null && !responseString.equals("Duplicate")) {
2144 responseString = "Success";
2146 ModelAndView result = new ModelAndView();
2147 result.setViewName(responseString);
2151 response.setCharacterEncoding("UTF-8");
2152 response.setContentType("application / json");
2153 request.setCharacterEncoding("UTF-8");
2155 PrintWriter out = response.getWriter();
2156 JSONObject j = new JSONObject("{fwTagDictionaryDatas: " + responseString + "}");
2157 out.write(j.toString());
2161 catch (Exception e){
2162 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2163 response.setCharacterEncoding("UTF-8");
2164 request.setCharacterEncoding("UTF-8");
2165 PrintWriter out = response.getWriter();
2166 out.write(e.getMessage());
2171 @RequestMapping(value={"/fw_dictionary/remove_tagList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
2172 public ModelAndView removeFirewallTagDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
2174 ObjectMapper mapper = new ObjectMapper();
2175 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2176 JsonNode root = mapper.readTree(request.getReader());
2177 FWTag fwTag = (FWTag)mapper.readValue(root.get("data").toString(), FWTag.class);
2178 commonClassDao.delete(fwTag);
2179 response.setCharacterEncoding("UTF-8");
2180 response.setContentType("application / json");
2181 request.setCharacterEncoding("UTF-8");
2183 PrintWriter out = response.getWriter();
2185 String responseString = mapper.writeValueAsString(commonClassDao.getData(FWTag.class));
2186 JSONObject j = new JSONObject("{fwTagDictionaryDatas: " + responseString + "}");
2187 out.write(j.toString());
2191 catch (Exception e){
2192 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2193 response.setCharacterEncoding("UTF-8");
2194 request.setCharacterEncoding("UTF-8");
2195 PrintWriter out = response.getWriter();
2196 out.write(e.getMessage());
2202 class TagGridValues{
2203 private ArrayList<Object> tags;
2205 public ArrayList<Object> getTags() {
2209 public void setTags(ArrayList<Object> tags) {
2215 private ArrayList<Object> attributes;
2217 public ArrayList<Object> getAttributes() {
2221 public void setAttributes(ArrayList<Object> attributes) {
2222 this.attributes = attributes;
2227 private ArrayList<Object> fromZoneDatas;
2228 private ArrayList<Object> toZoneDatas;
2229 private ArrayList<Object> sourceListDatas;
2230 private ArrayList<Object> destinationListDatas;
2231 private ArrayList<Object> sourceServiceDatas;
2232 private ArrayList<Object> destinationServiceDatas;
2233 private ArrayList<Object> actionListDatas;
2234 public ArrayList<Object> getFromZoneDatas() {
2235 return fromZoneDatas;
2237 public void setFromZoneDatas(ArrayList<Object> fromZoneDatas) {
2238 this.fromZoneDatas = fromZoneDatas;
2240 public ArrayList<Object> getToZoneDatas() {
2243 public void setToZoneDatas(ArrayList<Object> toZoneDatas) {
2244 this.toZoneDatas = toZoneDatas;
2246 public ArrayList<Object> getSourceListDatas() {
2247 return sourceListDatas;
2249 public void setSourceListDatas(ArrayList<Object> sourceListDatas) {
2250 this.sourceListDatas = sourceListDatas;
2252 public ArrayList<Object> getDestinationListDatas() {
2253 return destinationListDatas;
2255 public void setDestinationListDatas(ArrayList<Object> destinationListDatas) {
2256 this.destinationListDatas = destinationListDatas;
2258 public ArrayList<Object> getSourceServiceDatas() {
2259 return sourceServiceDatas;
2261 public void setSourceServiceDatas(ArrayList<Object> sourceServiceDatas) {
2262 this.sourceServiceDatas = sourceServiceDatas;
2264 public ArrayList<Object> getDestinationServiceDatas() {
2265 return destinationServiceDatas;
2267 public void setDestinationServiceDatas(ArrayList<Object> destinationServiceDatas) {
2268 this.destinationServiceDatas = destinationServiceDatas;
2270 public ArrayList<Object> getActionListDatas() {
2271 return actionListDatas;
2273 public void setActionListDatas(ArrayList<Object> actionListDatas) {
2274 this.actionListDatas = actionListDatas;