X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Fcomponents%2FCreateClosedLoopPerformanceMetrics.java;h=456924ac99d001704db828718a80934a3d89f309;hb=eef3c224cb6cad4b82a96938ade1e42ca881eea2;hp=68cc9eff752c9b9e5cbb4fbd4b01e81fbb769f84;hpb=44fd25bcbb86f8600ec88eeeac6bb8312672c470;p=policy%2Fengine.git diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateClosedLoopPerformanceMetrics.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateClosedLoopPerformanceMetrics.java index 68cc9eff7..456924ac9 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateClosedLoopPerformanceMetrics.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateClosedLoopPerformanceMetrics.java @@ -67,23 +67,15 @@ public class CreateClosedLoopPerformanceMetrics extends Policy { } //save configuration of the policy based on the policyname - private void saveConfigurations(String policyName, String jsonBody) { - try { - String body = null; - try { - body = jsonBody; - } catch (Exception e) { - LOGGER.error("Exception Occured"+e); - } - if(policyName.endsWith(".xml")){ - policyName = policyName.substring(0, policyName.lastIndexOf(".xml")); - } - PrintWriter out = new PrintWriter(CONFIG_HOME + File.separator + "."+ policyName +".json"); - out.println(body); - policyAdapter.setJsonBody(body); - policyAdapter.setConfigBodyData(body); - out.close(); - + private void saveConfigurations(String policyName, final String jsonBody) { + + if(policyName.endsWith(".xml")){ + policyName = policyName.substring(0, policyName.lastIndexOf(".xml")); + } + try (PrintWriter out = new PrintWriter(CONFIG_HOME + File.separator + "."+ policyName +".json")){ + out.println(jsonBody); + policyAdapter.setJsonBody(jsonBody); + policyAdapter.setConfigBodyData(jsonBody); } catch (Exception e) { LOGGER.error("Exception Occured"+e); }