X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=POLICY-SDK-APP%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fcontroller%2FCreateFirewallController.java;h=446e124edccfe66e73e0c12d751922f0e5f1aa12;hp=8aad4216dbd933e4055b414e183d93a52bb8b9b8;hb=0c20d1c294fe146e1018f14b07a8d861c29fe527;hpb=b831c6a3df8e1dc9017ae5e8ad002dc3b1002aab diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java index 8aad4216d..446e124ed 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,13 +25,10 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectWriter; -import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -42,12 +39,10 @@ import javax.servlet.http.HttpServletResponse; import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType; -import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType; -import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType; - +import org.apache.commons.lang3.StringUtils; import org.hibernate.SessionFactory; import org.json.JSONObject; import org.onap.policy.common.logging.flexlogger.FlexLogger; @@ -71,13 +66,14 @@ import org.onap.policy.rest.adapter.TermCollector; import org.onap.policy.rest.adapter.VendorSpecificData; import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.AddressGroup; -import org.onap.policy.rest.jpa.FWTagPicker; +import org.onap.policy.rest.jpa.FwTagPicker; import org.onap.policy.rest.jpa.GroupServiceList; import org.onap.policy.rest.jpa.PolicyEntity; import org.onap.policy.rest.jpa.PrefixList; import org.onap.policy.rest.jpa.SecurityZone; import org.onap.policy.rest.jpa.ServiceList; import org.onap.policy.rest.jpa.TermList; +import org.onap.policy.utils.PolicyUtils; import org.onap.policy.xacml.api.XACMLErrorConstants; import org.onap.portalsdk.core.controller.RestrictedBaseController; import org.springframework.beans.factory.annotation.Autowired; @@ -91,11 +87,19 @@ public class CreateFirewallController extends RestrictedBaseController { private static Logger policyLogger = FlexLogger.getLogger(CreateFirewallController.class); private static final String ANY = "ANY"; private static final String GROUP = "Group_"; + private static CommonClassDao commonClassDao; + private List tagCollectorList; + private List termCollectorList; + + List expandablePrefixIpList = new ArrayList<>(); + List expandableServicesList = new ArrayList<>(); @Autowired SessionFactory sessionFactory; - private static CommonClassDao commonClassDao; + public CreateFirewallController() { + // Empty constructor + } public static CommonClassDao getCommonClassDao() { return commonClassDao; @@ -105,24 +109,18 @@ public class CreateFirewallController extends RestrictedBaseController { CreateFirewallController.commonClassDao = commonClassDao; } - private List tagCollectorList; - - List expandablePrefixIPList = new ArrayList<>(); - List expandableServicesList = new ArrayList<>(); - @Autowired private CreateFirewallController(CommonClassDao commonClassDao) { CreateFirewallController.commonClassDao = commonClassDao; } - public CreateFirewallController() { - // Empty constructor - } - - private List termCollectorList; - + /** + * setDataToPolicyRestAdapter. + * + * @param policyData PolicyRestAdapter + * @return PolicyRestAdapter + */ public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData) { - String jsonBody; termCollectorList = new ArrayList<>(); tagCollectorList = new ArrayList<>(); if (!policyData.getAttributes().isEmpty()) { @@ -136,12 +134,15 @@ public class CreateFirewallController extends RestrictedBaseController { } } } - jsonBody = constructJson(policyData); - if (jsonBody != null && !"".equalsIgnoreCase(jsonBody)) { + String jsonBody = constructJson(policyData); + if (StringUtils.isBlank(jsonBody)) { policyData.setJsonBody(jsonBody); } else { policyData.setJsonBody("{}"); } + // + // Hmmm - seems to be overriding the previous if statement + // policyData.setJsonBody(jsonBody); return policyData; @@ -206,117 +207,90 @@ public class CreateFirewallController extends RestrictedBaseController { public void prePopulateFWPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) { ArrayList attributeList; attributeList = new ArrayList<>(); - if (policyAdapter.getPolicyData() instanceof PolicyType) { - Object policyData = policyAdapter.getPolicyData(); - PolicyType policy = (PolicyType) policyData; - // policy name value is the policy name without any prefix and Extensions. - policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName()); - String policyNameValue = - policyAdapter.getPolicyName().substring(policyAdapter.getPolicyName().indexOf("FW_") + 3); - if (policyLogger.isDebugEnabled()) { - policyLogger - .debug("Prepopulating form data for Config Policy selected:" + policyAdapter.getPolicyName()); - } - policyAdapter.setPolicyName(policyNameValue); - String description = ""; - try { - description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:")); - } catch (Exception e) { - policyLogger.info("General error", e); - description = policy.getDescription(); - } - policyAdapter.setPolicyDescription(description); + if (! (policyAdapter.getPolicyData() instanceof PolicyType)) { + return; + } + Object policyData = policyAdapter.getPolicyData(); + PolicyType policy = (PolicyType) policyData; + // policy name value is the policy name without any prefix and Extensions. + policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName()); + String policyNameValue = + policyAdapter.getPolicyName().substring(policyAdapter.getPolicyName().indexOf("FW_") + 3); + if (policyLogger.isDebugEnabled()) { + policyLogger + .debug("Prepopulating form data for Config Policy selected:" + policyAdapter.getPolicyName()); + } + policyAdapter.setPolicyName(policyNameValue); + String description = ""; + try { + description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:")); + } catch (Exception e) { + policyLogger.info("General error", e); + description = policy.getDescription(); + } + policyAdapter.setPolicyDescription(description); - ObjectMapper mapper = new ObjectMapper(); + ObjectMapper mapper = new ObjectMapper(); - TermCollector tc1 = null; - try { - // Json conversion. - String data; - SecurityZone jpaSecurityZone; - data = entity.getConfigurationData().getConfigBody(); - tc1 = mapper.readValue(data, TermCollector.class); - List securityZoneData = commonClassDao.getData(SecurityZone.class); - for (int i = 0; i < securityZoneData.size(); i++) { - jpaSecurityZone = (SecurityZone) securityZoneData.get(i); - if (jpaSecurityZone.getZoneValue().equals(tc1.getSecurityZoneId())) { - policyAdapter.setSecurityZone(jpaSecurityZone.getZoneName()); - break; - } + TermCollector tc1 = null; + try { + // Json conversion. + String data; + SecurityZone jpaSecurityZone; + data = entity.getConfigurationData().getConfigBody(); + tc1 = mapper.readValue(data, TermCollector.class); + List securityZoneData = commonClassDao.getData(SecurityZone.class); + for (int i = 0; i < securityZoneData.size(); i++) { + jpaSecurityZone = (SecurityZone) securityZoneData.get(i); + if (jpaSecurityZone.getZoneValue().equals(tc1.getSecurityZoneId())) { + policyAdapter.setSecurityZone(jpaSecurityZone.getZoneName()); + break; } - } catch (Exception e) { - policyLogger.error("Exception Caused while Retriving the JSON body data" + e); } + } catch (Exception e) { + policyLogger.error("Exception Caused while Retriving the JSON body data" + e); + } - Map termTagMap; - if (tc1 != null) { - for (int i = 0; i < tc1.getFirewallRuleList().size(); i++) { - termTagMap = new HashMap<>(); - String ruleName = tc1.getFirewallRuleList().get(i).getRuleName(); - String tagPickerName = tc1.getRuleToTag().get(i).getTagPickerName(); - termTagMap.put("key", ruleName); - termTagMap.put("value", tagPickerName); - attributeList.add(termTagMap); - } + Map termTagMap; + if (tc1 != null) { + for (int i = 0; i < tc1.getFirewallRuleList().size(); i++) { + termTagMap = new HashMap<>(); + String ruleName = tc1.getFirewallRuleList().get(i).getRuleName(); + String tagPickerName = tc1.getRuleToTag().get(i).getTagPickerName(); + termTagMap.put("key", ruleName); + termTagMap.put("value", tagPickerName); + attributeList.add(termTagMap); } - policyAdapter.setAttributes(attributeList); - // Get the target data under policy. - TargetType target = policy.getTarget(); - if (target != null) { - // Under target we have AnyOFType - List anyOfList = target.getAnyOf(); - if (anyOfList != null) { - Iterator iterAnyOf = anyOfList.iterator(); - while (iterAnyOf.hasNext()) { - AnyOfType anyOf = iterAnyOf.next(); - // Under AnyOFType we have AllOFType - List allOfList = anyOf.getAllOf(); - if (allOfList != null) { - Iterator iterAllOf = allOfList.iterator(); - while (iterAllOf.hasNext()) { - AllOfType allOf = iterAllOf.next(); - // Under AllOFType we have Match - List matchList = allOf.getMatch(); - if (matchList != null) { - - Iterator iterMatch = matchList.iterator(); - while (iterMatch.hasNext()) { - MatchType match = iterMatch.next(); - // - // Under the match we have attribute value and - // attributeDesignator. So,finally down to the actual attribute. - // - AttributeValueType attributeValue = match.getAttributeValue(); - String value = (String) attributeValue.getContent().get(0); - AttributeDesignatorType designator = match.getAttributeDesignator(); - String attributeId = designator.getAttributeId(); - if (("ConfigName").equals(attributeId)) { - policyAdapter.setConfigName(value); - } - if (("RiskType").equals(attributeId)) { - policyAdapter.setRiskType(value); - } - if (("RiskLevel").equals(attributeId)) { - policyAdapter.setRiskLevel(value); - } - if (("guard").equals(attributeId)) { - policyAdapter.setGuard(value); - } - if ("TTLDate".equals(attributeId) && !value.contains("NA")) { - PolicyController controller = new PolicyController(); - String newDate = controller.convertDate(value); - policyAdapter.setTtlDate(newDate); - } - } - } - } - } - } + } + policyAdapter.setAttributes(attributeList); + // Get the target data under policy. + TargetType target = policy.getTarget(); + if (target == null) { + return; + } + // Under target we have AnyOFType + // NOTE: target.getAnyOf() will never be null + for (AnyOfType anyOf : target.getAnyOf()) { + for (AllOfType allOf : anyOf.getAllOf()) { + for (MatchType match : allOf.getMatch()) { + // + // Under the match we have attribute value and + // attributeDesignator. So,finally down to the actual attribute. + // + policyAdapter.setupUsingAttribute(match.getAttributeDesignator().getAttributeId(), + (String) match.getAttributeValue().getContent().get(0)); } } } } + /** + * setFWViewRule. + * + * @param request HttpServletRequest + * @param response HttpServletResponse + * @return ModelAndView + */ @RequestMapping( value = {"/policyController/ViewFWPolicyRule.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) @@ -463,14 +437,12 @@ public class CreateFirewallController extends RestrictedBaseController { } } } - response.setCharacterEncoding("UTF-8"); - response.setContentType("application / json"); - request.setCharacterEncoding("UTF-8"); + response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); + response.setContentType(PolicyUtils.APPLICATION_JSON); + request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); - PrintWriter out = response.getWriter(); String responseString = mapper.writeValueAsString(displayString); - JSONObject j = new JSONObject("{policyData: " + responseString + "}"); - out.write(j.toString()); + response.getWriter().write(new JSONObject("{policyData: " + responseString + "}").toString()); return null; } catch (Exception e) { policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e); @@ -481,13 +453,13 @@ public class CreateFirewallController extends RestrictedBaseController { private String constructJson(PolicyRestAdapter policyData) { int ruleCount = 1; // Maps to assosciate the values read from the TermList dictionary - Map srcIP_map = null; - Map destIP_map = null; - Map srcPort_map = null; - Map destPort_map = null; - Map action_map = null; - Map fromZone_map = null; - Map toZone_map = null; + Map mapSrcIp = null; + Map mapDestIP = null; + Map mapSrcPort = null; + Map mapDestPort = null; + Map mapAction = null; + Map mapFromZone = null; + Map mapToZone = null; String ruleDesc = null; String ruleFromZone = null; @@ -513,14 +485,14 @@ public class CreateFirewallController extends RestrictedBaseController { List tagList = null; ServiceListJson targetSl = null; AddressMembers addressMembersJson = null; - int i = 0; + int intCounter = 0; try { String networkRole = ""; for (String tag : tagCollectorList) { tags = new Tags(); - List tagListData = commonClassDao.getData(FWTagPicker.class); + List tagListData = commonClassDao.getData(FwTagPicker.class); for (int tagCounter = 0; tagCounter < tagListData.size(); tagCounter++) { - FWTagPicker jpaTagPickerList = (FWTagPicker) tagListData.get(tagCounter); + FwTagPicker jpaTagPickerList = (FwTagPicker) tagListData.get(tagCounter); if (jpaTagPickerList.getTagPickerName().equals(tag)) { String tagValues = jpaTagPickerList.getTagValues(); tagList = new ArrayList<>(); @@ -542,10 +514,10 @@ public class CreateFirewallController extends RestrictedBaseController { } tags.setTags(tagList); tags.setTagPickerName(tag); - tags.setRuleName(termCollectorList.get(i)); + tags.setRuleName(termCollectorList.get(intCounter)); tags.setNetworkRole(networkRole); tagsList.add(tags); - i++; + intCounter++; } tc.setRuleToTag(tagsList); @@ -564,47 +536,47 @@ public class CreateFirewallController extends RestrictedBaseController { ruleFromZone = jpaTermList.getFromZone(); if ((ruleFromZone != null) && (!ruleFromZone.isEmpty())) { - fromZone_map = new HashMap<>(); - fromZone_map.put(tl, ruleFromZone); + mapFromZone = new HashMap<>(); + mapFromZone.put(tl, ruleFromZone); } ruleToZone = jpaTermList.getToZone(); if ((ruleToZone != null) && (!ruleToZone.isEmpty())) { - toZone_map = new HashMap<>(); - toZone_map.put(tl, ruleToZone); + mapToZone = new HashMap<>(); + mapToZone.put(tl, ruleToZone); } ruleSrcPrefixList = jpaTermList.getSrcIPList(); if ((ruleSrcPrefixList != null) && (!ruleSrcPrefixList.isEmpty())) { - srcIP_map = new HashMap<>(); - srcIP_map.put(tl, ruleSrcPrefixList); + mapSrcIp = new HashMap<>(); + mapSrcIp.put(tl, ruleSrcPrefixList); } ruleDestPrefixList = jpaTermList.getDestIPList(); if ((ruleDestPrefixList != null) && (!ruleDestPrefixList.isEmpty())) { - destIP_map = new HashMap<>(); - destIP_map.put(tl, ruleDestPrefixList); + mapDestIP = new HashMap<>(); + mapDestIP.put(tl, ruleDestPrefixList); } ruleSrcPort = jpaTermList.getSrcPortList(); if (ruleSrcPort != null && (!ruleSrcPort.isEmpty())) { - srcPort_map = new HashMap<>(); - srcPort_map.put(tl, ruleSrcPort); + mapSrcPort = new HashMap<>(); + mapSrcPort.put(tl, ruleSrcPort); } ruleDestPort = jpaTermList.getDestPortList(); if (ruleDestPort != null && (!jpaTermList.getDestPortList().isEmpty())) { - destPort_map = new HashMap<>(); - destPort_map.put(tl, ruleDestPort); + mapDestPort = new HashMap<>(); + mapDestPort.put(tl, ruleDestPort); } ruleAction = jpaTermList.getAction(); if ((ruleAction != null) && (!ruleAction.isEmpty())) { - action_map = new HashMap<>(); - action_map.put(tl, ruleAction); + mapAction = new HashMap<>(); + mapAction.put(tl, ruleAction); } } } @@ -613,32 +585,32 @@ public class CreateFirewallController extends RestrictedBaseController { targetTerm.setNegateSource(false); targetTerm.setNegateDestination(false); - if (action_map != null) { - targetTerm.setAction(action_map.get(tl)); + if (mapAction != null) { + targetTerm.setAction(mapAction.get(tl)); } // FromZone arrays - if (fromZone_map != null) { + if (mapFromZone != null) { List fromZone = new ArrayList<>(); - for (String fromZoneStr : fromZone_map.get(tl).split(",")) { + for (String fromZoneStr : mapFromZone.get(tl).split(",")) { fromZone.add(fromZoneStr); } targetTerm.setFromZones(fromZone); } // ToZone arrays - if (toZone_map != null) { + if (mapToZone != null) { List toZone = new ArrayList<>(); - for (String toZoneStr : toZone_map.get(tl).split(",")) { + for (String toZoneStr : mapToZone.get(tl).split(",")) { toZone.add(toZoneStr); } targetTerm.setToZones(toZone); } // Destination Services. - if (destPort_map != null) { + if (mapDestPort != null) { Set destServicesJsonList = new HashSet<>(); - for (String destServices : destPort_map.get(tl).split(",")) { + for (String destServices : mapDestPort.get(tl).split(",")) { ServicesJson destServicesJson = new ServicesJson(); destServicesJson.setType("REFERENCE"); if (destServices.equals(ANY)) { @@ -657,19 +629,19 @@ public class CreateFirewallController extends RestrictedBaseController { targetTerm.setDestServices(destServicesJsonList); } // ExpandableServicesList - if ((srcPort_map != null) && (destPort_map != null)) { - String servicesCollateString = srcPort_map.get(tl) + "," + destPort_map.get(tl); + if ((mapSrcPort != null) && (mapDestPort != null)) { + String servicesCollateString = mapSrcPort.get(tl) + "," + mapDestPort.get(tl); expandableServicesList.add(servicesCollateString); - } else if (srcPort_map != null) { - expandableServicesList.add(srcPort_map.get(tl)); - } else if (destPort_map != null) { - expandableServicesList.add(destPort_map.get(tl)); + } else if (mapSrcPort != null) { + expandableServicesList.add(mapSrcPort.get(tl)); + } else if (mapDestPort != null) { + expandableServicesList.add(mapDestPort.get(tl)); } - if (srcIP_map != null) { + if (mapSrcIp != null) { // Source List List sourceListArrayJson = new ArrayList<>(); - for (String srcList : srcIP_map.get(tl).split(",")) { + for (String srcList : mapSrcIp.get(tl).split(",")) { AddressJson srcListJson = new AddressJson(); if (srcList.equals(ANY)) { srcListJson.setType("any"); @@ -687,10 +659,10 @@ public class CreateFirewallController extends RestrictedBaseController { } targetTerm.setSourceList(sourceListArrayJson); } - if (destIP_map != null) { + if (mapDestIP != null) { // Destination List List destListArrayJson = new ArrayList<>(); - for (String destList : destIP_map.get(tl).split(",")) { + for (String destList : mapDestIP.get(tl).split(",")) { AddressJson destListJson = new AddressJson(); if (destList.equals(ANY)) { destListJson.setType("any"); @@ -709,13 +681,13 @@ public class CreateFirewallController extends RestrictedBaseController { targetTerm.setDestinationList(destListArrayJson); } // ExpandablePrefixIPList - if ((srcIP_map != null) && (destIP_map != null)) { - String collateString = srcIP_map.get(tl) + "," + destIP_map.get(tl); - expandablePrefixIPList.add(collateString); - } else if (srcIP_map != null) { - expandablePrefixIPList.add(srcIP_map.get(tl)); - } else if (destIP_map != null) { - expandablePrefixIPList.add(destIP_map.get(tl)); + if ((mapSrcIp != null) && (mapDestIP != null)) { + String collateString = mapSrcIp.get(tl) + "," + mapDestIP.get(tl); + expandablePrefixIpList.add(collateString); + } else if (mapSrcIp != null) { + expandablePrefixIpList.add(mapSrcIp.get(tl)); + } else if (mapDestIP != null) { + expandablePrefixIpList.add(mapDestIP.get(tl)); } termList.add(targetTerm); targetTerm.setPosition(Integer.toString(ruleCount++)); @@ -800,7 +772,7 @@ public class CreateFirewallController extends RestrictedBaseController { servListArray.add(targetAnyUdp); } - } else {// This is a group + } else { // This is a group GroupServiceList sg; targetSg = new ServiceGroupJson(); sg = mappingServiceGroup(t); @@ -835,15 +807,13 @@ public class CreateFirewallController extends RestrictedBaseController { } } - Set prefixIPList = new HashSet<>(); - for (String prefixList : expandablePrefixIPList) { + Set prefixIpList = new HashSet<>(); + for (String prefixList : expandablePrefixIpList) { for (String prefixIP : prefixList.split(",")) { if (!prefixIP.startsWith(GROUP)) { if (!prefixIP.equals(ANY)) { - List addMembersList = new ArrayList<>(); List valueDesc; PrefixIPList targetAddressList = new PrefixIPList(); - AddressMembers addressMembers = new AddressMembers(); targetAddressList.setName(prefixIP); policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "PrefixList value:" + prefixIP); valueDesc = mapping(prefixIP); @@ -852,18 +822,18 @@ public class CreateFirewallController extends RestrictedBaseController { + valueDesc.get(1)); targetAddressList.setDescription(valueDesc.get(1)); } - + AddressMembers addressMembers = new AddressMembers(); addressMembers.setType("SUBNET"); if (!valueDesc.isEmpty()) { addressMembers.setValue(valueDesc.get(0)); } - + List addMembersList = new ArrayList<>(); addMembersList.add(addressMembers); targetAddressList.setMembers(addMembersList); - prefixIPList.add(targetAddressList); + prefixIpList.add(targetAddressList); } - } else {// This is a group + } else { // This is a group AddressGroup ag; addressSg = new AddressGroupJson(); ag = mappingAddressGroup(prefixIP); @@ -874,14 +844,13 @@ public class CreateFirewallController extends RestrictedBaseController { List addrMembersList = new ArrayList<>(); for (String groupString : ag.getPrefixList().split(",")) { - List valueDesc; AddressMembersJson addressMembers = new AddressMembersJson(); addressMembers.setType("REFERENCES"); addressMembers.setName(groupString); addrMembersList.add(addressMembers); // Expand the group Name addressMembersJson = new AddressMembers(); - valueDesc = mapping(groupString); + List valueDesc = mapping(groupString); addressMembersJson.setName(groupString); addressMembersJson.setType("SUBNET"); @@ -909,7 +878,7 @@ public class CreateFirewallController extends RestrictedBaseController { Set addressGroup = new HashSet<>(); - for (Object addObj : prefixIPList) { + for (Object addObj : prefixIpList) { addressGroup.add(addObj); } @@ -925,9 +894,8 @@ public class CreateFirewallController extends RestrictedBaseController { tc.setAddressGroups(addressGroup); tc.setFirewallRuleList(termList); - ObjectWriter om = new ObjectMapper().writer(); try { - json = om.writeValueAsString(tc); + json = new ObjectMapper().writer().writeValueAsString(tc); } catch (JsonGenerationException e) { policyLogger.error("JsonGenerationException Ocured", e); } catch (JsonMappingException e) {