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]
/
ECOMP-PAP-REST
/
src
/
main
/
java
/
org
/
openecomp
/
policy
/
pap
/
xacml
/
rest
/
components
/
Policy.java
diff --git
a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java
b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java
index
48431fe
..
536f8e6
100644
(file)
--- a/
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java
+++ b/
ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java
@@
-210,13
+210,17
@@
public abstract class Policy {
// Validation for json.
protected static boolean isJSONValid(String data) {
// Validation for json.
protected static boolean isJSONValid(String data) {
+ JsonReader jsonReader = null;
try {
new JSONObject(data);
InputStream stream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
try {
new JSONObject(data);
InputStream stream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
-
JsonReader
jsonReader = Json.createReader(stream);
+ jsonReader = Json.createReader(stream);
System.out.println("Json Value is: " + jsonReader.read().toString() );
} catch (Exception e) {
System.out.println("Json Value is: " + jsonReader.read().toString() );
} catch (Exception e) {
+ LOGGER.error("Exception Occured while reading json"+e);
return false;
return false;
+ }finally{
+ jsonReader.close();
}
return true;
}
}
return true;
}
@@
-308,6
+312,12
@@
public abstract class Policy {
}
} catch (Exception e) {
success.put("error", "Validation Failed");
}
} catch (Exception e) {
success.put("error", "Validation Failed");
+ }finally{
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ LOGGER.error("Exception Occured while closing the input stream"+e);
+ }
}
} else {
PolicyLogger.error("Unknown data type sent back.");
}
} else {
PolicyLogger.error("Unknown data type sent back.");