From 92febb7abd1e6dfe89633d3d92cd70fabf5f0434 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 8 Jul 2019 12:38:53 -0400 Subject: Fix policy/engine due to sonar changes in common Fixed breakages due to changes made in policy/common to satisfy sonar. Change-Id: I88090c7549ba19f9eb45fae311e8811e39f30318 Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn --- .../policy/pdp/rest/XACMLPdpRegisterThread.java | 18 ++++---- .../org/onap/policy/pdp/rest/XACMLPdpServlet.java | 54 +++++++++++----------- .../onap/policy/pdp/rest/XACMLPdpServletTest.java | 6 +-- 3 files changed, 39 insertions(+), 39 deletions(-) (limited to 'ONAP-PDP-REST') diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpRegisterThread.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpRegisterThread.java index b33c4bd16..66a74a44f 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpRegisterThread.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpRegisterThread.java @@ -2,15 +2,15 @@ * ============LICENSE_START======================================================= * ONAP-PDP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved. * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,20 +42,20 @@ import org.onap.policy.rest.XACMLRestProperties; import org.onap.policy.xacml.api.XACMLErrorConstants; import com.att.research.xacml.util.XACMLProperties; -import org.onap.policy.common.logging.ONAPLoggingContext; +import org.onap.policy.common.logging.OnapLoggingContext; import org.onap.policy.common.logging.eelf.PolicyLogger; -import org.onap.policy.common.logging.flexlogger.*; +import org.onap.policy.common.logging.flexlogger.*; public class XACMLPdpRegisterThread implements Runnable { private static final Logger LOGGER = FlexLogger.getLogger(XACMLPdpRegisterThread.class); private static final Logger auditLogger = FlexLogger.getLogger("auditLogger"); - private ONAPLoggingContext baseLoggingContext = null; + private OnapLoggingContext baseLoggingContext = null; public volatile boolean isRunning = false; - public XACMLPdpRegisterThread(ONAPLoggingContext baseLoggingContext) { + public XACMLPdpRegisterThread(OnapLoggingContext baseLoggingContext) { this.baseLoggingContext = baseLoggingContext; } @@ -78,7 +78,7 @@ public class XACMLPdpRegisterThread implements Runnable { this.isRunning = true; } // get a new logging context for the thread - ONAPLoggingContext loggingContext = new ONAPLoggingContext(baseLoggingContext); + OnapLoggingContext loggingContext = new OnapLoggingContext(baseLoggingContext); loggingContext.setServiceName("PDP:PAP.register"); //are we registered with at least one boolean registered = false; @@ -124,7 +124,7 @@ public class XACMLPdpRegisterThread implements Runnable { // each time through the inner loop (which handles redirects) is a // continuation of the same transaction. UUID requestID = UUID.randomUUID(); - loggingContext.setRequestID(requestID.toString()); + loggingContext.setRequestId(requestID.toString()); //PolicyLogger.info("Request Id generated in XACMLPdpRegisterThread under XACML-PDP-REST"); loggingContext.transactionStarted(); // diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java index c86e21c09..c3f0cac46 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java @@ -20,17 +20,6 @@ package org.onap.policy.pdp.rest; -import com.att.research.xacml.api.Request; -import com.att.research.xacml.api.Response; -import com.att.research.xacml.api.pap.PDPStatus.Status; -import com.att.research.xacml.api.pdp.PDPEngine; -import com.att.research.xacml.api.pdp.PDPException; -import com.att.research.xacml.std.dom.DOMRequest; -import com.att.research.xacml.std.dom.DOMResponse; -import com.att.research.xacml.std.json.JSONRequest; -import com.att.research.xacml.std.json.JSONResponse; -import com.att.research.xacml.util.XACMLProperties; -import com.fasterxml.jackson.databind.ObjectMapper; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -64,8 +53,8 @@ import org.onap.policy.common.im.IntegrityMonitor; import org.onap.policy.common.im.IntegrityMonitorException; import org.onap.policy.common.im.IntegrityMonitorProperties; import org.onap.policy.common.im.StandbyStatusException; -import org.onap.policy.common.logging.ONAPLoggingContext; -import org.onap.policy.common.logging.ONAPLoggingUtils; +import org.onap.policy.common.logging.OnapLoggingContext; +import org.onap.policy.common.logging.OnapLoggingUtils; import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.eelf.PolicyLogger; import org.onap.policy.pdp.rest.jmx.PdpRestMonitor; @@ -75,6 +64,17 @@ import org.onap.policy.utils.PeCryptoUtils; import org.onap.policy.xacml.api.XACMLErrorConstants; import org.onap.policy.xacml.pdp.std.functions.PolicyList; import org.onap.policy.xacml.std.pap.StdPDPStatus; +import com.att.research.xacml.api.Request; +import com.att.research.xacml.api.Response; +import com.att.research.xacml.api.pap.PDPStatus.Status; +import com.att.research.xacml.api.pdp.PDPEngine; +import com.att.research.xacml.api.pdp.PDPException; +import com.att.research.xacml.std.dom.DOMRequest; +import com.att.research.xacml.std.dom.DOMResponse; +import com.att.research.xacml.std.json.JSONRequest; +import com.att.research.xacml.std.json.JSONResponse; +import com.att.research.xacml.util.XACMLProperties; +import com.fasterxml.jackson.databind.ObjectMapper; /** * Servlet implementation class XacmlPdpServlet @@ -177,7 +177,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { // private static transient Thread configThread = null; private static volatile boolean configThreadTerminate = false; - private transient ONAPLoggingContext baseLoggingContext = null; + private transient OnapLoggingContext baseLoggingContext = null; private transient IntegrityMonitor im; public IntegrityMonitor getIm() { @@ -226,7 +226,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { // // Logging stuff.... // - baseLoggingContext = new ONAPLoggingContext(); + baseLoggingContext = new OnapLoggingContext(); // fixed data that will be the same in all logging output goes here try { String hostname = InetAddress.getLocalHost().getCanonicalHostName(); @@ -281,7 +281,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "Failed to create IntegrityMonitor" + e); throw new ServletException(e); } - + try { System.setProperty("msToscaModel.home", properties.getProperty("msToscaModel.home")); } catch (Exception e) { @@ -291,7 +291,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { startThreads(baseLoggingContext, new Thread(this)); } - private static void startThreads(ONAPLoggingContext baseLoggingContext, Thread thread) { + private static void startThreads(OnapLoggingContext baseLoggingContext, Thread thread) { environment = XACMLProperties.getProperty("ENVIRONMENT", "DEVL"); // // Kick off our thread to register with the PAP servlet. @@ -426,11 +426,11 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { @Override protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - ONAPLoggingContext loggingContext = ONAPLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext); + OnapLoggingContext loggingContext = OnapLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext); loggingContext.transactionStarted(); - if ((loggingContext.getRequestID() == null) || "".equals(loggingContext.getRequestID())) { + if ((loggingContext.getRequestId() == null) || "".equals(loggingContext.getRequestId())) { UUID requestID = UUID.randomUUID(); - loggingContext.setRequestID(requestID.toString()); + loggingContext.setRequestId(requestID.toString()); PolicyLogger.info("requestID not provided in call to XACMLPdpSrvlet (doPut) so we generated one"); } else { PolicyLogger.info("requestID was provided in call to XACMLPdpSrvlet (doPut)"); @@ -509,7 +509,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { } protected void doPutConfig(String config, HttpServletRequest request, HttpServletResponse response, - ONAPLoggingContext loggingContext) throws IOException { + OnapLoggingContext loggingContext) throws IOException { try { // prevent multiple configuration changes from stacking up logger.info("XACMLPdpServlet: checking remainingCapacity of Queue."); @@ -642,11 +642,11 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - ONAPLoggingContext loggingContext = ONAPLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext); + OnapLoggingContext loggingContext = OnapLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext); loggingContext.transactionStarted(); - if ((loggingContext.getRequestID() == null) || (loggingContext.getRequestID() == "")) { + if ((loggingContext.getRequestId() == null) || (loggingContext.getRequestId() == "")) { UUID requestID = UUID.randomUUID(); - loggingContext.setRequestID(requestID.toString()); + loggingContext.setRequestId(requestID.toString()); PolicyLogger.info("requestID not provided in call to XACMLPdpSrvlet (doGet) so we generated one"); } else { PolicyLogger.info("requestID was provided in call to XACMLPdpSrvlet (doGet)"); @@ -825,12 +825,12 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - ONAPLoggingContext loggingContext = ONAPLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext); + OnapLoggingContext loggingContext = OnapLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext); loggingContext.transactionStarted(); loggingContext.setServiceName("PDP.decide"); - if ((loggingContext.getRequestID() == null) || ("".equals(loggingContext.getRequestID()))) { + if ((loggingContext.getRequestId() == null) || ("".equals(loggingContext.getRequestId()))) { UUID requestID = UUID.randomUUID(); - loggingContext.setRequestID(requestID.toString()); + loggingContext.setRequestId(requestID.toString()); PolicyLogger.info("requestID not provided in call to XACMLPdpSrvlet (doPost) so we generated one"); } else { PolicyLogger.info("requestID was provided in call to XACMLPdpSrvlet (doPost)"); diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java index 14c231aed..17601a280 100644 --- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java +++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-PDP-REST * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2019 Samsung * ================================================================================ @@ -41,7 +41,7 @@ import org.mockito.Mockito; import org.onap.policy.common.ia.IntegrityAuditProperties; import org.onap.policy.common.im.IntegrityMonitor; import org.onap.policy.common.im.IntegrityMonitorException; -import org.onap.policy.common.logging.ONAPLoggingContext; +import org.onap.policy.common.logging.OnapLoggingContext; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.xacml.std.pap.StdPDPPolicy; @@ -223,7 +223,7 @@ public class XACMLPdpServletTest extends TestCase { public void testXACMLPdpRegisterThread() { LOGGER.info("XACMLPdpServletTest - testXACMLPdpRegisterThread"); try { - ONAPLoggingContext baseLoggingContext = new ONAPLoggingContext(); + OnapLoggingContext baseLoggingContext = new OnapLoggingContext(); baseLoggingContext.setServer("localhost"); XACMLPdpRegisterThread regThread = new XACMLPdpRegisterThread(baseLoggingContext); regThread.run(); -- cgit 1.2.3-korg