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.pap.xacml.rest.adapters.GridData;
37 import org.openecomp.policy.pap.xacml.rest.util.JsonMessage;
38 import org.openecomp.policy.rest.dao.ActionListDao;
39 import org.openecomp.policy.rest.dao.AddressGroupDao;
40 import org.openecomp.policy.rest.dao.FirewallDictionaryListDao;
41 import org.openecomp.policy.rest.dao.PortListDao;
42 import org.openecomp.policy.rest.dao.PrefixListDao;
43 import org.openecomp.policy.rest.dao.ProtocolListDao;
44 import org.openecomp.policy.rest.dao.SecurityZoneDao;
45 import org.openecomp.policy.rest.dao.ServiceGroupDao;
46 import org.openecomp.policy.rest.dao.ServiceListDao;
47 import org.openecomp.policy.rest.dao.TermListDao;
48 import org.openecomp.policy.rest.dao.UserInfoDao;
49 import org.openecomp.policy.rest.dao.ZoneDao;
50 import org.openecomp.policy.rest.jpa.ActionList;
51 import org.openecomp.policy.rest.jpa.AddressGroup;
52 import org.openecomp.policy.rest.jpa.FirewallDictionaryList;
53 import org.openecomp.policy.rest.jpa.GroupServiceList;
54 import org.openecomp.policy.rest.jpa.PREFIXLIST;
55 import org.openecomp.policy.rest.jpa.PortList;
56 import org.openecomp.policy.rest.jpa.ProtocolList;
57 import org.openecomp.policy.rest.jpa.SecurityZone;
58 import org.openecomp.policy.rest.jpa.ServiceList;
59 import org.openecomp.policy.rest.jpa.TermList;
60 import org.openecomp.policy.rest.jpa.UserInfo;
61 import org.openecomp.policy.rest.jpa.Zone;
62 import org.springframework.beans.factory.annotation.Autowired;
63 import org.springframework.http.MediaType;
64 import org.springframework.stereotype.Controller;
65 import org.springframework.web.bind.annotation.RequestMapping;
66 import org.springframework.web.servlet.ModelAndView;
68 import com.fasterxml.jackson.databind.DeserializationFeature;
69 import com.fasterxml.jackson.databind.JsonNode;
70 import com.fasterxml.jackson.databind.ObjectMapper;
74 public class FirewallDictionaryController {
77 PrefixListDao prefixListDao;
80 PortListDao portListDao;
83 ProtocolListDao protocolListDao;
86 AddressGroupDao addressGroupDao;
89 ActionListDao actionListDao;
92 SecurityZoneDao securityZoneDao;
95 ServiceGroupDao serviceGroupDao;
98 ServiceListDao serviceListDao;
101 TermListDao termListDao;
107 UserInfoDao userInfoDao;
110 FirewallDictionaryListDao fwDictionaryListDao;
114 public UserInfo getUserInfo(String loginId){
115 UserInfo name = userInfoDao.getUserInfoByLoginId(loginId);
119 @RequestMapping(value={"/get_PrefixListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
120 public void getPrefixListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
122 Map<String, Object> model = new HashMap<String, Object>();
123 ObjectMapper mapper = new ObjectMapper();
124 model.put("prefixListDictionaryDatas", mapper.writeValueAsString(prefixListDao.getPrefixListDataByName()));
125 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
126 JSONObject j = new JSONObject(msg);
127 response.getWriter().write(j.toString());
134 @RequestMapping(value={"/get_PrefixListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
135 public void getPrefixListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
137 Map<String, Object> model = new HashMap<String, Object>();
138 ObjectMapper mapper = new ObjectMapper();
139 model.put("prefixListDictionaryDatas", mapper.writeValueAsString(prefixListDao.getPREFIXLISTData()));
140 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
141 JSONObject j = new JSONObject(msg);
142 response.getWriter().write(j.toString());
149 @RequestMapping(value={"/fw_dictionary/save_prefixList.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
150 public ModelAndView savePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
152 boolean duplicateflag = false;
153 ObjectMapper mapper = new ObjectMapper();
154 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
155 JsonNode root = mapper.readTree(request.getReader());
156 PREFIXLIST prefixList = (PREFIXLIST)mapper.readValue(root.get("prefixListDictionaryData").toString(), PREFIXLIST.class);
157 if(prefixList.getId() == 0){
158 CheckDictionaryDuplicateEntries entry = new CheckDictionaryDuplicateEntries();
159 List<Object> duplicateData = entry.CheckDuplicateEntry(prefixList.getPrefixListName(), "prefixListName", PREFIXLIST.class);
160 if(!duplicateData.isEmpty()){
161 duplicateflag = true;
163 prefixListDao.Save(prefixList);
166 prefixListDao.update(prefixList);
168 response.setCharacterEncoding("UTF-8");
169 response.setContentType("application / json");
170 request.setCharacterEncoding("UTF-8");
172 PrintWriter out = response.getWriter();
173 String responseString = "";
175 responseString = "Duplicate";
177 responseString = mapper.writeValueAsString(this.prefixListDao.getPREFIXLISTData());
179 JSONObject j = new JSONObject("{prefixListDictionaryDatas: " + responseString + "}");
181 out.write(j.toString());
186 response.setCharacterEncoding("UTF-8");
187 request.setCharacterEncoding("UTF-8");
188 PrintWriter out = response.getWriter();
189 out.write(e.getMessage());
194 @RequestMapping(value={"/fw_dictionary/remove_PrefixList.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
195 public ModelAndView removePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
197 ObjectMapper mapper = new ObjectMapper();
198 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
199 JsonNode root = mapper.readTree(request.getReader());
200 PREFIXLIST prefixList = (PREFIXLIST)mapper.readValue(root.get("data").toString(), PREFIXLIST.class);
201 prefixListDao.delete(prefixList);
202 response.setCharacterEncoding("UTF-8");
203 response.setContentType("application / json");
204 request.setCharacterEncoding("UTF-8");
206 PrintWriter out = response.getWriter();
208 String responseString = mapper.writeValueAsString(this.prefixListDao.getPREFIXLISTData());
209 JSONObject j = new JSONObject("{prefixListDictionaryDatas: " + responseString + "}");
210 out.write(j.toString());
215 System.out.println(e);
216 response.setCharacterEncoding("UTF-8");
217 request.setCharacterEncoding("UTF-8");
218 PrintWriter out = response.getWriter();
219 out.write(e.getMessage());
224 @RequestMapping(value={"/fw_dictionary/validate_prefixList.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
225 public ModelAndView validatePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
227 ObjectMapper mapper = new ObjectMapper();
228 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
229 JsonNode root = mapper.readTree(request.getReader());
230 PREFIXLIST prefixList = (PREFIXLIST)mapper.readValue(root.get("prefixListDictionaryData").toString(), PREFIXLIST.class);
231 String responseValidation = "success";
233 CIDR.newCIDR(prefixList.getPrefixListValue());
234 }catch(UnknownHostException e){
235 responseValidation = "error";
236 //AdminNotification.warn("IP not according to CIDR notation");
238 response.setCharacterEncoding("UTF-8");
239 response.setContentType("application / json");
240 request.setCharacterEncoding("UTF-8");
242 PrintWriter out = response.getWriter();
243 JSONObject j = new JSONObject("{result: " + responseValidation + "}");
244 out.write(j.toString());
249 response.setCharacterEncoding("UTF-8");
250 request.setCharacterEncoding("UTF-8");
251 PrintWriter out = response.getWriter();
252 out.write(e.getMessage());
257 @RequestMapping(value={"/get_PortListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
258 public void getPortListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
260 Map<String, Object> model = new HashMap<String, Object>();
261 ObjectMapper mapper = new ObjectMapper();
262 model.put("portListDictionaryDatas", mapper.writeValueAsString(portListDao.getPortListData()));
263 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
264 JSONObject j = new JSONObject(msg);
265 response.getWriter().write(j.toString());
272 @RequestMapping(value={"/fw_dictionary/save_portName.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
273 public ModelAndView savePortListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
275 boolean duplicateflag = false;
276 ObjectMapper mapper = new ObjectMapper();
277 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
278 JsonNode root = mapper.readTree(request.getReader());
279 PortList portList = (PortList)mapper.readValue(root.get("portListDictionaryData").toString(), PortList.class);
280 if(portList.getId() == 0){
281 CheckDictionaryDuplicateEntries entry = new CheckDictionaryDuplicateEntries();
282 List<Object> duplicateData = entry.CheckDuplicateEntry(portList.getPortName(), "portName", PortList.class);
283 if(!duplicateData.isEmpty()){
284 duplicateflag = true;
286 portListDao.Save(portList);
289 portListDao.update(portList);
291 response.setCharacterEncoding("UTF-8");
292 response.setContentType("application / json");
293 request.setCharacterEncoding("UTF-8");
295 PrintWriter out = response.getWriter();
296 String responseString = "";
298 responseString = "Duplicate";
300 responseString = mapper.writeValueAsString(this.portListDao.getPortListData());
302 JSONObject j = new JSONObject("{portListDictionaryDatas: " + responseString + "}");
304 out.write(j.toString());
309 response.setCharacterEncoding("UTF-8");
310 request.setCharacterEncoding("UTF-8");
311 PrintWriter out = response.getWriter();
312 out.write(e.getMessage());
317 @RequestMapping(value={"/fw_dictionary/remove_PortList.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
318 public ModelAndView removePortListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
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("data").toString(), PortList.class);
324 portListDao.delete(portList);
325 response.setCharacterEncoding("UTF-8");
326 response.setContentType("application / json");
327 request.setCharacterEncoding("UTF-8");
329 PrintWriter out = response.getWriter();
331 String responseString = mapper.writeValueAsString(this.portListDao.getPortListData());
332 JSONObject j = new JSONObject("{portListDictionaryDatas: " + responseString + "}");
333 out.write(j.toString());
338 System.out.println(e);
339 response.setCharacterEncoding("UTF-8");
340 request.setCharacterEncoding("UTF-8");
341 PrintWriter out = response.getWriter();
342 out.write(e.getMessage());
347 @RequestMapping(value={"/get_ProtocolListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
348 public void getProtocolListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
350 Map<String, Object> model = new HashMap<String, Object>();
351 ObjectMapper mapper = new ObjectMapper();
352 model.put("protocolListDictionaryDatas", mapper.writeValueAsString(protocolListDao.getProtocolListData()));
353 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
354 JSONObject j = new JSONObject(msg);
355 response.getWriter().write(j.toString());
362 @RequestMapping(value={"/get_ProtocolListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
363 public void getProtocolListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
365 Map<String, Object> model = new HashMap<String, Object>();
366 ObjectMapper mapper = new ObjectMapper();
367 model.put("protocolListDictionaryDatas", mapper.writeValueAsString(protocolListDao.getProtocolListDataByName()));
368 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
369 JSONObject j = new JSONObject(msg);
370 response.getWriter().write(j.toString());
377 @RequestMapping(value={"/fw_dictionary/save_protocolList.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
378 public ModelAndView saveProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
380 boolean duplicateflag = false;
381 ObjectMapper mapper = new ObjectMapper();
382 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
383 JsonNode root = mapper.readTree(request.getReader());
384 ProtocolList protocolList = (ProtocolList)mapper.readValue(root.get("protocolListDictionaryData").toString(), ProtocolList.class);
385 if(protocolList.getId() == 0){
386 CheckDictionaryDuplicateEntries entry = new CheckDictionaryDuplicateEntries();
387 List<Object> duplicateData = entry.CheckDuplicateEntry(protocolList.getProtocolName(), "protocolName", ProtocolList.class);
388 if(!duplicateData.isEmpty()){
389 duplicateflag = true;
391 protocolListDao.Save(protocolList);
394 protocolListDao.update(protocolList);
396 response.setCharacterEncoding("UTF-8");
397 response.setContentType("application / json");
398 request.setCharacterEncoding("UTF-8");
400 PrintWriter out = response.getWriter();
401 String responseString = "";
403 responseString = "Duplicate";
405 responseString = mapper.writeValueAsString(this.protocolListDao.getProtocolListData());
407 JSONObject j = new JSONObject("{protocolListDictionaryDatas: " + responseString + "}");
409 out.write(j.toString());
414 response.setCharacterEncoding("UTF-8");
415 request.setCharacterEncoding("UTF-8");
416 PrintWriter out = response.getWriter();
417 out.write(e.getMessage());
422 @RequestMapping(value={"/fw_dictionary/remove_protocol.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
423 public ModelAndView removeProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
425 ObjectMapper mapper = new ObjectMapper();
426 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
427 JsonNode root = mapper.readTree(request.getReader());
428 ProtocolList protocolList = (ProtocolList)mapper.readValue(root.get("data").toString(), ProtocolList.class);
429 protocolListDao.delete(protocolList);
430 response.setCharacterEncoding("UTF-8");
431 response.setContentType("application / json");
432 request.setCharacterEncoding("UTF-8");
434 PrintWriter out = response.getWriter();
436 String responseString = mapper.writeValueAsString(this.protocolListDao.getProtocolListData());
437 JSONObject j = new JSONObject("{protocolListDictionaryDatas: " + responseString + "}");
438 out.write(j.toString());
443 System.out.println(e);
444 response.setCharacterEncoding("UTF-8");
445 request.setCharacterEncoding("UTF-8");
446 PrintWriter out = response.getWriter();
447 out.write(e.getMessage());
452 @RequestMapping(value={"/get_AddressGroupDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
453 public void getAddressGroupDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
455 Map<String, Object> model = new HashMap<String, Object>();
456 ObjectMapper mapper = new ObjectMapper();
457 model.put("addressGroupDictionaryDatas", mapper.writeValueAsString(addressGroupDao.getAddressGroupDataByName()));
458 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
459 JSONObject j = new JSONObject(msg);
460 response.getWriter().write(j.toString());
467 @RequestMapping(value={"/get_AddressGroupData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
468 public void getAddressGroupDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
470 Map<String, Object> model = new HashMap<String, Object>();
471 ObjectMapper mapper = new ObjectMapper();
472 model.put("addressGroupDictionaryDatas", mapper.writeValueAsString(addressGroupDao.getAddressGroupData()));
473 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
474 JSONObject j = new JSONObject(msg);
475 response.getWriter().write(j.toString());
482 @RequestMapping(value={"/fw_dictionary/save_addressGroup.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
483 public ModelAndView saveAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
485 boolean duplicateflag = false;
486 ObjectMapper mapper = new ObjectMapper();
487 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
488 JsonNode root = mapper.readTree(request.getReader());
489 AddressGroup addressGroup = (AddressGroup)mapper.readValue(root.get("addressGroupDictionaryData").toString(), AddressGroup.class);
490 GridData gridData = (GridData)mapper.readValue(root.get("addressGroupDictionaryData").toString(), GridData.class);
491 if(!addressGroup.getGroupName().startsWith("Group_")){
492 String groupName = "Group_"+addressGroup.getGroupName();
493 addressGroup.setGroupName(groupName);
495 String userValue = "";
497 if(gridData.getAttributes().size() > 0){
498 for(Object attribute : gridData.getAttributes()){
499 if(attribute instanceof LinkedHashMap<?, ?>){
500 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
502 userValue = userValue + ",";
504 userValue = userValue + key ;
509 addressGroup.setServiceList(userValue);
510 if(addressGroup.getId() == 0){
511 CheckDictionaryDuplicateEntries entry = new CheckDictionaryDuplicateEntries();
512 List<Object> duplicateData = entry.CheckDuplicateEntry(addressGroup.getGroupName(), "name", AddressGroup.class);
513 if(!duplicateData.isEmpty()){
514 duplicateflag = true;
516 addressGroupDao.Save(addressGroup);
519 addressGroupDao.update(addressGroup);
521 response.setCharacterEncoding("UTF-8");
522 response.setContentType("application / json");
523 request.setCharacterEncoding("UTF-8");
525 PrintWriter out = response.getWriter();
526 String responseString = "";
528 responseString = "Duplicate";
530 responseString = mapper.writeValueAsString(this.addressGroupDao.getAddressGroupData());
532 JSONObject j = new JSONObject("{addressGroupDictionaryDatas: " + responseString + "}");
534 out.write(j.toString());
539 response.setCharacterEncoding("UTF-8");
540 request.setCharacterEncoding("UTF-8");
541 PrintWriter out = response.getWriter();
542 out.write(e.getMessage());
547 @RequestMapping(value={"/fw_dictionary/remove_AddressGroup.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
548 public ModelAndView removeAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
550 ObjectMapper mapper = new ObjectMapper();
551 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
552 JsonNode root = mapper.readTree(request.getReader());
553 AddressGroup addressGroup = (AddressGroup)mapper.readValue(root.get("data").toString(), AddressGroup.class);
554 addressGroupDao.delete(addressGroup);
555 response.setCharacterEncoding("UTF-8");
556 response.setContentType("application / json");
557 request.setCharacterEncoding("UTF-8");
559 PrintWriter out = response.getWriter();
561 String responseString = mapper.writeValueAsString(this.addressGroupDao.getAddressGroupData());
562 JSONObject j = new JSONObject("{addressGroupDictionaryDatas: " + responseString + "}");
563 out.write(j.toString());
568 System.out.println(e);
569 response.setCharacterEncoding("UTF-8");
570 request.setCharacterEncoding("UTF-8");
571 PrintWriter out = response.getWriter();
572 out.write(e.getMessage());
577 @RequestMapping(value={"/get_ActionListDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
578 public void getActionListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
580 Map<String, Object> model = new HashMap<String, Object>();
581 ObjectMapper mapper = new ObjectMapper();
582 model.put("actionListDictionaryDatas", mapper.writeValueAsString(actionListDao.getActionListDataByName()));
583 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
584 JSONObject j = new JSONObject(msg);
585 response.getWriter().write(j.toString());
592 @RequestMapping(value={"/get_ActionListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
593 public void getActionListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
595 Map<String, Object> model = new HashMap<String, Object>();
596 ObjectMapper mapper = new ObjectMapper();
597 model.put("actionListDictionaryDatas", mapper.writeValueAsString(actionListDao.getActionListData()));
598 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
599 JSONObject j = new JSONObject(msg);
600 response.getWriter().write(j.toString());
607 @RequestMapping(value={"/fw_dictionary/save_ActionList.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
608 public ModelAndView saveActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
610 boolean duplicateflag = false;
611 ObjectMapper mapper = new ObjectMapper();
612 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
613 JsonNode root = mapper.readTree(request.getReader());
614 ActionList actionList = (ActionList)mapper.readValue(root.get("actionListDictionaryData").toString(), ActionList.class);
615 if(actionList.getId() == 0){
616 CheckDictionaryDuplicateEntries entry = new CheckDictionaryDuplicateEntries();
617 List<Object> duplicateData = entry.CheckDuplicateEntry(actionList.getActionName(), "actionName", ActionList.class);
618 if(!duplicateData.isEmpty()){
619 duplicateflag = true;
621 actionListDao.Save(actionList);
624 actionListDao.update(actionList);
626 response.setCharacterEncoding("UTF-8");
627 response.setContentType("application / json");
628 request.setCharacterEncoding("UTF-8");
630 PrintWriter out = response.getWriter();
631 String responseString = "";
633 responseString = "Duplicate";
635 responseString = mapper.writeValueAsString(this.actionListDao.getActionListData());
637 JSONObject j = new JSONObject("{actionListDictionaryDatas: " + responseString + "}");
639 out.write(j.toString());
644 response.setCharacterEncoding("UTF-8");
645 request.setCharacterEncoding("UTF-8");
646 PrintWriter out = response.getWriter();
647 out.write(e.getMessage());
652 @RequestMapping(value={"/fw_dictionary/remove_ActionList.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
653 public ModelAndView removeActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
655 ObjectMapper mapper = new ObjectMapper();
656 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
657 JsonNode root = mapper.readTree(request.getReader());
658 ActionList actionList = (ActionList)mapper.readValue(root.get("data").toString(), ActionList.class);
659 actionListDao.delete(actionList);
660 response.setCharacterEncoding("UTF-8");
661 response.setContentType("application / json");
662 request.setCharacterEncoding("UTF-8");
664 PrintWriter out = response.getWriter();
666 String responseString = mapper.writeValueAsString(this.actionListDao.getActionListData());
667 JSONObject j = new JSONObject("{actionListDictionaryDatas: " + responseString + "}");
668 out.write(j.toString());
673 System.out.println(e);
674 response.setCharacterEncoding("UTF-8");
675 request.setCharacterEncoding("UTF-8");
676 PrintWriter out = response.getWriter();
677 out.write(e.getMessage());
682 @RequestMapping(value={"/get_ServiceGroupData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
683 public void getServiceGroupDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
685 Map<String, Object> model = new HashMap<String, Object>();
686 ObjectMapper mapper = new ObjectMapper();
687 model.put("serviceGroupDictionaryDatas", mapper.writeValueAsString(serviceGroupDao.getGroupServiceListData()));
688 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
689 JSONObject j = new JSONObject(msg);
690 response.getWriter().write(j.toString());
697 @RequestMapping(value={"/get_ServiceGroupDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
698 public void getServiceGroupDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
700 Map<String, Object> model = new HashMap<String, Object>();
701 ObjectMapper mapper = new ObjectMapper();
702 model.put("serviceGroupDictionaryDatas", mapper.writeValueAsString(serviceGroupDao.getGroupServiceDataByName()));
703 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
704 JSONObject j = new JSONObject(msg);
705 response.getWriter().write(j.toString());
712 @RequestMapping(value={"/fw_dictionary/save_serviceGroup.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
713 public ModelAndView saveServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
715 boolean duplicateflag = false;
716 ObjectMapper mapper = new ObjectMapper();
717 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
718 JsonNode root = mapper.readTree(request.getReader());
719 GroupServiceList groupServiceList = (GroupServiceList)mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GroupServiceList.class);
720 GridData gridData = (GridData)mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GridData.class);
721 if(!groupServiceList.getGroupName().startsWith("Group_")){
722 String groupName = "Group_"+groupServiceList.getGroupName();
723 groupServiceList.setGroupName(groupName);
725 String userValue = "";
727 if(gridData.getAttributes().size() > 0){
728 for(Object attribute : gridData.getAttributes()){
729 if(attribute instanceof LinkedHashMap<?, ?>){
730 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
732 userValue = userValue + ",";
734 userValue = userValue + key ;
739 groupServiceList.setServiceList(userValue);
740 if(groupServiceList.getId() == 0){
741 CheckDictionaryDuplicateEntries entry = new CheckDictionaryDuplicateEntries();
742 List<Object> duplicateData = entry.CheckDuplicateEntry(groupServiceList.getGroupName(), "name", GroupServiceList.class);
743 if(!duplicateData.isEmpty()){
744 duplicateflag = true;
746 serviceGroupDao.Save(groupServiceList);
749 serviceGroupDao.update(groupServiceList);
751 response.setCharacterEncoding("UTF-8");
752 response.setContentType("application / json");
753 request.setCharacterEncoding("UTF-8");
755 PrintWriter out = response.getWriter();
756 String responseString = "";
758 responseString = "Duplicate";
760 responseString = mapper.writeValueAsString(this.serviceGroupDao.getGroupServiceListData());
762 JSONObject j = new JSONObject("{serviceGroupDictionaryDatas: " + responseString + "}");
764 out.write(j.toString());
769 response.setCharacterEncoding("UTF-8");
770 request.setCharacterEncoding("UTF-8");
771 PrintWriter out = response.getWriter();
772 out.write(e.getMessage());
777 @RequestMapping(value={"/fw_dictionary/remove_serviceGroup.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
778 public ModelAndView removeServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
780 ObjectMapper mapper = new ObjectMapper();
781 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
782 JsonNode root = mapper.readTree(request.getReader());
783 GroupServiceList groupServiceList = (GroupServiceList)mapper.readValue(root.get("data").toString(), GroupServiceList.class);
784 serviceGroupDao.delete(groupServiceList);
785 response.setCharacterEncoding("UTF-8");
786 response.setContentType("application / json");
787 request.setCharacterEncoding("UTF-8");
789 PrintWriter out = response.getWriter();
791 String responseString = mapper.writeValueAsString(this.serviceGroupDao.getGroupServiceListData());
792 JSONObject j = new JSONObject("{serviceGroupDictionaryDatas: " + responseString + "}");
793 out.write(j.toString());
798 System.out.println(e);
799 response.setCharacterEncoding("UTF-8");
800 request.setCharacterEncoding("UTF-8");
801 PrintWriter out = response.getWriter();
802 out.write(e.getMessage());
807 @RequestMapping(value={"/get_SecurityZoneDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
808 public void getSecurityZoneDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
810 Map<String, Object> model = new HashMap<String, Object>();
811 ObjectMapper mapper = new ObjectMapper();
812 model.put("securityZoneDictionaryDatas", mapper.writeValueAsString(securityZoneDao.getSecurityZoneDataByName()));
813 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
814 JSONObject j = new JSONObject(msg);
815 response.getWriter().write(j.toString());
822 @RequestMapping(value={"/get_SecurityZoneData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
823 public void getSecurityZoneDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
825 Map<String, Object> model = new HashMap<String, Object>();
826 ObjectMapper mapper = new ObjectMapper();
827 model.put("securityZoneDictionaryDatas", mapper.writeValueAsString(securityZoneDao.getSecurityZoneData()));
828 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
829 JSONObject j = new JSONObject(msg);
830 response.getWriter().write(j.toString());
837 @RequestMapping(value={"/fw_dictionary/save_securityZone.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
838 public ModelAndView saveSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
840 boolean duplicateflag = false;
841 ObjectMapper mapper = new ObjectMapper();
842 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
843 JsonNode root = mapper.readTree(request.getReader());
844 SecurityZone securityZone = (SecurityZone)mapper.readValue(root.get("securityZoneDictionaryData").toString(), SecurityZone.class);
845 if(securityZone.getId() == 0){
846 CheckDictionaryDuplicateEntries entry = new CheckDictionaryDuplicateEntries();
847 List<Object> duplicateData = entry.CheckDuplicateEntry(securityZone.getZoneName(), "zoneName", SecurityZone.class);
848 if(!duplicateData.isEmpty()){
849 duplicateflag = true;
851 securityZoneDao.Save(securityZone);
854 securityZoneDao.update(securityZone);
856 response.setCharacterEncoding("UTF-8");
857 response.setContentType("application / json");
858 request.setCharacterEncoding("UTF-8");
860 PrintWriter out = response.getWriter();
861 String responseString = "";
863 responseString = "Duplicate";
865 responseString = mapper.writeValueAsString(this.securityZoneDao.getSecurityZoneData());
867 JSONObject j = new JSONObject("{securityZoneDictionaryDatas: " + responseString + "}");
869 out.write(j.toString());
874 response.setCharacterEncoding("UTF-8");
875 request.setCharacterEncoding("UTF-8");
876 PrintWriter out = response.getWriter();
877 out.write(e.getMessage());
882 @RequestMapping(value={"/fw_dictionary/remove_securityZone.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
883 public ModelAndView removeSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
885 ObjectMapper mapper = new ObjectMapper();
886 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
887 JsonNode root = mapper.readTree(request.getReader());
888 SecurityZone securityZone = (SecurityZone)mapper.readValue(root.get("data").toString(), SecurityZone.class);
889 securityZoneDao.delete(securityZone);
890 response.setCharacterEncoding("UTF-8");
891 response.setContentType("application / json");
892 request.setCharacterEncoding("UTF-8");
894 PrintWriter out = response.getWriter();
896 String responseString = mapper.writeValueAsString(this.securityZoneDao.getSecurityZoneData());
897 JSONObject j = new JSONObject("{securityZoneDictionaryDatas: " + responseString + "}");
898 out.write(j.toString());
903 System.out.println(e);
904 response.setCharacterEncoding("UTF-8");
905 request.setCharacterEncoding("UTF-8");
906 PrintWriter out = response.getWriter();
907 out.write(e.getMessage());
913 @RequestMapping(value={"/get_ServiceListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
914 public void getServiceListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
916 Map<String, Object> model = new HashMap<String, Object>();
917 ObjectMapper mapper = new ObjectMapper();
918 model.put("serviceListDictionaryDatas", mapper.writeValueAsString(serviceListDao.getServiceListData()));
919 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
920 JSONObject j = new JSONObject(msg);
921 response.getWriter().write(j.toString());
928 @RequestMapping(value={"/get_ServiceListDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
929 public void getServiceListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
931 Map<String, Object> model = new HashMap<String, Object>();
932 ObjectMapper mapper = new ObjectMapper();
933 model.put("serviceListDictionaryDatas", mapper.writeValueAsString(serviceListDao.getServiceListDataByName()));
934 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
935 JSONObject j = new JSONObject(msg);
936 response.getWriter().write(j.toString());
943 @RequestMapping(value={"/fw_dictionary/save_serviceList.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
944 public ModelAndView saveServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
946 boolean duplicateflag = false;
947 ObjectMapper mapper = new ObjectMapper();
948 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
949 JsonNode root = mapper.readTree(request.getReader());
950 ServiceList serviceList = (ServiceList)mapper.readValue(root.get("serviceListDictionaryData").toString(), ServiceList.class);
951 GridData serviceListGridData = (GridData)mapper.readValue(root.get("serviceListDictionaryData").toString(), GridData.class);
952 String tcpValue = "";
954 if(serviceListGridData.getTransportProtocols().size() > 0){
955 for(Object attribute : serviceListGridData.getTransportProtocols()){
956 if(attribute instanceof LinkedHashMap<?, ?>){
957 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
959 tcpValue = tcpValue + ",";
961 tcpValue = tcpValue + key ;
966 serviceList.setServiceTransProtocol(tcpValue);
967 String appValue = "";
969 if(serviceListGridData.getAppProtocols().size() > 0){
970 for(Object attribute : serviceListGridData.getAppProtocols()){
971 if(attribute instanceof LinkedHashMap<?, ?>){
972 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
974 appValue = appValue + ",";
976 appValue = appValue + key ;
981 serviceList.setServiceAppProtocol(appValue);
982 serviceList.setServiceType("SERVICE");
983 if(serviceList.getId() == 0){
984 CheckDictionaryDuplicateEntries entry = new CheckDictionaryDuplicateEntries();
985 List<Object> duplicateData = entry.CheckDuplicateEntry(serviceList.getServiceName(), "serviceName", ServiceList.class);
986 if(!duplicateData.isEmpty()){
987 duplicateflag = true;
989 serviceListDao.Save(serviceList);
993 serviceListDao.update(serviceList);
995 response.setCharacterEncoding("UTF-8");
996 response.setContentType("application / json");
997 request.setCharacterEncoding("UTF-8");
999 PrintWriter out = response.getWriter();
1000 String responseString = "";
1002 responseString = "Duplicate";
1004 responseString = mapper.writeValueAsString(this.serviceListDao.getServiceListData());
1006 JSONObject j = new JSONObject("{serviceListDictionaryDatas: " + responseString + "}");
1008 out.write(j.toString());
1012 catch (Exception e){
1013 response.setCharacterEncoding("UTF-8");
1014 request.setCharacterEncoding("UTF-8");
1015 PrintWriter out = response.getWriter();
1016 out.write(e.getMessage());
1021 @RequestMapping(value={"/fw_dictionary/remove_serviceList.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1022 public ModelAndView removeServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
1024 ObjectMapper mapper = new ObjectMapper();
1025 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1026 JsonNode root = mapper.readTree(request.getReader());
1027 ServiceList serviceList = (ServiceList)mapper.readValue(root.get("data").toString(), ServiceList.class);
1028 serviceListDao.delete(serviceList);
1029 response.setCharacterEncoding("UTF-8");
1030 response.setContentType("application / json");
1031 request.setCharacterEncoding("UTF-8");
1033 PrintWriter out = response.getWriter();
1035 String responseString = mapper.writeValueAsString(this.serviceListDao.getServiceListData());
1036 JSONObject j = new JSONObject("{serviceListDictionaryDatas: " + responseString + "}");
1037 out.write(j.toString());
1041 catch (Exception e){
1042 System.out.println(e);
1043 response.setCharacterEncoding("UTF-8");
1044 request.setCharacterEncoding("UTF-8");
1045 PrintWriter out = response.getWriter();
1046 out.write(e.getMessage());
1051 @RequestMapping(value={"/get_ZoneData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1052 public void getZoneDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
1054 Map<String, Object> model = new HashMap<String, Object>();
1055 ObjectMapper mapper = new ObjectMapper();
1056 model.put("zoneDictionaryDatas", mapper.writeValueAsString(zoneDao.getZoneData()));
1057 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1058 JSONObject j = new JSONObject(msg);
1059 response.getWriter().write(j.toString());
1061 catch (Exception e){
1062 e.printStackTrace();
1066 @RequestMapping(value={"/get_ZoneDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1067 public void getZoneDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
1069 Map<String, Object> model = new HashMap<String, Object>();
1070 ObjectMapper mapper = new ObjectMapper();
1071 model.put("zoneDictionaryDatas", mapper.writeValueAsString(zoneDao.getZoneDataByName()));
1072 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1073 JSONObject j = new JSONObject(msg);
1074 response.getWriter().write(j.toString());
1076 catch (Exception e){
1077 e.printStackTrace();
1081 @RequestMapping(value={"/fw_dictionary/save_zoneName.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1082 public ModelAndView saveZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
1084 boolean duplicateflag = false;
1085 ObjectMapper mapper = new ObjectMapper();
1086 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1087 JsonNode root = mapper.readTree(request.getReader());
1088 Zone zone = (Zone)mapper.readValue(root.get("zoneDictionaryData").toString(), Zone.class);
1089 if(zone.getId() == 0){
1090 CheckDictionaryDuplicateEntries entry = new CheckDictionaryDuplicateEntries();
1091 List<Object> duplicateData = entry.CheckDuplicateEntry(zone.getZoneName(), "zoneName", Zone.class);
1092 if(!duplicateData.isEmpty()){
1093 duplicateflag = true;
1098 zoneDao.update(zone);
1100 response.setCharacterEncoding("UTF-8");
1101 response.setContentType("application / json");
1102 request.setCharacterEncoding("UTF-8");
1104 PrintWriter out = response.getWriter();
1105 String responseString = "";
1107 responseString = "Duplicate";
1109 responseString = mapper.writeValueAsString(this.zoneDao.getZoneData());
1111 JSONObject j = new JSONObject("{zoneDictionaryDatas: " + responseString + "}");
1113 out.write(j.toString());
1117 catch (Exception e){
1118 response.setCharacterEncoding("UTF-8");
1119 request.setCharacterEncoding("UTF-8");
1120 PrintWriter out = response.getWriter();
1121 out.write(e.getMessage());
1126 @RequestMapping(value={"/fw_dictionary/remove_zone.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1127 public ModelAndView removeZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
1129 ObjectMapper mapper = new ObjectMapper();
1130 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1131 JsonNode root = mapper.readTree(request.getReader());
1132 Zone zone = (Zone)mapper.readValue(root.get("data").toString(), Zone.class);
1133 zoneDao.delete(zone);
1134 response.setCharacterEncoding("UTF-8");
1135 response.setContentType("application / json");
1136 request.setCharacterEncoding("UTF-8");
1138 PrintWriter out = response.getWriter();
1140 String responseString = mapper.writeValueAsString(this.zoneDao.getZoneData());
1141 JSONObject j = new JSONObject("{zoneDictionaryDatas: " + responseString + "}");
1142 out.write(j.toString());
1146 catch (Exception e){
1147 System.out.println(e);
1148 response.setCharacterEncoding("UTF-8");
1149 request.setCharacterEncoding("UTF-8");
1150 PrintWriter out = response.getWriter();
1151 out.write(e.getMessage());
1156 @RequestMapping(value={"/get_TermListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1157 public void getTermListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
1159 Map<String, Object> model = new HashMap<String, Object>();
1160 ObjectMapper mapper = new ObjectMapper();
1161 model.put("termListDictionaryDatas", mapper.writeValueAsString(termListDao.getTermListDataByName()));
1162 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1163 JSONObject j = new JSONObject(msg);
1164 response.getWriter().write(j.toString());
1166 catch (Exception e){
1167 e.printStackTrace();
1171 @RequestMapping(value={"/get_TermListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1172 public void getTermListDictionaryEntityData(HttpServletRequest request, HttpServletResponse response){
1174 Map<String, Object> model = new HashMap<String, Object>();
1175 ObjectMapper mapper = new ObjectMapper();
1176 model.put("termListDictionaryDatas", mapper.writeValueAsString(termListDao.getTermListData()));
1177 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1178 JSONObject j = new JSONObject(msg);
1179 response.getWriter().write(j.toString());
1181 catch (Exception e){
1182 e.printStackTrace();
1186 @RequestMapping(value={"/fw_dictionary/save_termList.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1187 public ModelAndView saveTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
1189 boolean duplicateflag = false;
1190 ObjectMapper mapper = new ObjectMapper();
1191 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1192 JsonNode root = mapper.readTree(request.getReader());
1193 TermList termList = (TermList)mapper.readValue(root.get("termListDictionaryData").toString(), TermList.class);
1194 TermListData termListDatas = (TermListData)mapper.readValue(root.get("termListDictionaryData").toString(), TermListData.class);
1195 String userId = root.get("loginId").textValue();
1196 String fromZoneValue = "";
1198 if(termListDatas.getFromZoneDatas().size() > 0){
1199 for(Object fromZone : termListDatas.getFromZoneDatas()){
1200 if(fromZone instanceof LinkedHashMap<?, ?>){
1201 String key = ((LinkedHashMap<?, ?>) fromZone).get("option").toString();
1203 fromZoneValue = fromZoneValue + ",";
1205 fromZoneValue = fromZoneValue + key ;
1210 termList.setFromZones(fromZoneValue);
1212 String toZoneValue = "";
1213 int toZonecounter = 0;
1214 if(termListDatas.getToZoneDatas().size() > 0){
1215 for(Object toZone : termListDatas.getToZoneDatas()){
1216 if(toZone instanceof LinkedHashMap<?, ?>){
1217 String key = ((LinkedHashMap<?, ?>) toZone).get("option").toString();
1218 if(toZonecounter>0){
1219 toZoneValue = toZoneValue + ",";
1221 toZoneValue = toZoneValue + key ;
1226 termList.setToZones(toZoneValue);
1228 String srcListValues = "";
1229 int srcListcounter = 0;
1230 if(termListDatas.getSourceListDatas().size() > 0){
1231 for(Object srcList : termListDatas.getSourceListDatas()){
1232 if(srcList instanceof LinkedHashMap<?, ?>){
1233 String key = ((LinkedHashMap<?, ?>) srcList).get("option").toString();
1234 if(srcListcounter>0){
1235 srcListValues = srcListValues + ",";
1237 srcListValues = srcListValues + key ;
1242 termList.setSrcIPList(srcListValues);
1244 String desListValues = "";
1245 int destListcounter = 0;
1246 if(termListDatas.getDestinationListDatas().size() > 0){
1247 for(Object desList : termListDatas.getDestinationListDatas()){
1248 if(desList instanceof LinkedHashMap<?, ?>){
1249 String key = ((LinkedHashMap<?, ?>) desList).get("option").toString();
1250 if(destListcounter>0){
1251 desListValues = desListValues + ",";
1253 desListValues = desListValues + key ;
1258 termList.setDestIPList(desListValues);
1260 String srcSerValue = "";
1261 int srcSercounter = 0;
1262 if(termListDatas.getSourceServiceDatas().size() > 0){
1263 for(Object srcSrc : termListDatas.getSourceServiceDatas()){
1264 if(srcSrc instanceof LinkedHashMap<?, ?>){
1265 String key = ((LinkedHashMap<?, ?>) srcSrc).get("option").toString();
1266 if(srcSercounter>0){
1267 srcSerValue = srcSerValue + ",";
1269 srcSerValue = srcSerValue + key ;
1274 termList.setSrcPortList(srcSerValue);
1276 String desSrcValue = "";
1277 int desSrccounter = 0;
1278 if(termListDatas.getDestinationServiceDatas().size() > 0){
1279 for(Object desSrc : termListDatas.getDestinationServiceDatas()){
1280 if(desSrc instanceof LinkedHashMap<?, ?>){
1281 String key = ((LinkedHashMap<?, ?>) desSrc).get("option").toString();
1282 if(desSrccounter>0){
1283 desSrcValue = desSrcValue + ",";
1285 desSrcValue = desSrcValue + key ;
1290 termList.setDestPortList(desSrcValue);
1292 String actionValue = "";
1293 int actioncounter = 0;
1294 if(termListDatas.getActionListDatas().size() > 0){
1295 for(Object actionList : termListDatas.getActionListDatas()){
1296 if(actionList instanceof LinkedHashMap<?, ?>){
1297 String key = ((LinkedHashMap<?, ?>) actionList).get("option").toString();
1298 if(actioncounter>0){
1299 actionValue = actionValue + ",";
1301 actionValue = actionValue + key ;
1306 termList.setAction(actionValue);
1308 if(termList.getId() == 0){
1309 CheckDictionaryDuplicateEntries entry = new CheckDictionaryDuplicateEntries();
1310 List<Object> duplicateData = entry.CheckDuplicateEntry(termList.getTermName(), "termName", TermList.class);
1311 if(!duplicateData.isEmpty()){
1312 duplicateflag = true;
1314 termList.setUserCreatedBy(this.getUserInfo(userId));
1315 termList.setUserModifiedBy(this.getUserInfo(userId));
1316 termListDao.Save(termList);
1319 termList.setUserModifiedBy(this.getUserInfo(userId));
1320 termListDao.update(termList);
1322 response.setCharacterEncoding("UTF-8");
1323 response.setContentType("application / json");
1324 request.setCharacterEncoding("UTF-8");
1326 PrintWriter out = response.getWriter();
1328 String responseString = "";
1330 responseString = "Duplicate";
1332 responseString = mapper.writeValueAsString(this.termListDao.getTermListData());
1334 JSONObject j = new JSONObject("{termListDictionaryDatas: " + responseString + "}");
1336 out.write(j.toString());
1340 catch (Exception e){
1341 response.setCharacterEncoding("UTF-8");
1342 request.setCharacterEncoding("UTF-8");
1343 PrintWriter out = response.getWriter();
1344 out.write(e.getMessage());
1349 @RequestMapping(value={"/fw_dictionary/remove_termList.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1350 public ModelAndView removeTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception {
1352 ObjectMapper mapper = new ObjectMapper();
1353 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1354 JsonNode root = mapper.readTree(request.getReader());
1355 TermList termList = (TermList)mapper.readValue(root.get("data").toString(), TermList.class);
1356 termListDao.delete(termList);
1357 response.setCharacterEncoding("UTF-8");
1358 response.setContentType("application / json");
1359 request.setCharacterEncoding("UTF-8");
1361 PrintWriter out = response.getWriter();
1363 String responseString = mapper.writeValueAsString(this.termListDao.getTermListData());
1364 JSONObject j = new JSONObject("{termListDictionaryDatas: " + responseString + "}");
1365 out.write(j.toString());
1369 catch (Exception e){
1370 System.out.println(e);
1371 response.setCharacterEncoding("UTF-8");
1372 request.setCharacterEncoding("UTF-8");
1373 PrintWriter out = response.getWriter();
1374 out.write(e.getMessage());
1378 //ParentList Dictionary Data
1379 @RequestMapping(value={"/get_FWDictionaryListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1380 public void getFWDictListDictionaryEntityDataByName(HttpServletRequest request, HttpServletResponse response){
1382 Map<String, Object> model = new HashMap<String, Object>();
1383 ObjectMapper mapper = new ObjectMapper();
1384 model.put("fwDictListDictionaryDatas", mapper.writeValueAsString(fwDictionaryListDao.getFWDictionaryListDataByName()));
1385 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1386 JSONObject j = new JSONObject(msg);
1387 response.getWriter().write(j.toString());
1389 catch (Exception e){
1390 e.printStackTrace();
1394 @RequestMapping(value={"/get_FWDictionaryListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1395 public void getFWDictionaryListEntityData(HttpServletRequest request, HttpServletResponse response){
1397 Map<String, Object> model = new HashMap<String, Object>();
1398 ObjectMapper mapper = new ObjectMapper();
1399 model.put("fwDictListDictionaryDatas", mapper.writeValueAsString(fwDictionaryListDao.getFWDictionaryListData()));
1400 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1401 JSONObject j = new JSONObject(msg);
1402 response.getWriter().write(j.toString());
1404 catch (Exception e){
1405 e.printStackTrace();
1409 @RequestMapping(value={"/fw_dictionary/save_FWDictionaryList.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1410 public ModelAndView saveFWDictionaryList(HttpServletRequest request, HttpServletResponse response) throws Exception{
1412 boolean duplicateflag = false;
1413 ObjectMapper mapper = new ObjectMapper();
1414 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1415 JsonNode root = mapper.readTree(request.getReader());
1416 FirewallDictionaryList fwDictList = (FirewallDictionaryList)mapper.readValue(root.get("fwDictListDictionaryData").toString(), FirewallDictionaryList.class);
1417 GridData gridData = (GridData)mapper.readValue(root.get("fwDictListDictionaryData").toString(), GridData.class);
1418 String userSLValue = "";
1420 if(gridData.getAttributes().size() > 0){
1421 for(Object attribute : gridData.getAttributes()){
1422 if(attribute instanceof LinkedHashMap<?, ?>){
1423 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
1425 userSLValue = userSLValue + ",";
1427 userSLValue = userSLValue + key ;
1432 fwDictList.setServiceList(userSLValue);
1433 String userALValue = "";
1435 if(gridData.getAlAttributes().size() > 0){
1436 for(Object attribute : gridData.getAlAttributes()){
1437 if(attribute instanceof LinkedHashMap<?, ?>){
1438 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
1440 userALValue = userALValue + ",";
1442 userALValue = userALValue + key ;
1447 fwDictList.setAddressList(userALValue);
1448 if(fwDictList.getId() == 0){
1449 CheckDictionaryDuplicateEntries entry = new CheckDictionaryDuplicateEntries();
1450 List<Object> duplicateData = entry.CheckDuplicateEntry(fwDictList.getParentItemName(), "parentItemName", FirewallDictionaryList.class);
1451 if(!duplicateData.isEmpty()){
1452 duplicateflag = true;
1454 fwDictionaryListDao.Save(fwDictList);
1457 fwDictionaryListDao.update(fwDictList);
1459 response.setCharacterEncoding("UTF-8");
1460 response.setContentType("application / json");
1461 request.setCharacterEncoding("UTF-8");
1463 PrintWriter out = response.getWriter();
1464 String responseString = "";
1466 responseString = "Duplicate";
1468 responseString = mapper.writeValueAsString(this.fwDictionaryListDao.getFWDictionaryListData());
1470 JSONObject j = new JSONObject("{fwDictListDictionaryDatas: " + responseString + "}");
1472 out.write(j.toString());
1476 catch (Exception e){
1477 response.setCharacterEncoding("UTF-8");
1478 request.setCharacterEncoding("UTF-8");
1479 PrintWriter out = response.getWriter();
1480 out.write(e.getMessage());
1485 @RequestMapping(value={"/fw_dictionary/remove_FWDictionaryList.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1486 public ModelAndView removeFWDictionaryListy(HttpServletRequest request, HttpServletResponse response) throws Exception {
1488 ObjectMapper mapper = new ObjectMapper();
1489 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1490 JsonNode root = mapper.readTree(request.getReader());
1491 FirewallDictionaryList fwDictList = (FirewallDictionaryList)mapper.readValue(root.get("data").toString(), FirewallDictionaryList.class);
1492 fwDictionaryListDao.delete(fwDictList);
1493 response.setCharacterEncoding("UTF-8");
1494 response.setContentType("application / json");
1495 request.setCharacterEncoding("UTF-8");
1497 PrintWriter out = response.getWriter();
1499 String responseString = mapper.writeValueAsString(this.fwDictionaryListDao.getFWDictionaryListData());
1500 JSONObject j = new JSONObject("{fwDictListDictionaryDatas: " + responseString + "}");
1501 out.write(j.toString());
1505 catch (Exception e){
1506 System.out.println(e);
1507 response.setCharacterEncoding("UTF-8");
1508 request.setCharacterEncoding("UTF-8");
1509 PrintWriter out = response.getWriter();
1510 out.write(e.getMessage());
1517 private ArrayList<Object> attributes;
1519 public ArrayList<Object> getAttributes() {
1523 public void setAttributes(ArrayList<Object> attributes) {
1524 this.attributes = attributes;
1529 private ArrayList<Object> fromZoneDatas;
1530 private ArrayList<Object> toZoneDatas;
1531 private ArrayList<Object> sourceListDatas;
1532 private ArrayList<Object> destinationListDatas;
1533 private ArrayList<Object> sourceServiceDatas;
1534 private ArrayList<Object> destinationServiceDatas;
1535 private ArrayList<Object> actionListDatas;
1536 public ArrayList<Object> getFromZoneDatas() {
1537 return fromZoneDatas;
1539 public void setFromZoneDatas(ArrayList<Object> fromZoneDatas) {
1540 this.fromZoneDatas = fromZoneDatas;
1542 public ArrayList<Object> getToZoneDatas() {
1545 public void setToZoneDatas(ArrayList<Object> toZoneDatas) {
1546 this.toZoneDatas = toZoneDatas;
1548 public ArrayList<Object> getSourceListDatas() {
1549 return sourceListDatas;
1551 public void setSourceListDatas(ArrayList<Object> sourceListDatas) {
1552 this.sourceListDatas = sourceListDatas;
1554 public ArrayList<Object> getDestinationListDatas() {
1555 return destinationListDatas;
1557 public void setDestinationListDatas(ArrayList<Object> destinationListDatas) {
1558 this.destinationListDatas = destinationListDatas;
1560 public ArrayList<Object> getSourceServiceDatas() {
1561 return sourceServiceDatas;
1563 public void setSourceServiceDatas(ArrayList<Object> sourceServiceDatas) {
1564 this.sourceServiceDatas = sourceServiceDatas;
1566 public ArrayList<Object> getDestinationServiceDatas() {
1567 return destinationServiceDatas;
1569 public void setDestinationServiceDatas(ArrayList<Object> destinationServiceDatas) {
1570 this.destinationServiceDatas = destinationServiceDatas;
1572 public ArrayList<Object> getActionListDatas() {
1573 return actionListDatas;
1575 public void setActionListDatas(ArrayList<Object> actionListDatas) {
1576 this.actionListDatas = actionListDatas;