2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.pap.xacml.rest.controller;
23 import java.io.IOException;
24 import java.io.PrintWriter;
25 import java.net.UnknownHostException;
26 import java.util.ArrayList;
27 import java.util.Date;
28 import java.util.HashMap;
29 import java.util.LinkedHashMap;
30 import java.util.List;
33 import javax.servlet.http.HttpServletRequest;
34 import javax.servlet.http.HttpServletResponse;
36 import org.jboss.netty.handler.ipfilter.CIDR;
37 import org.json.JSONObject;
38 import org.onap.policy.common.logging.flexlogger.FlexLogger;
39 import org.onap.policy.common.logging.flexlogger.Logger;
40 import org.onap.policy.pap.xacml.rest.adapters.GridData;
41 import org.onap.policy.pap.xacml.rest.util.JsonMessage;
42 import org.onap.policy.rest.dao.CommonClassDao;
43 import org.onap.policy.rest.jpa.ActionList;
44 import org.onap.policy.rest.jpa.AddressGroup;
45 import org.onap.policy.rest.jpa.FWTag;
46 import org.onap.policy.rest.jpa.FWTagPicker;
47 import org.onap.policy.rest.jpa.FirewallDictionaryList;
48 import org.onap.policy.rest.jpa.GroupServiceList;
49 import org.onap.policy.rest.jpa.PrefixList;
50 import org.onap.policy.rest.jpa.PortList;
51 import org.onap.policy.rest.jpa.ProtocolList;
52 import org.onap.policy.rest.jpa.SecurityZone;
53 import org.onap.policy.rest.jpa.ServiceList;
54 import org.onap.policy.rest.jpa.TermList;
55 import org.onap.policy.rest.jpa.UserInfo;
56 import org.onap.policy.rest.jpa.Zone;
57 import org.onap.policy.utils.PolicyUtils;
58 import org.onap.policy.xacml.api.XACMLErrorConstants;
59 import org.springframework.beans.factory.annotation.Autowired;
60 import org.springframework.http.MediaType;
61 import org.springframework.stereotype.Controller;
62 import org.springframework.web.bind.annotation.RequestMapping;
63 import org.springframework.web.servlet.ModelAndView;
65 import com.fasterxml.jackson.databind.DeserializationFeature;
66 import com.fasterxml.jackson.databind.JsonNode;
67 import com.fasterxml.jackson.databind.ObjectMapper;
71 public class FirewallDictionaryController {
73 private static final Logger LOGGER = FlexLogger.getLogger(FirewallDictionaryController.class);
75 private static CommonClassDao commonClassDao;
76 private static String prefixListName = "prefixListName";
77 private static String successMapKey = "successMapKey";
78 private static String successMessage = "success";
79 private static String operation = "operation";
80 private static String getDictionary = "getDictionary";
81 private static String errorMsg = "error";
82 private static String dictionaryDBQuery = "dictionaryDBQuery";
83 private static String apiflag = "apiflag";
84 private static String dictionaryFields ="dictionaryFields";
85 private static String update = "update";
86 private static String duplicateResponseString = "Duplicate";
87 private static String successMsg = "Success";
88 private static String utf8 = "UTF-8";
89 private static String applicationJsonContentType = "application / json";
90 private static String existsResponseString = "Exists";
91 private static String protocolName = "protocolName";
92 private static String groupNameStart = "Group_";
93 private static String option = "option";
94 private static String zoneName = "zoneName";
95 private static String serviceName = "serviceName";
96 private static String termName = "termName";
97 private static String userid = "userid";
98 private static String tagPickerName = "tagPickerName";
99 private static String fwTagPickerDictionaryData = "fwTagPickerDictionaryData";
100 private static String fwTagDictionaryDatas = "fwTagDictionaryDatas";
104 public FirewallDictionaryController(CommonClassDao commonClassDao){
105 FirewallDictionaryController.commonClassDao = commonClassDao;
108 public static void setCommonClassDao(CommonClassDao clDao){
109 commonClassDao = clDao;
113 * This is an empty constructor
115 public FirewallDictionaryController(){}
117 public UserInfo getUserInfo(String loginId){
118 return (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", loginId);
122 @RequestMapping(value={"/get_PrefixListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
123 public void getPrefixListDictionaryEntityDataByName(HttpServletResponse response){
125 Map<String, Object> model = new HashMap<>();
126 ObjectMapper mapper = new ObjectMapper();
127 model.put("prefixListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(PrefixList.class, prefixListName)));
128 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
129 JSONObject j = new JSONObject(msg);
130 response.getWriter().write(j.toString());
133 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
137 @RequestMapping(value={"/get_PrefixListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
138 public void getPrefixListDictionaryEntityData(HttpServletResponse response){
140 Map<String, Object> model = new HashMap<>();
141 ObjectMapper mapper = new ObjectMapper();
142 model.put("prefixListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(PrefixList.class)));
143 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
144 JSONObject j = new JSONObject(msg);
145 response.addHeader(successMapKey, successMessage);
146 response.addHeader(operation, getDictionary);
147 response.getWriter().write(j.toString());
150 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW, e);
151 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
152 response.addHeader(errorMsg, dictionaryDBQuery);
156 @RequestMapping(value={"/fw_dictionary/save_prefixList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
157 public ModelAndView savePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
159 boolean duplicateflag = false;
160 boolean isFakeUpdate = false;
161 boolean fromAPI = false;
162 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
165 ObjectMapper mapper = new ObjectMapper();
166 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
167 JsonNode root = mapper.readTree(request.getReader());
168 PrefixList prefixList;
170 prefixList = (PrefixList)mapper.readValue(root.get(dictionaryFields).toString(), PrefixList.class);
172 //check if update operation or create, get id for data to be updated and update attributeData
173 if ((update).equals(request.getParameter(operation))) {
174 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(prefixList.getPrefixListName(), prefixListName, PrefixList.class);
175 PrefixList data = (PrefixList) duplicateData.get(0);
176 int id = data.getId();
181 prefixList.setId(id);
185 prefixList = (PrefixList)mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
187 if(prefixList.getId() == 0){
188 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(prefixList.getPrefixListName(), prefixListName, PrefixList.class);
189 if(!duplicateData.isEmpty()){
190 duplicateflag = true;
192 commonClassDao.save(prefixList);
196 commonClassDao.update(prefixList);
199 String responseString = "";
201 responseString = duplicateResponseString;
203 responseString = mapper.writeValueAsString(commonClassDao.getData(PrefixList.class));
207 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
209 responseString = existsResponseString;
211 responseString = successMsg;
214 ModelAndView result = new ModelAndView();
215 result.setViewName(responseString);
218 response.setCharacterEncoding(utf8);
219 response.setContentType(applicationJsonContentType);
220 request.setCharacterEncoding(utf8);
222 PrintWriter out = response.getWriter();
223 JSONObject j = new JSONObject("{prefixListDictionaryDatas: " + responseString + "}");
224 out.write(j.toString());
227 }catch (Exception e){
228 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW, e);
229 response.setCharacterEncoding(utf8);
230 request.setCharacterEncoding(utf8);
231 PrintWriter out = response.getWriter();
232 out.write(PolicyUtils.CATCH_EXCEPTION);
237 @RequestMapping(value={"/fw_dictionary/remove_PrefixList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
238 public ModelAndView removePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
240 ObjectMapper mapper = new ObjectMapper();
241 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
242 JsonNode root = mapper.readTree(request.getReader());
243 PrefixList prefixList = (PrefixList)mapper.readValue(root.get("data").toString(), PrefixList.class);
244 commonClassDao.delete(prefixList);
245 response.setCharacterEncoding(utf8);
246 response.setContentType(applicationJsonContentType);
247 request.setCharacterEncoding(utf8);
249 PrintWriter out = response.getWriter();
250 String responseString = mapper.writeValueAsString(commonClassDao.getData(PrefixList.class));
251 JSONObject j = new JSONObject("{prefixListDictionaryDatas: " + responseString + "}");
252 out.write(j.toString());
256 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
257 response.setCharacterEncoding(utf8);
258 request.setCharacterEncoding(utf8);
259 PrintWriter out = response.getWriter();
260 out.write(PolicyUtils.CATCH_EXCEPTION);
265 @RequestMapping(value={"/fw_dictionary/validate_prefixList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
266 public ModelAndView validatePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
268 ObjectMapper mapper = new ObjectMapper();
269 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
270 JsonNode root = mapper.readTree(request.getReader());
271 PrefixList prefixList = (PrefixList)mapper.readValue(root.get("prefixListDictionaryData").toString(), PrefixList.class);
272 String responseValidation = successMessage;
274 CIDR.newCIDR(prefixList.getPrefixListValue());
275 }catch(UnknownHostException e){
277 responseValidation = errorMsg;
279 response.setCharacterEncoding(utf8);
280 response.setContentType(applicationJsonContentType);
281 request.setCharacterEncoding(utf8);
283 PrintWriter out = response.getWriter();
284 JSONObject j = new JSONObject("{result: " + responseValidation + "}");
285 out.write(j.toString());
289 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
290 response.setCharacterEncoding(utf8);
291 request.setCharacterEncoding(utf8);
292 PrintWriter out = response.getWriter();
293 out.write(PolicyUtils.CATCH_EXCEPTION);
298 @RequestMapping(value={"/get_PortListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
299 public void getPortListDictionaryEntityData(HttpServletResponse response){
301 Map<String, Object> model = new HashMap<>();
302 ObjectMapper mapper = new ObjectMapper();
303 model.put("portListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(PortList.class)));
304 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
305 JSONObject j = new JSONObject(msg);
306 response.addHeader(successMapKey, successMessage);
307 response.addHeader(operation, getDictionary);
308 response.getWriter().write(j.toString());
311 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
312 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
313 response.addHeader(errorMsg, dictionaryDBQuery);
317 @RequestMapping(value={"/fw_dictionary/save_portName"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
318 public ModelAndView savePortListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
320 boolean duplicateflag = false;
321 ObjectMapper mapper = new ObjectMapper();
322 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
323 JsonNode root = mapper.readTree(request.getReader());
324 PortList portList = (PortList)mapper.readValue(root.get("portListDictionaryData").toString(), PortList.class);
325 if(portList.getId() == 0){
326 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(portList.getPortName(), "portName", PortList.class);
327 if(!duplicateData.isEmpty()){
328 duplicateflag = true;
330 commonClassDao.save(portList);
333 commonClassDao.update(portList);
335 response.setCharacterEncoding(utf8);
336 response.setContentType(applicationJsonContentType);
337 request.setCharacterEncoding(utf8);
339 PrintWriter out = response.getWriter();
340 String responseString = "";
342 responseString = duplicateResponseString;
344 responseString = mapper.writeValueAsString(commonClassDao.getData(PortList.class));
346 JSONObject j = new JSONObject("{portListDictionaryDatas: " + responseString + "}");
348 out.write(j.toString());
353 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
354 response.setCharacterEncoding(utf8);
355 request.setCharacterEncoding(utf8);
356 PrintWriter out = response.getWriter();
357 out.write(PolicyUtils.CATCH_EXCEPTION);
362 @RequestMapping(value={"/fw_dictionary/remove_PortList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
363 public ModelAndView removePortListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
365 ObjectMapper mapper = new ObjectMapper();
366 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
367 JsonNode root = mapper.readTree(request.getReader());
368 PortList portList = (PortList)mapper.readValue(root.get("data").toString(), PortList.class);
369 commonClassDao.delete(portList);
370 response.setCharacterEncoding(utf8);
371 response.setContentType(applicationJsonContentType);
372 request.setCharacterEncoding(utf8);
374 PrintWriter out = response.getWriter();
375 String responseString = mapper.writeValueAsString(commonClassDao.getData(PortList.class));
376 JSONObject j = new JSONObject("{portListDictionaryDatas: " + responseString + "}");
377 out.write(j.toString());
381 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
382 response.setCharacterEncoding(utf8);
383 request.setCharacterEncoding(utf8);
384 PrintWriter out = response.getWriter();
385 out.write(PolicyUtils.CATCH_EXCEPTION);
390 @RequestMapping(value={"/get_ProtocolListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
391 public void getProtocolListDictionaryEntityData(HttpServletResponse response){
393 Map<String, Object> model = new HashMap<>();
394 ObjectMapper mapper = new ObjectMapper();
395 model.put("protocolListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(ProtocolList.class)));
396 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
397 JSONObject j = new JSONObject(msg);
398 response.addHeader(successMapKey, successMessage);
399 response.addHeader(operation, getDictionary);
400 response.getWriter().write(j.toString());
403 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
404 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
405 response.addHeader(errorMsg, dictionaryDBQuery);
409 @RequestMapping(value={"/get_ProtocolListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
410 public void getProtocolListDictionaryEntityDataByName(HttpServletResponse response){
412 Map<String, Object> model = new HashMap<>();
413 ObjectMapper mapper = new ObjectMapper();
414 model.put("protocolListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(ProtocolList.class, protocolName)));
415 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
416 JSONObject j = new JSONObject(msg);
417 response.getWriter().write(j.toString());
420 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
424 @RequestMapping(value={"/fw_dictionary/save_protocolList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
425 public ModelAndView saveProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
427 boolean duplicateflag = false;
428 boolean isFakeUpdate = false;
429 boolean fromAPI = false;
430 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
433 ObjectMapper mapper = new ObjectMapper();
434 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
435 JsonNode root = mapper.readTree(request.getReader());
436 ProtocolList protocolList;
438 protocolList = (ProtocolList)mapper.readValue(root.get(dictionaryFields).toString(), ProtocolList.class);
440 //check if update operation or create, get id for data to be updated and update attributeData
441 if ((update).equals(request.getParameter(operation))) {
442 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(protocolList.getProtocolName(), protocolName, ProtocolList.class);
443 ProtocolList data = (ProtocolList) duplicateData.get(0);
444 int id = data.getId();
447 protocolList.setId(1);
449 protocolList.setId(id);
453 protocolList = (ProtocolList)mapper.readValue(root.get("protocolListDictionaryData").toString(), ProtocolList.class);
455 if(protocolList.getId() == 0){
456 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(protocolList.getProtocolName(), protocolName, ProtocolList.class);
457 if(!duplicateData.isEmpty()){
458 duplicateflag = true;
460 commonClassDao.save(protocolList);
464 commonClassDao.update(protocolList);
467 String responseString = "";
469 responseString = duplicateResponseString;
471 responseString = mapper.writeValueAsString(commonClassDao.getData(ProtocolList.class));
475 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
477 responseString = existsResponseString;
479 responseString = successMsg;
482 ModelAndView result = new ModelAndView();
483 result.setViewName(responseString);
486 response.setCharacterEncoding(utf8);
487 response.setContentType(applicationJsonContentType);
488 request.setCharacterEncoding(utf8);
490 PrintWriter out = response.getWriter();
491 JSONObject j = new JSONObject("{protocolListDictionaryDatas: " + responseString + "}");
492 out.write(j.toString());
495 }catch (Exception e){
496 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
497 response.setCharacterEncoding(utf8);
498 request.setCharacterEncoding(utf8);
499 PrintWriter out = response.getWriter();
500 out.write(PolicyUtils.CATCH_EXCEPTION);
505 @RequestMapping(value={"/fw_dictionary/remove_protocol"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
506 public ModelAndView removeProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
508 ObjectMapper mapper = new ObjectMapper();
509 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
510 JsonNode root = mapper.readTree(request.getReader());
511 ProtocolList protocolList = (ProtocolList)mapper.readValue(root.get("data").toString(), ProtocolList.class);
512 commonClassDao.delete(protocolList);
513 response.setCharacterEncoding(utf8);
514 response.setContentType(applicationJsonContentType);
515 request.setCharacterEncoding(utf8);
517 PrintWriter out = response.getWriter();
519 String responseString = mapper.writeValueAsString(commonClassDao.getData(ProtocolList.class));
520 JSONObject j = new JSONObject("{protocolListDictionaryDatas: " + responseString + "}");
521 out.write(j.toString());
525 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
526 response.setCharacterEncoding(utf8);
527 request.setCharacterEncoding(utf8);
528 PrintWriter out = response.getWriter();
529 out.write(PolicyUtils.CATCH_EXCEPTION);
534 @RequestMapping(value={"/get_AddressGroupDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
535 public void getAddressGroupDictionaryEntityDataByName(HttpServletResponse response){
537 Map<String, Object> model = new HashMap<>();
538 ObjectMapper mapper = new ObjectMapper();
539 model.put("addressGroupDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(AddressGroup.class, "name")));
540 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
541 JSONObject j = new JSONObject(msg);
542 response.getWriter().write(j.toString());
545 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
549 @RequestMapping(value={"/get_AddressGroupData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
550 public void getAddressGroupDictionaryEntityData(HttpServletResponse response){
552 Map<String, Object> model = new HashMap<>();
553 ObjectMapper mapper = new ObjectMapper();
554 model.put("addressGroupDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(AddressGroup.class)));
555 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
556 JSONObject j = new JSONObject(msg);
557 response.addHeader(successMapKey, successMessage);
558 response.addHeader(operation, getDictionary);
559 response.getWriter().write(j.toString());
562 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
563 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
564 response.addHeader(errorMsg, dictionaryDBQuery);
568 @RequestMapping(value={"/fw_dictionary/save_addressGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
569 public ModelAndView saveAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
571 boolean duplicateflag = false;
572 boolean isFakeUpdate = false;
573 boolean fromAPI = false;
574 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
577 ObjectMapper mapper = new ObjectMapper();
578 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
579 JsonNode root = mapper.readTree(request.getReader());
580 AddressGroup addressGroup;
583 addressGroup = (AddressGroup)mapper.readValue(root.get(dictionaryFields).toString(), AddressGroup.class);
584 gridData = (GridData)mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
586 if(!addressGroup.getGroupName().startsWith(groupNameStart)){
587 String groupName = groupNameStart+addressGroup.getGroupName();
588 addressGroup.setGroupName(groupName);
591 //check if update operation or create, get id for data to be updated and update attributeData
592 if ((update).equals(request.getParameter(operation))) {
593 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(addressGroup.getGroupName(), "name", AddressGroup.class);
594 AddressGroup data = (AddressGroup) duplicateData.get(0);
595 int id = data.getId();
598 addressGroup.setId(1);
600 addressGroup.setId(id);
604 addressGroup = (AddressGroup)mapper.readValue(root.get("addressGroupDictionaryData").toString(), AddressGroup.class);
605 gridData = (GridData)mapper.readValue(root.get("addressGroupDictionaryData").toString(), GridData.class);
606 if(!addressGroup.getGroupName().startsWith(groupNameStart)){
607 String groupName = groupNameStart+addressGroup.getGroupName();
608 addressGroup.setGroupName(groupName);
611 String userValue = "";
613 if(!gridData.getAttributes().isEmpty()){
614 for(Object attribute : gridData.getAttributes()){
615 if(attribute instanceof LinkedHashMap<?, ?>){
616 String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
618 userValue = userValue + ",";
620 userValue = userValue + key ;
625 addressGroup.setServiceList(userValue);
626 if(addressGroup.getId() == 0){
627 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(addressGroup.getGroupName(), "name", AddressGroup.class);
628 if(!duplicateData.isEmpty()){
629 duplicateflag = true;
631 commonClassDao.save(addressGroup);
635 commonClassDao.update(addressGroup);
638 String responseString = "";
640 responseString = duplicateResponseString;
642 responseString = mapper.writeValueAsString(commonClassDao.getData(AddressGroup.class));
645 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
647 responseString = existsResponseString;
649 responseString = successMsg;
652 ModelAndView result = new ModelAndView();
653 result.setViewName(responseString);
656 response.setCharacterEncoding(utf8);
657 response.setContentType(applicationJsonContentType);
658 request.setCharacterEncoding(utf8);
660 PrintWriter out = response.getWriter();
661 JSONObject j = new JSONObject("{addressGroupDictionaryDatas: " + responseString + "}");
662 out.write(j.toString());
665 }catch (Exception e){
666 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
667 response.setCharacterEncoding(utf8);
668 request.setCharacterEncoding(utf8);
669 PrintWriter out = response.getWriter();
670 out.write(PolicyUtils.CATCH_EXCEPTION);
675 @RequestMapping(value={"/fw_dictionary/remove_AddressGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
676 public ModelAndView removeAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
678 ObjectMapper mapper = new ObjectMapper();
679 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
680 JsonNode root = mapper.readTree(request.getReader());
681 AddressGroup addressGroup = (AddressGroup)mapper.readValue(root.get("data").toString(), AddressGroup.class);
682 commonClassDao.delete(addressGroup);
683 response.setCharacterEncoding(utf8);
684 response.setContentType(applicationJsonContentType);
685 request.setCharacterEncoding(utf8);
687 PrintWriter out = response.getWriter();
689 String responseString = mapper.writeValueAsString(commonClassDao.getData(AddressGroup.class));
690 JSONObject j = new JSONObject("{addressGroupDictionaryDatas: " + responseString + "}");
691 out.write(j.toString());
695 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
696 response.setCharacterEncoding(utf8);
697 request.setCharacterEncoding(utf8);
698 PrintWriter out = response.getWriter();
699 out.write(PolicyUtils.CATCH_EXCEPTION);
704 @RequestMapping(value={"/get_ActionListDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
705 public void getActionListDictionaryEntityDataByName(HttpServletResponse response){
707 Map<String, Object> model = new HashMap<>();
708 ObjectMapper mapper = new ObjectMapper();
709 List<Object> list = commonClassDao.getData(ActionList.class);
710 List<String> dictList = new ArrayList<>();
711 for(int i = 0; i < list.size(); i++){
712 ActionList dict = (ActionList) list.get(i);
713 dictList.add(dict.getActionName());
715 model.put("actionListDictionaryDatas", mapper.writeValueAsString(dictList));
716 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
717 JSONObject j = new JSONObject(msg);
718 response.getWriter().write(j.toString());
721 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
725 @RequestMapping(value={"/get_ActionListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
726 public void getActionListDictionaryEntityData(HttpServletResponse response){
728 Map<String, Object> model = new HashMap<>();
729 ObjectMapper mapper = new ObjectMapper();
730 model.put("actionListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(ActionList.class)));
731 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
732 JSONObject j = new JSONObject(msg);
733 response.addHeader(successMapKey, successMessage);
734 response.addHeader(operation, getDictionary);
735 response.getWriter().write(j.toString());
738 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
739 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
740 response.addHeader(errorMsg, dictionaryDBQuery);
744 @RequestMapping(value={"/fw_dictionary/save_ActionList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
745 public ModelAndView saveActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
747 boolean duplicateflag = false;
748 boolean isFakeUpdate = false;
749 boolean fromAPI = false;
750 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
753 ObjectMapper mapper = new ObjectMapper();
754 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
755 JsonNode root = mapper.readTree(request.getReader());
756 ActionList actionList;
758 actionList = (ActionList)mapper.readValue(root.get(dictionaryFields).toString(), ActionList.class);
760 //check if update operation or create, get id for data to be updated and update attributeData
761 if ((update).equals(request.getParameter(operation))) {
762 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(actionList.getActionName(), "actionName", ActionList.class);
763 ActionList data = (ActionList) duplicateData.get(0);
764 int id = data.getId();
769 actionList.setId(id);
773 actionList = (ActionList)mapper.readValue(root.get("actionListDictionaryData").toString(), ActionList.class);
775 if(actionList.getId() == 0){
776 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(actionList.getActionName(), "actionName", ActionList.class);
777 if(!duplicateData.isEmpty()){
778 duplicateflag = true;
780 commonClassDao.save(actionList);
784 commonClassDao.update(actionList);
787 String responseString = "";
789 responseString = duplicateResponseString;
791 responseString = mapper.writeValueAsString(commonClassDao.getData(ActionList.class));
795 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
797 responseString = existsResponseString;
799 responseString = successMsg;
802 ModelAndView result = new ModelAndView();
803 result.setViewName(responseString);
806 response.setCharacterEncoding(utf8);
807 response.setContentType(applicationJsonContentType);
808 request.setCharacterEncoding(utf8);
810 PrintWriter out = response.getWriter();
811 JSONObject j = new JSONObject("{actionListDictionaryDatas: " + responseString + "}");
812 out.write(j.toString());
815 }catch (Exception e){
816 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
817 response.setCharacterEncoding(utf8);
818 request.setCharacterEncoding(utf8);
819 PrintWriter out = response.getWriter();
820 out.write(PolicyUtils.CATCH_EXCEPTION);
825 @RequestMapping(value={"/fw_dictionary/remove_ActionList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
826 public ModelAndView removeActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
828 ObjectMapper mapper = new ObjectMapper();
829 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
830 JsonNode root = mapper.readTree(request.getReader());
831 ActionList actionList = (ActionList)mapper.readValue(root.get("data").toString(), ActionList.class);
832 commonClassDao.delete(actionList);
833 response.setCharacterEncoding(utf8);
834 response.setContentType(applicationJsonContentType);
835 request.setCharacterEncoding(utf8);
837 PrintWriter out = response.getWriter();
838 String responseString = mapper.writeValueAsString(commonClassDao.getData(ActionList.class));
839 JSONObject j = new JSONObject("{actionListDictionaryDatas: " + responseString + "}");
840 out.write(j.toString());
844 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
845 response.setCharacterEncoding(utf8);
846 request.setCharacterEncoding(utf8);
847 PrintWriter out = response.getWriter();
848 out.write(PolicyUtils.CATCH_EXCEPTION);
853 @RequestMapping(value={"/get_ServiceGroupData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
854 public void getServiceGroupDictionaryEntityData(HttpServletResponse response){
856 Map<String, Object> model = new HashMap<>();
857 ObjectMapper mapper = new ObjectMapper();
858 model.put("serviceGroupDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(GroupServiceList.class)));
859 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
860 JSONObject j = new JSONObject(msg);
861 response.addHeader(successMapKey, successMessage);
862 response.addHeader(operation, getDictionary);
863 response.getWriter().write(j.toString());
866 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
867 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
868 response.addHeader(errorMsg, dictionaryDBQuery);
872 @RequestMapping(value={"/get_ServiceGroupDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
873 public void getServiceGroupDictionaryEntityDataByName(HttpServletResponse response){
875 Map<String, Object> model = new HashMap<>();
876 ObjectMapper mapper = new ObjectMapper();
877 model.put("serviceGroupDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(GroupServiceList.class, "name")));
878 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
879 JSONObject j = new JSONObject(msg);
880 response.getWriter().write(j.toString());
883 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
887 @RequestMapping(value={"/fw_dictionary/save_serviceGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
888 public ModelAndView saveServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
890 boolean duplicateflag = false;
891 boolean isFakeUpdate = false;
892 boolean fromAPI = false;
893 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
896 ObjectMapper mapper = new ObjectMapper();
897 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
898 JsonNode root = mapper.readTree(request.getReader());
899 GroupServiceList groupServiceList;
902 groupServiceList = (GroupServiceList)mapper.readValue(root.get(dictionaryFields).toString(), GroupServiceList.class);
903 gridData = (GridData)mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
905 if(!groupServiceList.getGroupName().startsWith(groupNameStart)){
906 String groupName = groupNameStart+groupServiceList.getGroupName();
907 groupServiceList.setGroupName(groupName);
909 //check if update operation or create, get id for data to be updated and update attributeData
910 if ((update).equals(request.getParameter(operation))) {
911 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(groupServiceList.getGroupName(), "name", GroupServiceList.class);
912 GroupServiceList data = (GroupServiceList) duplicateData.get(0);
913 int id = data.getId();
917 groupServiceList.setId(1);
919 groupServiceList.setId(id);
923 groupServiceList = (GroupServiceList)mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GroupServiceList.class);
924 gridData = (GridData)mapper.readValue(root.get("serviceGroupDictionaryData").toString(), GridData.class);
926 if(!groupServiceList.getGroupName().startsWith(groupNameStart)){
927 String groupName = groupNameStart+groupServiceList.getGroupName();
928 groupServiceList.setGroupName(groupName);
930 String userValue = "";
932 if(!gridData.getAttributes().isEmpty()){
933 for(Object attribute : gridData.getAttributes()){
934 if(attribute instanceof LinkedHashMap<?, ?>){
935 String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
937 userValue = userValue + ",";
939 userValue = userValue + key ;
944 groupServiceList.setServiceList(userValue);
945 if(groupServiceList.getId() == 0){
946 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(groupServiceList.getGroupName(), "name", GroupServiceList.class);
947 if(!duplicateData.isEmpty()){
948 duplicateflag = true;
950 commonClassDao.save(groupServiceList);
954 commonClassDao.update(groupServiceList);
957 String responseString = "";
959 responseString = duplicateResponseString;
961 responseString = mapper.writeValueAsString(commonClassDao.getData(GroupServiceList.class));
965 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
967 responseString = existsResponseString;
969 responseString = successMsg;
972 ModelAndView result = new ModelAndView();
973 result.setViewName(responseString);
976 response.setCharacterEncoding(utf8);
977 response.setContentType(applicationJsonContentType);
978 request.setCharacterEncoding(utf8);
980 PrintWriter out = response.getWriter();
981 JSONObject j = new JSONObject("{serviceGroupDictionaryDatas: " + responseString + "}");
982 out.write(j.toString());
985 }catch (Exception e){
986 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
987 response.setCharacterEncoding(utf8);
988 request.setCharacterEncoding(utf8);
989 PrintWriter out = response.getWriter();
990 out.write(PolicyUtils.CATCH_EXCEPTION);
995 @RequestMapping(value={"/fw_dictionary/remove_serviceGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
996 public ModelAndView removeServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
998 ObjectMapper mapper = new ObjectMapper();
999 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1000 JsonNode root = mapper.readTree(request.getReader());
1001 GroupServiceList groupServiceList = (GroupServiceList)mapper.readValue(root.get("data").toString(), GroupServiceList.class);
1002 commonClassDao.delete(groupServiceList);
1003 response.setCharacterEncoding(utf8);
1004 response.setContentType(applicationJsonContentType);
1005 request.setCharacterEncoding(utf8);
1007 PrintWriter out = response.getWriter();
1009 String responseString = mapper.writeValueAsString(commonClassDao.getData(GroupServiceList.class));
1010 JSONObject j = new JSONObject("{serviceGroupDictionaryDatas: " + responseString + "}");
1011 out.write(j.toString());
1015 catch (Exception e){
1017 response.setCharacterEncoding(utf8);
1018 request.setCharacterEncoding(utf8);
1019 PrintWriter out = response.getWriter();
1020 out.write(PolicyUtils.CATCH_EXCEPTION);
1025 @RequestMapping(value={"/get_SecurityZoneDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1026 public void getSecurityZoneDictionaryEntityDataByName(HttpServletResponse response){
1028 Map<String, Object> model = new HashMap<>();
1029 ObjectMapper mapper = new ObjectMapper();
1030 model.put("securityZoneDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(SecurityZone.class, zoneName)));
1031 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1032 JSONObject j = new JSONObject(msg);
1033 response.getWriter().write(j.toString());
1035 catch (Exception e){
1036 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1040 @RequestMapping(value={"/get_SecurityZoneData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1041 public void getSecurityZoneDictionaryEntityData(HttpServletResponse response){
1043 Map<String, Object> model = new HashMap<>();
1044 ObjectMapper mapper = new ObjectMapper();
1045 model.put("securityZoneDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(SecurityZone.class)));
1046 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1047 JSONObject j = new JSONObject(msg);
1048 response.addHeader(successMapKey, successMessage);
1049 response.addHeader(operation, getDictionary);
1050 response.getWriter().write(j.toString());
1052 catch (Exception e){
1053 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1054 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
1055 response.addHeader(errorMsg, dictionaryDBQuery);
1059 @RequestMapping(value={"/fw_dictionary/save_securityZone"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1060 public ModelAndView saveSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
1062 boolean duplicateflag = false;
1063 boolean isFakeUpdate = false;
1064 boolean fromAPI = false;
1065 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
1068 ObjectMapper mapper = new ObjectMapper();
1069 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1070 JsonNode root = mapper.readTree(request.getReader());
1071 SecurityZone securityZone;
1073 securityZone = (SecurityZone)mapper.readValue(root.get(dictionaryFields).toString(), SecurityZone.class);
1075 //check if update operation or create, get id for data to be updated and update attributeData
1076 if ((update).equals(request.getParameter(operation))) {
1077 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(securityZone.getZoneName(), zoneName, SecurityZone.class);
1078 SecurityZone data = (SecurityZone) duplicateData.get(0);
1079 int id = data.getId();
1082 securityZone.setId(1);
1084 securityZone.setId(id);
1088 securityZone = (SecurityZone)mapper.readValue(root.get("securityZoneDictionaryData").toString(), SecurityZone.class);
1090 if(securityZone.getId() == 0){
1091 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(securityZone.getZoneName(), zoneName, SecurityZone.class);
1092 if(!duplicateData.isEmpty()){
1093 duplicateflag = true;
1095 commonClassDao.save(securityZone);
1099 commonClassDao.update(securityZone);
1102 String responseString = "";
1104 responseString = duplicateResponseString;
1106 responseString = mapper.writeValueAsString(commonClassDao.getData(SecurityZone.class));
1110 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
1112 responseString = existsResponseString;
1114 responseString = successMsg;
1117 ModelAndView result = new ModelAndView();
1118 result.setViewName(responseString);
1121 response.setCharacterEncoding(utf8);
1122 response.setContentType(applicationJsonContentType);
1123 request.setCharacterEncoding(utf8);
1125 PrintWriter out = response.getWriter();
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(utf8);
1134 request.setCharacterEncoding(utf8);
1135 PrintWriter out = response.getWriter();
1136 out.write(PolicyUtils.CATCH_EXCEPTION);
1141 @RequestMapping(value={"/fw_dictionary/remove_securityZone"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1142 public ModelAndView removeSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
1144 ObjectMapper mapper = new ObjectMapper();
1145 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1146 JsonNode root = mapper.readTree(request.getReader());
1147 SecurityZone securityZone = (SecurityZone)mapper.readValue(root.get("data").toString(), SecurityZone.class);
1148 commonClassDao.delete(securityZone);
1149 response.setCharacterEncoding(utf8);
1150 response.setContentType(applicationJsonContentType);
1151 request.setCharacterEncoding(utf8);
1153 PrintWriter out = response.getWriter();
1155 String responseString = mapper.writeValueAsString(commonClassDao.getData(SecurityZone.class));
1156 JSONObject j = new JSONObject("{securityZoneDictionaryDatas: " + responseString + "}");
1157 out.write(j.toString());
1161 catch (Exception e){
1162 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1163 response.setCharacterEncoding(utf8);
1164 request.setCharacterEncoding(utf8);
1165 PrintWriter out = response.getWriter();
1166 out.write(PolicyUtils.CATCH_EXCEPTION);
1172 @RequestMapping(value={"/get_ServiceListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1173 public void getServiceListDictionaryEntityData(HttpServletResponse response){
1175 Map<String, Object> model = new HashMap<>();
1176 ObjectMapper mapper = new ObjectMapper();
1177 model.put("serviceListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(ServiceList.class)));
1178 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1179 JSONObject j = new JSONObject(msg);
1180 response.addHeader(successMapKey, successMessage);
1181 response.addHeader(operation, getDictionary);
1182 response.getWriter().write(j.toString());
1184 catch (Exception e){
1185 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1186 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
1187 response.addHeader(errorMsg, dictionaryDBQuery);
1191 @RequestMapping(value={"/get_ServiceListDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1192 public void getServiceListDictionaryEntityDataByName(HttpServletResponse response){
1194 Map<String, Object> model = new HashMap<>();
1195 ObjectMapper mapper = new ObjectMapper();
1196 model.put("serviceListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(ServiceList.class, serviceName)));
1197 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1198 JSONObject j = new JSONObject(msg);
1199 response.getWriter().write(j.toString());
1201 catch (Exception e){
1202 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1206 @RequestMapping(value={"/fw_dictionary/save_serviceList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1207 public ModelAndView saveServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
1209 boolean duplicateflag = false;
1210 boolean isFakeUpdate = false;
1211 boolean fromAPI = false;
1212 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
1215 ObjectMapper mapper = new ObjectMapper();
1216 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1217 JsonNode root = mapper.readTree(request.getReader());
1218 ServiceList serviceList;
1219 GridData serviceListGridData;
1221 serviceList = (ServiceList)mapper.readValue(root.get(dictionaryFields).toString(), ServiceList.class);
1222 serviceListGridData = (GridData)mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
1224 //check if update operation or create, get id for data to be updated and update attributeData
1225 if ((update).equals(request.getParameter(operation))) {
1226 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(serviceList.getServiceName(), serviceName, ServiceList.class);
1227 ServiceList data = (ServiceList) duplicateData.get(0);
1228 int id = data.getId();
1231 serviceList.setId(1);
1233 serviceList.setId(id);
1237 serviceList = (ServiceList)mapper.readValue(root.get("serviceListDictionaryData").toString(), ServiceList.class);
1238 serviceListGridData = (GridData)mapper.readValue(root.get("serviceListDictionaryData").toString(), GridData.class);
1240 String tcpValue = "";
1242 if(!serviceListGridData.getTransportProtocols().isEmpty()){
1243 for(Object attribute : serviceListGridData.getTransportProtocols()){
1244 if(attribute instanceof LinkedHashMap<?, ?>){
1245 String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
1247 tcpValue = tcpValue + ",";
1249 tcpValue = tcpValue + key ;
1254 serviceList.setServiceTransProtocol(tcpValue);
1255 String appValue = "";
1257 if(!serviceListGridData.getAppProtocols().isEmpty()){
1258 for(Object attribute : serviceListGridData.getAppProtocols()){
1259 if(attribute instanceof LinkedHashMap<?, ?>){
1260 String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
1262 appValue = appValue + ",";
1264 appValue = appValue + key ;
1269 serviceList.setServiceAppProtocol(appValue);
1270 serviceList.setServiceType("SERVICE");
1271 if(serviceList.getId() == 0){
1272 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(serviceList.getServiceName(), serviceName, ServiceList.class);
1273 if(!duplicateData.isEmpty()){
1274 duplicateflag = true;
1276 commonClassDao.save(serviceList);
1280 commonClassDao.update(serviceList);
1284 String responseString = "";
1286 responseString = duplicateResponseString;
1288 responseString = mapper.writeValueAsString(commonClassDao.getData(ServiceList.class));
1291 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
1293 responseString = existsResponseString;
1295 responseString = successMsg;
1298 ModelAndView result = new ModelAndView();
1299 result.setViewName(responseString);
1302 response.setCharacterEncoding(utf8);
1303 response.setContentType(applicationJsonContentType);
1304 request.setCharacterEncoding(utf8);
1306 PrintWriter out = response.getWriter();
1307 JSONObject j = new JSONObject("{serviceListDictionaryDatas: " + responseString + "}");
1308 out.write(j.toString());
1311 }catch (Exception e){
1312 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1313 response.setCharacterEncoding(utf8);
1314 request.setCharacterEncoding(utf8);
1315 PrintWriter out = response.getWriter();
1316 out.write(PolicyUtils.CATCH_EXCEPTION);
1322 @RequestMapping(value={"/fw_dictionary/remove_serviceList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1323 public ModelAndView removeServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
1325 ObjectMapper mapper = new ObjectMapper();
1326 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1327 JsonNode root = mapper.readTree(request.getReader());
1328 ServiceList serviceList = (ServiceList)mapper.readValue(root.get("data").toString(), ServiceList.class);
1329 commonClassDao.delete(serviceList);
1330 response.setCharacterEncoding(utf8);
1331 response.setContentType(applicationJsonContentType);
1332 request.setCharacterEncoding(utf8);
1334 PrintWriter out = response.getWriter();
1336 String responseString = mapper.writeValueAsString(commonClassDao.getData(ServiceList.class));
1337 JSONObject j = new JSONObject("{serviceListDictionaryDatas: " + responseString + "}");
1338 out.write(j.toString());
1342 catch (Exception e){
1344 response.setCharacterEncoding(utf8);
1345 request.setCharacterEncoding(utf8);
1346 PrintWriter out = response.getWriter();
1347 out.write(PolicyUtils.CATCH_EXCEPTION);
1352 @RequestMapping(value={"/get_ZoneData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1353 public void getZoneDictionaryEntityData(HttpServletResponse response){
1355 Map<String, Object> model = new HashMap<>();
1356 ObjectMapper mapper = new ObjectMapper();
1357 model.put("zoneDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(Zone.class)));
1358 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1359 JSONObject j = new JSONObject(msg);
1360 response.addHeader(successMapKey, successMessage);
1361 response.addHeader(operation, getDictionary);
1362 response.getWriter().write(j.toString());
1364 catch (Exception e){
1365 LOGGER.error("Exception Occured"+e);
1369 @RequestMapping(value={"/get_ZoneDictionaryDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1370 public void getZoneDictionaryEntityDataByName(HttpServletResponse response){
1372 Map<String, Object> model = new HashMap<>();
1373 ObjectMapper mapper = new ObjectMapper();
1374 model.put("zoneDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(Zone.class, zoneName)));
1375 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1376 JSONObject j = new JSONObject(msg);
1377 response.getWriter().write(j.toString());
1379 catch (Exception e){
1380 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1384 @RequestMapping(value={"/fw_dictionary/save_zoneName"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1385 public ModelAndView saveZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
1387 boolean duplicateflag = false;
1388 boolean isFakeUpdate = false;
1389 boolean fromAPI = false;
1390 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
1393 ObjectMapper mapper = new ObjectMapper();
1394 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1395 JsonNode root = mapper.readTree(request.getReader());
1398 zone = (Zone)mapper.readValue(root.get(dictionaryFields).toString(), Zone.class);
1400 //check if update operation or create, get id for data to be updated and update attributeData
1401 if ((update).equals(request.getParameter(operation))) {
1402 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(zone.getZoneName(), zoneName, Zone.class);
1403 Zone data = (Zone) duplicateData.get(0);
1404 int id = data.getId();
1413 zone = (Zone)mapper.readValue(root.get("zoneDictionaryData").toString(), Zone.class);
1415 if(zone.getId() == 0){
1416 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(zone.getZoneName(), zoneName, Zone.class);
1417 if(!duplicateData.isEmpty()){
1418 duplicateflag = true;
1420 commonClassDao.save(zone);
1424 commonClassDao.update(zone);
1427 String responseString = "";
1429 responseString = duplicateResponseString;
1431 responseString = mapper.writeValueAsString(commonClassDao.getData(Zone.class));
1435 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
1437 responseString = existsResponseString;
1439 responseString = successMsg;
1442 ModelAndView result = new ModelAndView();
1443 result.setViewName(responseString);
1446 response.setCharacterEncoding(utf8);
1447 response.setContentType(applicationJsonContentType);
1448 request.setCharacterEncoding(utf8);
1450 PrintWriter out = response.getWriter();
1451 JSONObject j = new JSONObject("{zoneDictionaryDatas: " + responseString + "}");
1452 out.write(j.toString());
1455 }catch (Exception e){
1456 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1457 response.setCharacterEncoding(utf8);
1458 request.setCharacterEncoding(utf8);
1459 PrintWriter out = response.getWriter();
1460 out.write(PolicyUtils.CATCH_EXCEPTION);
1465 @RequestMapping(value={"/fw_dictionary/remove_zone"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1466 public ModelAndView removeZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
1468 ObjectMapper mapper = new ObjectMapper();
1469 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1470 JsonNode root = mapper.readTree(request.getReader());
1471 Zone zone = (Zone)mapper.readValue(root.get("data").toString(), Zone.class);
1472 commonClassDao.delete(zone);
1473 response.setCharacterEncoding(utf8);
1474 response.setContentType(applicationJsonContentType);
1475 request.setCharacterEncoding(utf8);
1477 PrintWriter out = response.getWriter();
1479 String responseString = mapper.writeValueAsString(commonClassDao.getData(Zone.class));
1480 JSONObject j = new JSONObject("{zoneDictionaryDatas: " + responseString + "}");
1481 out.write(j.toString());
1485 catch (Exception e){
1486 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1487 response.setCharacterEncoding(utf8);
1488 request.setCharacterEncoding(utf8);
1489 PrintWriter out = response.getWriter();
1490 out.write(PolicyUtils.CATCH_EXCEPTION);
1495 @RequestMapping(value={"/get_TermListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1496 public void getTermListDictionaryEntityDataByName(HttpServletResponse response){
1498 Map<String, Object> model = new HashMap<>();
1499 ObjectMapper mapper = new ObjectMapper();
1500 model.put("termListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(TermList.class, termName)));
1501 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1502 JSONObject j = new JSONObject(msg);
1503 response.getWriter().write(j.toString());
1505 catch (Exception e){
1506 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1510 @RequestMapping(value={"/get_TermListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1511 public void getTermListDictionaryEntityData(HttpServletResponse response){
1513 Map<String, Object> model = new HashMap<>();
1514 ObjectMapper mapper = new ObjectMapper();
1515 model.put("termListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(TermList.class)));
1516 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1517 JSONObject j = new JSONObject(msg);
1518 response.addHeader(successMapKey, successMessage);
1519 response.addHeader(operation, getDictionary);
1520 response.getWriter().write(j.toString());
1522 catch (Exception e){
1523 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1524 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
1525 response.addHeader(errorMsg, dictionaryDBQuery);
1529 @RequestMapping(value={"/fw_dictionary/save_termList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1530 public ModelAndView saveTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
1532 boolean duplicateflag = false;
1533 boolean isFakeUpdate = false;
1534 boolean fromAPI = false;
1535 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
1538 ObjectMapper mapper = new ObjectMapper();
1539 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1540 JsonNode root = mapper.readTree(request.getReader());
1542 TermListData termListDatas;
1543 String userId = null;
1545 termList = (TermList)mapper.readValue(root.get(dictionaryFields).toString(), TermList.class);
1546 termListDatas = (TermListData)mapper.readValue(root.get(dictionaryFields).toString(), TermListData.class);
1549 //check if update operation or create, get id for data to be updated and update attributeData
1550 if ((update).equals(request.getParameter(operation))) {
1551 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(termList.getTermName(), termName, TermList.class);
1552 TermList data = (TermList) duplicateData.get(0);
1553 int id = data.getId();
1560 termList.setUserCreatedBy(this.getUserInfo(userId));
1563 termList = (TermList)mapper.readValue(root.get("termListDictionaryData").toString(), TermList.class);
1564 termListDatas = (TermListData)mapper.readValue(root.get("termListDictionaryData").toString(), TermListData.class);
1565 userId = root.get(userid).textValue();
1567 String fromZoneValue = "";
1569 if(!termListDatas.getFromZoneDatas().isEmpty()){
1570 for(Object fromZone : termListDatas.getFromZoneDatas()){
1571 if(fromZone instanceof LinkedHashMap<?, ?>){
1572 String key = ((LinkedHashMap<?, ?>) fromZone).get(option).toString();
1574 fromZoneValue = fromZoneValue + ",";
1576 fromZoneValue = fromZoneValue + key ;
1581 termList.setFromZones(fromZoneValue);
1583 String toZoneValue = "";
1584 int toZonecounter = 0;
1585 if(!termListDatas.getToZoneDatas().isEmpty()){
1586 for(Object toZone : termListDatas.getToZoneDatas()){
1587 if(toZone instanceof LinkedHashMap<?, ?>){
1588 String key = ((LinkedHashMap<?, ?>) toZone).get(option).toString();
1589 if(toZonecounter>0){
1590 toZoneValue = toZoneValue + ",";
1592 toZoneValue = toZoneValue + key ;
1597 termList.setToZones(toZoneValue);
1599 String srcListValues = "";
1600 int srcListcounter = 0;
1601 if(!termListDatas.getSourceListDatas().isEmpty()){
1602 for(Object srcList : termListDatas.getSourceListDatas()){
1603 if(srcList instanceof LinkedHashMap<?, ?>){
1604 String key = ((LinkedHashMap<?, ?>) srcList).get(option).toString();
1605 if(srcListcounter>0){
1606 srcListValues = srcListValues + ",";
1608 srcListValues = srcListValues + key ;
1613 termList.setSrcIPList(srcListValues);
1615 String desListValues = "";
1616 int destListcounter = 0;
1617 if(!termListDatas.getDestinationListDatas().isEmpty()){
1618 for(Object desList : termListDatas.getDestinationListDatas()){
1619 if(desList instanceof LinkedHashMap<?, ?>){
1620 String key = ((LinkedHashMap<?, ?>) desList).get(option).toString();
1621 if(destListcounter>0){
1622 desListValues = desListValues + ",";
1624 desListValues = desListValues + key ;
1629 termList.setDestIPList(desListValues);
1631 String srcSerValue = "";
1632 int srcSercounter = 0;
1633 if(!termListDatas.getSourceServiceDatas().isEmpty()){
1634 for(Object srcSrc : termListDatas.getSourceServiceDatas()){
1635 if(srcSrc instanceof LinkedHashMap<?, ?>){
1636 String key = ((LinkedHashMap<?, ?>) srcSrc).get(option).toString();
1637 if(srcSercounter>0){
1638 srcSerValue = srcSerValue + ",";
1640 srcSerValue = srcSerValue + key ;
1645 termList.setSrcPortList(srcSerValue);
1647 String desSrcValue = "";
1648 int desSrccounter = 0;
1649 if(!termListDatas.getDestinationServiceDatas().isEmpty()){
1650 for(Object desSrc : termListDatas.getDestinationServiceDatas()){
1651 if(desSrc instanceof LinkedHashMap<?, ?>){
1652 String key = ((LinkedHashMap<?, ?>) desSrc).get(option).toString();
1653 if(desSrccounter>0){
1654 desSrcValue = desSrcValue + ",";
1656 desSrcValue = desSrcValue + key ;
1661 termList.setDestPortList(desSrcValue);
1663 String actionValue = "";
1664 int actioncounter = 0;
1665 if(!termListDatas.getActionListDatas().isEmpty()){
1666 for(Object actionList : termListDatas.getActionListDatas()){
1667 if(actionList instanceof LinkedHashMap<?, ?>){
1668 String key = ((LinkedHashMap<?, ?>) actionList).get(option).toString();
1669 if(actioncounter>0){
1670 actionValue = actionValue + ",";
1672 actionValue = actionValue + key ;
1677 termList.setAction(actionValue);
1679 if(termList.getId() == 0){
1680 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(termList.getTermName(), termName, TermList.class);
1681 if(!duplicateData.isEmpty()){
1682 duplicateflag = true;
1684 termList.setUserCreatedBy(this.getUserInfo(userId));
1685 termList.setUserModifiedBy(this.getUserInfo(userId));
1686 termList.setCreatedDate(new Date());
1687 commonClassDao.save(termList);
1691 termList.setUserModifiedBy(this.getUserInfo(userId));
1692 termList.setModifiedDate(new Date());
1693 commonClassDao.update(termList);
1696 String responseString = "";
1698 responseString = duplicateResponseString;
1700 responseString = mapper.writeValueAsString(commonClassDao.getData(TermList.class));
1704 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
1706 responseString = existsResponseString;
1708 responseString = successMsg;
1711 ModelAndView result = new ModelAndView();
1712 result.setViewName(responseString);
1715 response.setCharacterEncoding(utf8);
1716 response.setContentType(applicationJsonContentType);
1717 request.setCharacterEncoding(utf8);
1719 PrintWriter out = response.getWriter();
1720 JSONObject j = new JSONObject("{termListDictionaryDatas: " + responseString + "}");
1721 out.write(j.toString());
1724 }catch (Exception e){
1725 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1726 response.setCharacterEncoding(utf8);
1727 request.setCharacterEncoding(utf8);
1728 PrintWriter out = response.getWriter();
1729 out.write(PolicyUtils.CATCH_EXCEPTION);
1734 @RequestMapping(value={"/fw_dictionary/remove_termList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1735 public ModelAndView removeTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
1737 ObjectMapper mapper = new ObjectMapper();
1738 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1739 JsonNode root = mapper.readTree(request.getReader());
1740 TermList termList = (TermList)mapper.readValue(root.get("data").toString(), TermList.class);
1741 commonClassDao.delete(termList);
1742 response.setCharacterEncoding(utf8);
1743 response.setContentType(applicationJsonContentType);
1744 request.setCharacterEncoding(utf8);
1746 PrintWriter out = response.getWriter();
1748 String responseString = mapper.writeValueAsString(commonClassDao.getData(TermList.class));
1749 JSONObject j = new JSONObject("{termListDictionaryDatas: " + responseString + "}");
1750 out.write(j.toString());
1754 catch (Exception e){
1755 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1756 response.setCharacterEncoding(utf8);
1757 request.setCharacterEncoding(utf8);
1758 PrintWriter out = response.getWriter();
1759 out.write(PolicyUtils.CATCH_EXCEPTION);
1763 //ParentList Dictionary Data
1764 @RequestMapping(value={"/get_FWDictionaryListDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1765 public void getFWDictListDictionaryEntityDataByName(HttpServletResponse response){
1767 Map<String, Object> model = new HashMap<>();
1768 ObjectMapper mapper = new ObjectMapper();
1769 model.put("fwDictListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(FirewallDictionaryList.class, "parentItemName")));
1770 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1771 JSONObject j = new JSONObject(msg);
1772 response.getWriter().write(j.toString());
1774 catch (Exception e){
1775 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1779 @RequestMapping(value={"/get_FWDictionaryListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1780 public void getFWDictionaryListEntityData(HttpServletResponse response){
1782 Map<String, Object> model = new HashMap<>();
1783 ObjectMapper mapper = new ObjectMapper();
1784 model.put("fwDictListDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class)));
1785 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1786 JSONObject j = new JSONObject(msg);
1787 response.addHeader(successMapKey, successMessage);
1788 response.addHeader(operation, getDictionary);
1789 response.getWriter().write(j.toString());
1791 catch (Exception e){
1792 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1793 response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
1794 response.addHeader(errorMsg, dictionaryDBQuery);
1798 @RequestMapping(value={"/fw_dictionary/save_FWDictionaryList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1799 public ModelAndView saveFWDictionaryList(HttpServletRequest request, HttpServletResponse response) throws IOException{
1801 boolean duplicateflag = false;
1802 ObjectMapper mapper = new ObjectMapper();
1803 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1804 JsonNode root = mapper.readTree(request.getReader());
1805 FirewallDictionaryList fwDictList = (FirewallDictionaryList)mapper.readValue(root.get("fwDictListDictionaryData").toString(), FirewallDictionaryList.class);
1806 GridData gridData = (GridData)mapper.readValue(root.get("fwDictListDictionaryData").toString(), GridData.class);
1807 String userSLValue = "";
1809 if(!gridData.getAttributes().isEmpty()){
1810 for(Object attribute : gridData.getAttributes()){
1811 if(attribute instanceof LinkedHashMap<?, ?>){
1812 String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
1814 userSLValue = userSLValue + ",";
1816 userSLValue = userSLValue + key ;
1821 fwDictList.setServiceList(userSLValue);
1822 String userALValue = "";
1824 if(!gridData.getAlAttributes().isEmpty()){
1825 for(Object attribute : gridData.getAlAttributes()){
1826 if(attribute instanceof LinkedHashMap<?, ?>){
1827 String key = ((LinkedHashMap<?, ?>) attribute).get(option).toString();
1829 userALValue = userALValue + ",";
1831 userALValue = userALValue + key ;
1836 fwDictList.setAddressList(userALValue);
1837 if(fwDictList.getId() == 0){
1838 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwDictList.getParentItemName(), "parentItemName", FirewallDictionaryList.class);
1839 if(!duplicateData.isEmpty()){
1840 duplicateflag = true;
1842 commonClassDao.save(fwDictList);
1845 commonClassDao.update(fwDictList);
1847 response.setCharacterEncoding(utf8);
1848 response.setContentType(applicationJsonContentType);
1849 request.setCharacterEncoding(utf8);
1851 PrintWriter out = response.getWriter();
1852 String responseString = "";
1854 responseString = duplicateResponseString;
1856 responseString = mapper.writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class));
1858 JSONObject j = new JSONObject("{fwDictListDictionaryDatas: " + responseString + "}");
1860 out.write(j.toString());
1864 catch (Exception e){
1865 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1866 response.setCharacterEncoding(utf8);
1867 request.setCharacterEncoding(utf8);
1868 PrintWriter out = response.getWriter();
1869 out.write(PolicyUtils.CATCH_EXCEPTION);
1874 @RequestMapping(value={"/fw_dictionary/remove_FWDictionaryList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1875 public ModelAndView removeFWDictionaryListy(HttpServletRequest request, HttpServletResponse response) throws IOException {
1877 ObjectMapper mapper = new ObjectMapper();
1878 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1879 JsonNode root = mapper.readTree(request.getReader());
1880 FirewallDictionaryList fwDictList = (FirewallDictionaryList)mapper.readValue(root.get("data").toString(), FirewallDictionaryList.class);
1881 commonClassDao.delete(fwDictList);
1882 response.setCharacterEncoding(utf8);
1883 response.setContentType(applicationJsonContentType);
1884 request.setCharacterEncoding(utf8);
1886 PrintWriter out = response.getWriter();
1888 String responseString = mapper.writeValueAsString(commonClassDao.getData(FirewallDictionaryList.class));
1889 JSONObject j = new JSONObject("{fwDictListDictionaryDatas: " + responseString + "}");
1890 out.write(j.toString());
1894 catch (Exception e){
1895 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1896 response.setCharacterEncoding(utf8);
1897 request.setCharacterEncoding(utf8);
1898 PrintWriter out = response.getWriter();
1899 out.write(PolicyUtils.CATCH_EXCEPTION);
1905 @RequestMapping(value={"/get_TagPickerNameByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1906 public void getTagPickerNameEntityDataByName(HttpServletResponse response){
1908 Map<String, Object> model = new HashMap<>();
1909 ObjectMapper mapper = new ObjectMapper();
1910 model.put("fwTagPickerDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(FWTagPicker.class, tagPickerName)));
1911 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1912 JSONObject j = new JSONObject(msg);
1913 response.getWriter().write(j.toString());
1915 catch (Exception e){
1916 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1920 @RequestMapping(value={"/get_TagPickerListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
1921 public void getTagPickerDictionaryEntityData(HttpServletResponse response){
1923 Map<String, Object> model = new HashMap<>();
1924 ObjectMapper mapper = new ObjectMapper();
1925 model.put("fwTagPickerDictionaryDatas", mapper.writeValueAsString(commonClassDao.getData(FWTagPicker.class)));
1926 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
1927 JSONObject j = new JSONObject(msg);
1928 response.addHeader(successMapKey, successMessage);
1929 response.addHeader(operation, getDictionary);
1930 response.getWriter().write(j.toString());
1932 catch (Exception e){
1933 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
1937 @RequestMapping(value={"/fw_dictionary/save_fwTagPicker"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
1938 public ModelAndView saveFirewallTagPickerDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
1940 boolean duplicateflag = false;
1941 boolean isFakeUpdate = false;
1942 boolean fromAPI = false;
1943 if (request.getParameter("apiflag")!=null && ("api").equalsIgnoreCase (request.getParameter("apiflag"))) {
1946 ObjectMapper mapper = new ObjectMapper();
1947 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1948 JsonNode root = mapper.readTree(request.getReader());
1949 FWTagPicker fwTagPicker;
1953 fwTagPicker = (FWTagPicker)mapper.readValue(root.get("dictionaryFields").toString(), FWTagPicker.class);
1955 //check if update operation or create, get id for data to be updated and update attributeData
1956 if (("update").equals(request.getParameter("operation"))) {
1957 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTagPicker.getTagPickerName(), "tagPickerName", FWTagPicker.class);
1959 FWTagPicker dbdata = (FWTagPicker) duplicateData.get(0);
1960 id = dbdata.getId();
1961 fwTagPicker.setId(id);
1962 fwTagPicker.setUserCreatedBy(this.getUserInfo(userId));
1966 fwTagPicker = (FWTagPicker)mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), FWTagPicker.class);
1967 data = (TagGridValues)mapper.readValue(root.get("fwTagPickerDictionaryData").toString(), TagGridValues.class);
1968 userId = root.get("userid").textValue();
1970 StringBuilder header = new StringBuilder();
1972 if(!data.getTags().isEmpty()){
1973 for(Object attribute : data.getTags()){
1974 if(attribute instanceof LinkedHashMap<?, ?>){
1975 String key = ((LinkedHashMap<?, ?>) attribute).get("option").toString();
1976 String value = ((LinkedHashMap<?, ?>) attribute).get("number").toString();
1980 header.append(key+":"+value);
1985 fwTagPicker.setTagValues(header.toString());
1988 if(fwTagPicker.getId() == 0){
1989 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTagPicker.getTagPickerName(), "tagPickerName", FWTagPicker.class);
1990 if(!duplicateData.isEmpty()){
1991 duplicateflag = true;
1993 fwTagPicker.setUserCreatedBy(this.getUserInfo(userId));
1994 fwTagPicker.setUserModifiedBy(this.getUserInfo(userId));
1995 commonClassDao.save(fwTagPicker);
1998 fwTagPicker.setUserModifiedBy(this.getUserInfo(userId));
1999 fwTagPicker.setModifiedDate(new Date());
2000 commonClassDao.update(fwTagPicker);
2002 String responseString = "";
2004 responseString = duplicateResponseString;
2006 responseString = mapper.writeValueAsString(commonClassDao.getData(FWTagPicker.class));
2010 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
2011 responseString = successMsg;
2013 ModelAndView result = new ModelAndView();
2014 result.setViewName(responseString);
2017 response.setCharacterEncoding(utf8);
2018 response.setContentType(applicationJsonContentType);
2019 request.setCharacterEncoding(utf8);
2021 PrintWriter out = response.getWriter();
2022 JSONObject j = new JSONObject("{fwTagPickerDictionaryDatas: " + responseString + "}");
2023 out.write(j.toString());
2027 catch (Exception e){
2028 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2029 response.setCharacterEncoding(utf8);
2030 request.setCharacterEncoding(utf8);
2031 PrintWriter out = response.getWriter();
2032 out.write(PolicyUtils.CATCH_EXCEPTION);
2037 @RequestMapping(value={"/fw_dictionary/remove_tagPicker"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
2038 public ModelAndView removeFirewallTagPickerDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
2040 ObjectMapper mapper = new ObjectMapper();
2041 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2042 JsonNode root = mapper.readTree(request.getReader());
2043 FWTagPicker fwTagPicker = (FWTagPicker)mapper.readValue(root.get("data").toString(), FWTagPicker.class);
2044 commonClassDao.delete(fwTagPicker);
2045 response.setCharacterEncoding(utf8);
2046 response.setContentType(applicationJsonContentType);
2047 request.setCharacterEncoding(utf8);
2049 PrintWriter out = response.getWriter();
2050 String responseString = mapper.writeValueAsString(commonClassDao.getData(FWTagPicker.class));
2051 JSONObject j = new JSONObject("{fwTagPickerDictionaryDatas: " + responseString + "}");
2052 out.write(j.toString());
2055 catch (Exception e){
2056 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2057 response.setCharacterEncoding(utf8);
2058 request.setCharacterEncoding(utf8);
2059 PrintWriter out = response.getWriter();
2060 out.write(PolicyUtils.CATCH_EXCEPTION);
2065 @RequestMapping(value={"/get_TagListData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
2066 public void getTagDictionaryEntityData(HttpServletResponse response){
2068 Map<String, Object> model = new HashMap<>();
2069 ObjectMapper mapper = new ObjectMapper();
2070 model.put(fwTagDictionaryDatas, mapper.writeValueAsString(commonClassDao.getData(FWTag.class)));
2071 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
2072 JSONObject j = new JSONObject(msg);
2073 response.addHeader(successMapKey, successMessage);
2074 response.addHeader(operation, getDictionary);
2075 response.getWriter().write(j.toString());
2077 catch (Exception e){
2078 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2082 @RequestMapping(value={"/get_TagNameByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
2083 public void getTagNameEntityDataByName(HttpServletRequest request, HttpServletResponse response){
2085 Map<String, Object> model = new HashMap<>();
2086 ObjectMapper mapper = new ObjectMapper();
2087 model.put("fwTagDictionaryDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(FWTag.class, "fwTagName")));
2088 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
2089 JSONObject j = new JSONObject(msg);
2090 response.getWriter().write(j.toString());
2092 catch (Exception e){
2093 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2098 @RequestMapping(value={"/fw_dictionary/save_fwTag"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
2099 public ModelAndView saveFirewallTagDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
2101 boolean duplicateflag = false;
2102 boolean fromAPI = false;
2103 if (request.getParameter(apiflag)!=null && ("api").equalsIgnoreCase(request.getParameter(apiflag))) {
2106 ObjectMapper mapper = new ObjectMapper();
2107 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2108 JsonNode root = mapper.readTree(request.getReader());
2113 fwTag = mapper.readValue(root.get("dictionaryFields").toString(), FWTag.class);
2115 //check if update operation or create, get id for data to be updated and update attributeData
2116 if ("update".equals(request.getParameter("operation"))) {
2117 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTag.getFwTagName(), "fwTagName", FWTag.class);
2119 FWTag data = (FWTag) duplicateData.get(0);
2122 fwTag.setUserCreatedBy(this.getUserInfo(userId));
2125 TagGridValues tagGridValues;
2126 fwTag = mapper.readValue(root.get("fwTagDictionaryData").toString(), FWTag.class);
2127 tagGridValues = mapper.readValue(root.get("fwTagDictionaryData").toString(), TagGridValues.class);
2128 userId = root.get("userid").textValue();
2130 StringBuilder userValue = new StringBuilder();
2132 if(!tagGridValues.getTags().isEmpty()){
2133 for(Object attribute : tagGridValues.getTags()){
2134 if(attribute instanceof LinkedHashMap<?, ?>){
2135 String key = ((LinkedHashMap<?, ?>) attribute).get("tags").toString();
2137 userValue.append(",");
2139 userValue.append(key);
2144 fwTag.setTagValues(userValue.toString());
2147 if(fwTag.getId() == 0){
2148 List<Object> duplicateData = commonClassDao.checkDuplicateEntry(fwTag.getFwTagName(), "fwTagName", FWTag.class);
2149 if(!duplicateData.isEmpty()){
2150 duplicateflag = true;
2152 fwTag.setUserCreatedBy(this.getUserInfo(userId));
2153 fwTag.setUserModifiedBy(this.getUserInfo(userId));
2155 commonClassDao.save(fwTag);
2159 fwTag.setUserModifiedBy(this.getUserInfo(userId));
2160 commonClassDao.update(fwTag);
2163 String responseString = "";
2165 responseString = "Duplicate";
2167 responseString = mapper.writeValueAsString(commonClassDao.getData(FWTag.class));
2171 if (responseString!=null && !(duplicateResponseString).equals(responseString)) {
2172 responseString = successMsg;
2174 ModelAndView result = new ModelAndView();
2175 result.setViewName(responseString);
2179 response.setCharacterEncoding(utf8);
2180 response.setContentType(applicationJsonContentType);
2181 request.setCharacterEncoding(utf8);
2183 PrintWriter out = response.getWriter();
2184 JSONObject j = new JSONObject("{fwTagDictionaryDatas: " + responseString + "}");
2185 out.write(j.toString());
2189 catch (Exception e){
2190 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2191 response.setCharacterEncoding(utf8);
2192 request.setCharacterEncoding(utf8);
2193 PrintWriter out = response.getWriter();
2194 out.write(PolicyUtils.CATCH_EXCEPTION);
2199 @RequestMapping(value={"/fw_dictionary/remove_tagList"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
2200 public ModelAndView removeFirewallTagDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
2202 ObjectMapper mapper = new ObjectMapper();
2203 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2204 JsonNode root = mapper.readTree(request.getReader());
2205 FWTag fwTag = (FWTag)mapper.readValue(root.get("data").toString(), FWTag.class);
2206 commonClassDao.delete(fwTag);
2207 response.setCharacterEncoding(utf8);
2208 response.setContentType(applicationJsonContentType);
2209 request.setCharacterEncoding(utf8);
2211 PrintWriter out = response.getWriter();
2213 String responseString = mapper.writeValueAsString(commonClassDao.getData(FWTag.class));
2214 JSONObject j = new JSONObject("{fwTagDictionaryDatas: " + responseString + "}");
2215 out.write(j.toString());
2219 catch (Exception e){
2220 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
2221 response.setCharacterEncoding(utf8);
2222 request.setCharacterEncoding(utf8);
2223 PrintWriter out = response.getWriter();
2224 out.write(PolicyUtils.CATCH_EXCEPTION);
2230 class TagGridValues{
2231 private List<Object> tags;
2233 public List<Object> getTags() {
2237 public void setTags(List<Object> tags) {
2243 private List<Object> attributes;
2245 public List<Object> getAttributes() {
2249 public void setAttributes(List<Object> attributes) {
2250 this.attributes = attributes;
2255 private List<Object> fromZoneDatas;
2256 private List<Object> toZoneDatas;
2257 private List<Object> sourceListDatas;
2258 private List<Object> destinationListDatas;
2259 private List<Object> sourceServiceDatas;
2260 private List<Object> destinationServiceDatas;
2261 private List<Object> actionListDatas;
2262 public List<Object> getFromZoneDatas() {
2263 return fromZoneDatas;
2265 public void setFromZoneDatas(List<Object> fromZoneDatas) {
2266 this.fromZoneDatas = fromZoneDatas;
2268 public List<Object> getToZoneDatas() {
2271 public void setToZoneDatas(List<Object> toZoneDatas) {
2272 this.toZoneDatas = toZoneDatas;
2274 public List<Object> getSourceListDatas() {
2275 return sourceListDatas;
2277 public void setSourceListDatas(List<Object> sourceListDatas) {
2278 this.sourceListDatas = sourceListDatas;
2280 public List<Object> getDestinationListDatas() {
2281 return destinationListDatas;
2283 public void setDestinationListDatas(List<Object> destinationListDatas) {
2284 this.destinationListDatas = destinationListDatas;
2286 public List<Object> getSourceServiceDatas() {
2287 return sourceServiceDatas;
2289 public void setSourceServiceDatas(List<Object> sourceServiceDatas) {
2290 this.sourceServiceDatas = sourceServiceDatas;
2292 public List<Object> getDestinationServiceDatas() {
2293 return destinationServiceDatas;
2295 public void setDestinationServiceDatas(List<Object> destinationServiceDatas) {
2296 this.destinationServiceDatas = destinationServiceDatas;
2298 public List<Object> getActionListDatas() {
2299 return actionListDatas;
2301 public void setActionListDatas(List<Object> actionListDatas) {
2302 this.actionListDatas = actionListDatas;