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%2FPolicy.java;h=4c837bb18835f7a4ef088f278adf18e4dc943a81;hb=eff265962c081edb751d5d2ed99dc443cb97f3fb;hp=3b3e81ee2f01cb25f3032280903c2f3a9f845822;hpb=cb802d83533ff13886f08b6b9ecb8827bb86d90c;p=policy%2Fengine.git diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/Policy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/Policy.java index 3b3e81ee2..4c837bb18 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/Policy.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/Policy.java @@ -231,13 +231,13 @@ public abstract class Policy { String absolutePath = parentPath.toString(); if (absolutePath != null && !absolutePath.equals(EMPTY_STRING)) { policyDir = absolutePath.substring(absolutePath.lastIndexOf('\\') + 1, absolutePath.length()); - if (policyDir == null || policyDir.equals(EMPTY_STRING)) { + if (policyDir.equals(EMPTY_STRING)) { policyDir = absolutePath.substring(absolutePath.lastIndexOf('/') + 1, absolutePath.length()); } } String fileName = "default"; - if (policyDir != null && !policyDir.equals(EMPTY_STRING)) { + if (!policyDir.equals(EMPTY_STRING)) { if("ClosedLoop_PM".equals(policyConfigType)){ fileName = policyType + "_" + "PM" + "_" +java.lang.String.format(policyFileName) + "." +version +".xml"; }else if("ClosedLoop_Fault".equals(policyConfigType)){ @@ -271,9 +271,8 @@ public abstract class Policy { // //Does not need to be XACMLPolicyWriterWithPapNotify since it is already in the PAP //and this transaction is intercepted up stream. - InputStream inputStream = null; - try { - inputStream = XACMLPolicyWriter.getXmlAsInputStream((PolicyType) policyData); + + try(InputStream inputStream = XACMLPolicyWriter.getXmlAsInputStream((PolicyType) policyData)) { PolicyDef policyDef = DOMPolicyDef.load(inputStream); if (policyDef == null) { success.put("validation", "PolicyDef Validation Failed"); @@ -283,13 +282,6 @@ public abstract class Policy { } catch (Exception e) { LOGGER.error("PolicyDef Validation failed"+e); success.put("error", "Validation Failed"); - }finally{ - try { - if(inputStream != null) - inputStream.close(); - } catch (IOException e) { - LOGGER.error("Exception Occured while closing the input stream"+e); - } } } else { PolicyLogger.error("Unknown data type sent back.");