aboutsummaryrefslogtreecommitdiffstats
path: root/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ClosedLoopPolicyPerformanceMetricClient.java
diff options
context:
space:
mode:
authorRavindra Bakkamanthala <rb7147@att.com>2017-06-05 22:42:02 -0400
committerRavindra Bakkamanthala <rb7147@att.com>2017-06-07 14:47:34 -0400
commitfc5c07705edc4dcb7083b39116a43844bb6a1490 (patch)
treeab5c7258197fc776fef8106413704a5f0a829160 /PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ClosedLoopPolicyPerformanceMetricClient.java
parentd9007d680d19734d5dc106479784c420236cca4b (diff)
Fixed the Policy API issues and Bugfixes
Change-Id: I6e8b54442421b6ebd0ff88426fc6e5f3a36b0690 Signed-off-by: Ravindra Bakkamanthala <rb7147@att.com>
Diffstat (limited to 'PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ClosedLoopPolicyPerformanceMetricClient.java')
-rw-r--r--PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ClosedLoopPolicyPerformanceMetricClient.java22
1 files changed, 14 insertions, 8 deletions
diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ClosedLoopPolicyPerformanceMetricClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ClosedLoopPolicyPerformanceMetricClient.java
index 6357cea5a..9564cdefe 100644
--- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ClosedLoopPolicyPerformanceMetricClient.java
+++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ClosedLoopPolicyPerformanceMetricClient.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;
@@ -50,20 +51,26 @@ public class ClosedLoopPolicyPerformanceMetricClient {
//Builds JSONObject from File
private static JsonObject buildJSON(File jsonInput, String jsonString) throws FileNotFoundException {
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;
}
@@ -80,10 +87,9 @@ public class ClosedLoopPolicyPerformanceMetricClient {
// Set up Micro Services Attributes
File jsonFile = null;
String MSjsonString= null;
- if (MSjsonString == null) {
- Path file = Paths.get("C:\\policyAPI\\ClosedLoopJSON\\pmTestJson.json");
- jsonFile = file.toFile();
- }
+ Path file = Paths.get("C:\\policyAPI\\ClosedLoopJSON\\pmTestJson.json");
+ jsonFile = file.toFile();
+
policyParameters.setConfigBody(buildJSON(jsonFile, MSjsonString).toString());
policyParameters.setConfigBodyType(PolicyType.JSON);