X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2FXACMLPapServlet.java;h=d6c29873167002fd24afe43a31a2929df745f70a;hp=4f65e26a0b5bbc954f82e98fa76c2acb3ed0d652;hb=989ae85e3a25e059cb963a9bc293526be51273ca;hpb=948367c08eb34ebaac24601cfc2b249b11925255 diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java index 4f65e26a0..d6c298731 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java @@ -1419,12 +1419,10 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList //If the selected policy is in the group we must remove the old version of it LOGGER.info("Removing old version of the policy"); for(PDPPolicy existingPolicy : currentPoliciesInGroup) { - if (existingPolicy.getName().equals(policy.getName())){ - if (!existingPolicy.getId().equals(policy.getId())) { - group.removePolicy(existingPolicy); - LOGGER.info("Removing policy: " + existingPolicy); - break; - } + if (existingPolicy.getName().equals(policy.getName()) && !existingPolicy.getId().equals(policy.getId())){ + group.removePolicy(existingPolicy); + LOGGER.info("Removing policy: " + existingPolicy); + break; } } @@ -1618,12 +1616,10 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList */ if(apiflag != null){ - // get the request content into a String - String json = null; // read the inputStream into a buffer java.util.Scanner scanner = new java.util.Scanner(request.getInputStream()); scanner.useDelimiter("\\A"); - json = scanner.hasNext() ? scanner.next() : ""; + String json = scanner.hasNext() ? scanner.next() : ""; scanner.close(); LOGGER.info("PushPolicy API request: " + json); @@ -1671,7 +1667,9 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList } //delete temporary policy file from the bin directory - Files.deleteIfExists(Paths.get(policy.getId())); + if(policy != null) { + Files.deleteIfExists(Paths.get(policy.getId())); + } } } catch (Exception e) { @@ -2622,10 +2620,8 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList public UpdatePDPThread(OnapPDP pdp, ONAPLoggingContext loggingContext) { this.pdp = pdp; - if (!(loggingContext == null)) { - if (!(loggingContext.getRequestID() == null) || (loggingContext.getRequestID() == "")) { + if ((loggingContext != null) && (loggingContext.getRequestID() != null || loggingContext.getRequestID() == "")) { this.requestId = loggingContext.getRequestID(); - } } this.loggingContext = loggingContext; } @@ -2635,7 +2631,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList HttpURLConnection connection = null; // get a new logging context for the thread try { - if (this.loggingContext.equals(null)) { + if (this.loggingContext == null) { loggingContext = new ONAPLoggingContext(baseLoggingContext); } } catch (Exception e) {