Code Review
/
policy
/
engine.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fixed the Policy API issues and Bugfixes
[policy/engine.git]
/
PolicyEngineClient
/
src
/
main
/
java
/
org
/
openecomp
/
policyEngine
/
ClosedLoopPolicyPerformanceMetricClient.java
diff --git
a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ClosedLoopPolicyPerformanceMetricClient.java
b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ClosedLoopPolicyPerformanceMetricClient.java
index
6357cea
..
9564cde
100644
(file)
--- 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.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;
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;;
//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);
if (jsonString != null && jsonInput == null) {
StringReader in = null;
in = new StringReader(jsonString);
-
JsonReader
jsonReader = Json.createReader(in);
+
jsonReader = Json.createReader(in);
json = jsonReader.readObject();
json = jsonReader.readObject();
+ in.close();
}
else {
InputStream in = null;
in = new FileInputStream(jsonInput);
}
else {
InputStream in = null;
in = new FileInputStream(jsonInput);
-
JsonReader
jsonReader = Json.createReader(in);
+ jsonReader = Json.createReader(in);
json = jsonReader.readObject();
json = jsonReader.readObject();
+ try {
+ in.close();
+ } catch (IOException e) {
+ System.err.println("Exception Occured while closing input stream"+e);
+ }
}
}
-
+ jsonReader.close();
return json;
}
return json;
}
@@
-80,10
+87,9
@@
public class ClosedLoopPolicyPerformanceMetricClient {
// Set up Micro Services Attributes
File jsonFile = null;
String MSjsonString= null;
// 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);
policyParameters.setConfigBody(buildJSON(jsonFile, MSjsonString).toString());
policyParameters.setConfigBodyType(PolicyType.JSON);