From fc5c07705edc4dcb7083b39116a43844bb6a1490 Mon Sep 17 00:00:00 2001 From: Ravindra Bakkamanthala Date: Mon, 5 Jun 2017 22:42:02 -0400 Subject: Fixed the Policy API issues and Bugfixes Change-Id: I6e8b54442421b6ebd0ff88426fc6e5f3a36b0690 Signed-off-by: Ravindra Bakkamanthala --- .../policyEngine/ConfigFirewallPolicyClient.java | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ConfigFirewallPolicyClient.java') diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ConfigFirewallPolicyClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ConfigFirewallPolicyClient.java index 5c6752bd5..a6b3119f9 100644 --- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ConfigFirewallPolicyClient.java +++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ConfigFirewallPolicyClient.java @@ -23,6 +23,7 @@ package org.openecomp.policyEngine; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.IOException; import java.io.InputStream; import java.io.StringReader; import java.nio.file.Path; @@ -65,10 +66,9 @@ public class ConfigFirewallPolicyClient { policyParameters.setRiskType("PROD"); File jsonFile = null; String jsonRuleList = null; - if (jsonRuleList == null) { - Path file = Paths.get("C:\\policyAPI\\firewallRulesJSON\\Config_FW_1607Rule.json"); - jsonFile = file.toFile(); - } + Path file = Paths.get("C:\\policyAPI\\firewallRulesJSON\\Config_FW_1607Rule.json"); + jsonFile = file.toFile(); + //buildJSON(jsonFile, jsonRuleList); policyParameters.setConfigBody(buildJSON(jsonFile, jsonRuleList).toString()); policyParameters.setConfigBodyType(PolicyType.JSON); @@ -93,24 +93,26 @@ public class ConfigFirewallPolicyClient { } private static JsonObject buildJSON(File jsonInput, String jsonString) throws FileNotFoundException { - JsonObject json = null;; + JsonObject json = null; + JsonReader jsonReader = null; if (jsonString != null && jsonInput == null) { StringReader in = null; - in = new StringReader(jsonString); - - JsonReader jsonReader = Json.createReader(in); + jsonReader = Json.createReader(in); json = jsonReader.readObject(); - - + in.close(); } else { InputStream in = null; in = new FileInputStream(jsonInput); - - JsonReader jsonReader = Json.createReader(in); + jsonReader = Json.createReader(in); json = jsonReader.readObject(); + try { + in.close(); + } catch (IOException e) { + System.err.println("Exception Occured while closing input stream"+e); + } } - + jsonReader.close(); return json; } -- cgit 1.2.3-korg