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%2FXACMLPapServlet.java;h=d6c29873167002fd24afe43a31a2929df745f70a;hb=989ae85e3a25e059cb963a9bc293526be51273ca;hp=85d79f74aee1a4412622da4cb825e7e14f42b559;hpb=709fe78e311189429a22c4ceebf20f19e89693f3;p=policy%2Fengine.git 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 85d79f74a..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 @@ -40,7 +40,6 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Properties; import java.util.Scanner; @@ -88,7 +87,6 @@ import org.onap.policy.xacml.api.pap.ONAPPapEngineFactory; import org.onap.policy.xacml.api.pap.OnapPDP; import org.onap.policy.xacml.api.pap.OnapPDPGroup; import org.onap.policy.xacml.api.pap.PAPPolicyEngine; -import org.onap.policy.xacml.std.pap.StdPAPPolicy; import org.onap.policy.xacml.std.pap.StdPDP; import org.onap.policy.xacml.std.pap.StdPDPGroup; import org.onap.policy.xacml.std.pap.StdPDPItemSetChangeNotifier.StdItemSetChangeListener; @@ -1421,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; } } @@ -1620,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); @@ -1673,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) { @@ -2624,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; } @@ -2637,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) {