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%2FCreateBrmsRawPolicy.java;h=0bac0e06680868d7cca18784da9bd8ab1ba85976;hb=eef3c224cb6cad4b82a96938ade1e42ca881eea2;hp=4bcb05788800a21b47af4bd0634dc1cbccbd500d;hpb=073cc188efe9abb4c010cf674e34e2cf46ef1c52;p=policy%2Fengine.git diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBrmsRawPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBrmsRawPolicy.java index 4bcb05788..0bac0e066 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBrmsRawPolicy.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBrmsRawPolicy.java @@ -40,6 +40,7 @@ import org.onap.policy.common.logging.eelf.PolicyLogger; import org.onap.policy.pap.xacml.rest.controller.BRMSDictionaryController; import org.onap.policy.rest.adapter.PolicyRestAdapter; +import com.att.research.xacml.api.pap.PAPException; import com.att.research.xacml.std.IdentifierImpl; import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType; @@ -71,15 +72,13 @@ public class CreateBrmsRawPolicy extends Policy { // Saving the Configurations file at server location for CreateBrmsRawPolicy policy. protected void saveConfigurations(String policyName, String jsonBody) { - try { - if (policyName.endsWith(".xml")) { - policyName = policyName.substring(0, - policyName.lastIndexOf(".xml")); - } - PrintWriter out = new PrintWriter(CONFIG_HOME + File.separator + policyName + ".txt"); + + if (policyName.endsWith(".xml")) { + policyName = policyName.substring(0, + policyName.lastIndexOf(".xml")); + } + try (PrintWriter out = new PrintWriter(CONFIG_HOME + File.separator + policyName + ".txt")){ out.println(jsonBody); - out.close(); - } catch (Exception e) { PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "CreateBrmsRawPolicy", "Exception saving configurations file"); } @@ -115,7 +114,7 @@ public class CreateBrmsRawPolicy extends Policy { } @Override - public Map savePolicies() throws Exception { + public Map savePolicies() throws PAPException { Map successMap = new HashMap<>(); if(isPolicyExists()){ @@ -146,7 +145,7 @@ public class CreateBrmsRawPolicy extends Policy { // separately because the fully configured policy is used for multiple // things @Override - public boolean prepareToSave() throws Exception { + public boolean prepareToSave() throws PAPException { if (isPreparedToSave()) { // we have already done this