Fix policy/engine due to sonar changes in common 47/91047/1
authorJim Hahn <jrh3@att.com>
Mon, 8 Jul 2019 16:38:53 +0000 (12:38 -0400)
committerJim Hahn <jrh3@att.com>
Mon, 8 Jul 2019 16:38:53 +0000 (12:38 -0400)
Fixed breakages due to changes made in policy/common to satisfy
sonar.

Change-Id: I88090c7549ba19f9eb45fae311e8811e39f30318
Issue-ID: POLICY-1791
Signed-off-by: Jim Hahn <jrh3@att.com>
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/ConsoleAndApiService.java
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/UpdatePdpThread.java
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/APIRequestHandler.java
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandler.java
ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/ConsoleAndApiServiceTest.java
ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandlerTest.java
ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpRegisterThread.java
ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java
ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java
ONAP-PDP/src/test/java/org/onap/policy/xacml/action/FindActionTest.java

index 52e4060..bde5e5f 100644 (file)
@@ -35,7 +35,7 @@ import java.util.Set;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import org.onap.policy.common.logging.ONAPLoggingContext;
+import org.onap.policy.common.logging.OnapLoggingContext;
 import org.onap.policy.common.logging.eelf.MessageCodes;
 import org.onap.policy.common.logging.eelf.PolicyLogger;
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
@@ -79,7 +79,7 @@ public class ConsoleAndApiService {
      * @throws IOException Signals that an I/O exception has occurred.
      */
     public void doAcPost(HttpServletRequest request, HttpServletResponse response, String groupId,
-            ONAPLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
+            OnapLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
         PolicyDBDaoTransaction doAcPostTransaction = null;
         try {
             String groupName = request.getParameter("groupName");
@@ -370,7 +370,7 @@ public class ConsoleAndApiService {
      * @throws IOException Signals that an I/O exception has occurred.
      */
     public void doAcGet(HttpServletRequest request, HttpServletResponse response, String groupId,
-            ONAPLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
+            OnapLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
         try {
             String parameterDefault = request.getParameter("default");
             String pdpId = request.getParameter("pdpId");
@@ -572,7 +572,7 @@ public class ConsoleAndApiService {
      * @throws IOException Signals that an I/O exception has occurred.
      */
     public void doAcPut(HttpServletRequest request, HttpServletResponse response, String groupId,
-            ONAPLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
+            OnapLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
         PolicyDBDaoTransaction acPutTransaction = XACMLPapServlet.getPolicyDbDao().getNewTransaction();
         try {
             String userId = request.getParameter("userId");
@@ -816,7 +816,7 @@ public class ConsoleAndApiService {
      * @throws IOException Signals that an I/O exception has occurred.
      */
     public void doAcDelete(HttpServletRequest request, HttpServletResponse response, String groupId,
-            ONAPLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
+            OnapLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
         PolicyDBDaoTransaction removePdpOrGroupTransaction = XACMLPapServlet.getPolicyDbDao().getNewTransaction();
         try {
             // for all DELETE operations the group must exist before the
index 11576d3..c912a80 100644 (file)
@@ -28,7 +28,7 @@ import java.net.URL;
 import java.util.List;
 import java.util.Properties;
 import java.util.UUID;
-import org.onap.policy.common.logging.ONAPLoggingContext;
+import org.onap.policy.common.logging.OnapLoggingContext;
 import org.onap.policy.common.logging.eelf.MessageCodes;
 import org.onap.policy.common.logging.eelf.PolicyLogger;
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
@@ -39,14 +39,14 @@ import org.onap.policy.xacml.api.pap.OnapPDP;
 public class UpdatePdpThread implements Runnable {
 
     private static final Logger LOGGER = FlexLogger.getLogger(UpdatePdpThread.class);
-    private ONAPLoggingContext baseLoggingContext = new XACMLPapServlet().getBaseLoggingContext();
+    private OnapLoggingContext baseLoggingContext = new XACMLPapServlet().getBaseLoggingContext();
     private static final Logger auditLogger = FlexLogger.getLogger("auditLogger");
     private static final String XACMLPAPSERVLET = "XACMLPapServlet";
     private static final String MESSAGE = "  message: ";
 
     private OnapPDP pdp;
     private String requestId;
-    private ONAPLoggingContext loggingContext;
+    private OnapLoggingContext loggingContext;
     private List<Properties> properties;
 
 
@@ -62,11 +62,11 @@ public class UpdatePdpThread implements Runnable {
      * @param loggingContext the logging context
      * @param properties the properties
      */
-    public UpdatePdpThread(OnapPDP pdp, ONAPLoggingContext loggingContext, List<Properties> properties) {
+    public UpdatePdpThread(OnapPDP pdp, OnapLoggingContext loggingContext, List<Properties> properties) {
         this.pdp = pdp;
         if (loggingContext != null
-                && (loggingContext.getRequestID() != null || "".equals(loggingContext.getRequestID()))) {
-            this.requestId = loggingContext.getRequestID();
+                && (loggingContext.getRequestId() != null || "".equals(loggingContext.getRequestId()))) {
+            this.requestId = loggingContext.getRequestId();
         }
         this.loggingContext = loggingContext;
         this.properties = properties;
@@ -79,7 +79,7 @@ public class UpdatePdpThread implements Runnable {
         // get a new logging context for the thread
         try {
             if (this.loggingContext == null) {
-                loggingContext = new ONAPLoggingContext(baseLoggingContext);
+                loggingContext = new OnapLoggingContext(baseLoggingContext);
             }
         } catch (Exception e) {
             PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, XACMLPAPSERVLET,
@@ -95,14 +95,14 @@ public class UpdatePdpThread implements Runnable {
             // post to loggingContext to be used later when calling PDP
             if (requestId == null || "".equals(requestId)) {
                 UUID requestId = UUID.randomUUID();
-                loggingContext.setRequestID(requestId.toString());
+                loggingContext.setRequestId(requestId.toString());
                 PolicyLogger
                         .info("requestID not provided in call to XACMLPapSrvlet (UpdatePDPThread) so we generated one: "
-                                + loggingContext.getRequestID());
+                                + loggingContext.getRequestId());
             } else {
-                loggingContext.setRequestID(requestId);
+                loggingContext.setRequestId(requestId);
                 PolicyLogger.info("requestID was provided in call to XACMLPapSrvlet (UpdatePDPThread):  "
-                        + loggingContext.getRequestID());
+                        + loggingContext.getRequestId());
             }
             loggingContext.transactionStarted();
             // the Id of the PDP is its URL
@@ -120,7 +120,7 @@ public class UpdatePdpThread implements Runnable {
                 connection.setRequestProperty("Authorization", "Basic " + encoding);
             }
             connection.setRequestProperty("Content-Type", "text/x-java-properties");
-            connection.setRequestProperty("X-ECOMP-RequestID", loggingContext.getRequestID());
+            connection.setRequestProperty("X-ECOMP-RequestID", loggingContext.getRequestId());
             connection.setInstanceFollowRedirects(true);
             connection.setDoOutput(true);
             if (!writePropertiesToStream(connection)) {
index 85315ca..8dc52b8 100644 (file)
 
 package org.onap.policy.pap.xacml.rest;
 
-import com.att.research.xacml.api.pap.PAPException;
-import com.att.research.xacml.api.pap.PDPPolicy;
-import com.att.research.xacml.api.pap.PDPStatus;
-import com.att.research.xacml.util.FactoryException;
-import com.att.research.xacml.util.XACMLProperties;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.base.Splitter;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -59,8 +52,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.common.logging.flexlogger.FlexLogger;
@@ -87,6 +80,13 @@ import org.onap.policy.xacml.std.pap.StdPDPGroup;
 import org.onap.policy.xacml.std.pap.StdPDPItemSetChangeNotifier.StdItemSetChangeListener;
 import org.onap.policy.xacml.std.pap.StdPDPPolicy;
 import org.onap.policy.xacml.std.pap.StdPDPStatus;
+import com.att.research.xacml.api.pap.PAPException;
+import com.att.research.xacml.api.pap.PDPPolicy;
+import com.att.research.xacml.api.pap.PDPStatus;
+import com.att.research.xacml.util.FactoryException;
+import com.att.research.xacml.util.XACMLProperties;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Splitter;
 
 /**
  * Servlet implementation class XacmlPapServlet.
@@ -158,7 +158,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
      * this servlet starts. Its configurable by the admin.
      */
     private static transient Thread initiateThread = null;
-    private transient ONAPLoggingContext baseLoggingContext = null;
+    private transient OnapLoggingContext baseLoggingContext = null;
     private static final String GROUPID = "groupId";
 
     /**
@@ -175,7 +175,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
     public void init(ServletConfig config) throws ServletException {
         try {
             // Logging
-            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();
@@ -546,8 +546,8 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
     @Override
     protected void doPost(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException {
-        ONAPLoggingContext loggingContext =
-                ONAPLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
+        OnapLoggingContext loggingContext =
+                OnapLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
         setLoggingContext(loggingContext, "doPost", "PAP.post");
         PolicyDBDaoTransaction pdpTransaction = null;
         try {
@@ -810,8 +810,8 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
     @Override
     protected void doGet(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException {
-        ONAPLoggingContext loggingContext =
-                ONAPLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
+        OnapLoggingContext loggingContext =
+                OnapLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
         setLoggingContext(loggingContext, "doGet", "PAP.get");
         loggingContext.metricStarted();
         XACMLRest.dumpRequest(request);
@@ -1017,8 +1017,8 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
     @Override
     protected void doPut(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException {
-        ONAPLoggingContext loggingContext =
-                ONAPLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
+        OnapLoggingContext loggingContext =
+                OnapLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
         setLoggingContext(loggingContext, "doPut", "PAP.put");
         try {
             loggingContext.metricStarted();
@@ -1234,8 +1234,8 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
     @Override
     protected void doDelete(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException {
-        ONAPLoggingContext loggingContext =
-                ONAPLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
+        OnapLoggingContext loggingContext =
+                OnapLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
         setLoggingContext(loggingContext, "doDelete", "PAP.delete");
         try {
             loggingContext.metricStarted();
@@ -1397,7 +1397,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
      * @throws IOException
      */
     public void updateGroupsFromAPI(HttpServletRequest request, HttpServletResponse response,
-            String groupId, ONAPLoggingContext loggingContext) throws IOException {
+            String groupId, OnapLoggingContext loggingContext) throws IOException {
         PolicyDBDaoTransaction acPutTransaction = policyDbDao.getNewTransaction();
         PolicyLogger.audit("PolicyDBDaoTransaction started for updateGroupsFromAPI");
         try {
@@ -1541,7 +1541,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
         }
     }
 
-    public void changed(ONAPLoggingContext loggingContext) {
+    public void changed(OnapLoggingContext loggingContext) {
         // all PDPs in all groups need to be updated/sync'd
         Set<OnapPDPGroup> groups;
         try {
@@ -1565,7 +1565,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
         }
     }
 
-    public void groupChanged(OnapPDPGroup group, ONAPLoggingContext loggingContext) {
+    public void groupChanged(OnapPDPGroup group, OnapLoggingContext loggingContext) {
         // all PDPs within one group need to be updated/sync'd
         for (OnapPDP pdp : group.getOnapPdps()) {
             pdpChanged(pdp, loggingContext, getPdpDataByGroup(group));
@@ -1585,7 +1585,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
         }
     }
 
-    public void pdpChanged(OnapPDP pdp, ONAPLoggingContext loggingContext) {
+    public void pdpChanged(OnapPDP pdp, OnapLoggingContext loggingContext) {
         // kick off a thread to do an event notification for each PDP.
         // This needs to be on a separate thread so that PDPs that do not
         // respond (down, non-existent, etc)
@@ -1604,7 +1604,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
         }
     }
 
-    private void pdpChanged(OnapPDP pdp, ONAPLoggingContext loggingContext,
+    private void pdpChanged(OnapPDP pdp, OnapLoggingContext loggingContext,
             List<Properties> pdpDataByGroup) {
         Thread t = new Thread(new UpdatePdpThread(pdp, loggingContext, pdpDataByGroup));
         if (CheckPDP.validateID(pdp.getId())) {
@@ -1622,7 +1622,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
         return dataToNotify.setPolicyConfigProperties(pdp, papEngine);
     }
 
-    private void testService(ONAPLoggingContext loggingContext, HttpServletResponse response)
+    private void testService(OnapLoggingContext loggingContext, HttpServletResponse response)
             throws IOException {
         LOGGER.info("Test request received");
         try {
@@ -1686,13 +1686,13 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
         }
     }
 
-    private void setLoggingContext(ONAPLoggingContext loggingContext, String methodType,
+    private void setLoggingContext(OnapLoggingContext loggingContext, String methodType,
             String serviceName) {
         loggingContext.transactionStarted();
         loggingContext.setServiceName(serviceName);
-        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 XACMLPapServlet ('" + methodType
                     + "') so we generated one");
         } else {
@@ -1842,11 +1842,11 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
         XACMLPapServlet.msPolicyName = msPolicyName;
     }
 
-    public ONAPLoggingContext getBaseLoggingContext() {
+    public OnapLoggingContext getBaseLoggingContext() {
         return baseLoggingContext;
     }
 
-    public void setBaseLoggingContext(ONAPLoggingContext baseLoggingContext) {
+    public void setBaseLoggingContext(OnapLoggingContext baseLoggingContext) {
         this.baseLoggingContext = baseLoggingContext;
     }
 }
index 5bea62d..46c2b11 100644 (file)
@@ -23,7 +23,7 @@ package org.onap.policy.pap.xacml.rest.handler;
 import java.io.IOException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import org.onap.policy.common.logging.ONAPLoggingContext;
+import org.onap.policy.common.logging.OnapLoggingContext;
 import org.onap.policy.pap.xacml.rest.service.ImportService;
 import org.onap.policy.pap.xacml.rest.service.MetricService;
 import org.onap.policy.xacml.api.pap.OnapPDPGroup;
@@ -97,7 +97,7 @@ public class APIRequestHandler {
      * @param apiflag the apiflag
      * @throws IOException Signals that an I/O exception has occurred.
      */
-    public void doDelete(HttpServletRequest request, HttpServletResponse response, ONAPLoggingContext loggingContext,
+    public void doDelete(HttpServletRequest request, HttpServletResponse response, OnapLoggingContext loggingContext,
             String apiflag) throws IOException {
         DeleteHandler deleteHandler = DeleteHandler.getInstance();
         if ("deletePapApi".equalsIgnoreCase(apiflag)) {
index 92e43c6..fd98279 100644 (file)
@@ -31,7 +31,7 @@ import javax.script.SimpleBindings;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import org.apache.commons.lang3.StringUtils;
-import org.onap.policy.common.logging.ONAPLoggingContext;
+import org.onap.policy.common.logging.OnapLoggingContext;
 import org.onap.policy.common.logging.eelf.MessageCodes;
 import org.onap.policy.common.logging.eelf.PolicyLogger;
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
@@ -352,7 +352,7 @@ public class DeleteHandler {
      * @throws IOException Signals that an I/O exception has occurred.
      */
     public void doApiDeleteFromPdp(HttpServletRequest request, HttpServletResponse response,
-            ONAPLoggingContext loggingContext) throws IOException {
+            OnapLoggingContext loggingContext) throws IOException {
 
         String groupId = request.getParameter("groupId");
 
@@ -449,7 +449,7 @@ public class DeleteHandler {
         }
     }
 
-    private String deletePolicyFromPdpGroup(OnapPDPGroup group, ONAPLoggingContext loggingContext, String userId) {
+    private String deletePolicyFromPdpGroup(OnapPDPGroup group, OnapLoggingContext loggingContext, String userId) {
         PolicyDBDaoTransaction acPutTransaction = XACMLPapServlet.getDbDaoTransaction();
         String response = null;
         loggingContext.setServiceName("API:PAP.DeleteHandler");
index 0cd70f9..49120a0 100644 (file)
@@ -46,7 +46,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.mockito.Mockito;
-import org.onap.policy.common.logging.ONAPLoggingContext;
+import org.onap.policy.common.logging.OnapLoggingContext;
 import org.onap.policy.pap.xacml.rest.components.ConfigPolicy;
 import org.onap.policy.pap.xacml.rest.components.Policy;
 import org.onap.policy.pap.xacml.rest.components.PolicyDBDao;
@@ -83,7 +83,7 @@ public class ConsoleAndApiServiceTest {
     private static final String USER_ID = "userId";
     private static final String APIFLAG = "apiflag";
     private static final String ENVIRONMENT_HEADER = "Environment";
-    private static final ONAPLoggingContext logContext = Mockito.mock(ONAPLoggingContext.class);
+    private static final OnapLoggingContext logContext = Mockito.mock(OnapLoggingContext.class);
     private static PolicyDBDao dbd;
     private static StdEngine stdEngine = null;
     private static SessionFactory sessionFactory = null;
index 7354003..008f262 100644 (file)
@@ -37,7 +37,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
-import org.onap.policy.common.logging.ONAPLoggingContext;
+import org.onap.policy.common.logging.OnapLoggingContext;
 import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
 import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
 import org.onap.policy.pap.xacml.rest.elk.client.PolicyElasticSearchController;
@@ -102,7 +102,7 @@ public class DeleteHandlerTest {
                }
 
         // Test deletion from PDP
-        ONAPLoggingContext loggingContext = Mockito.mock(ONAPLoggingContext.class);
+        OnapLoggingContext loggingContext = Mockito.mock(OnapLoggingContext.class);
         try {
             handler.doApiDeleteFromPdp(request, response, loggingContext);
         }
index b33c4bd..66a74a4 100644 (file)
@@ -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();
                 //
index c86e21c..c3f0cac 100644 (file)
 
 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)");
index 14c231a..17601a2 100644 (file)
@@ -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();
index 5403f8f..f8729d6 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP-PDP
  * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,6 +46,7 @@ import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
 import org.onap.policy.common.utils.network.NetworkUtil;
 import org.onap.policy.xacml.custom.OnapFunctionDefinitionFactory;
 
@@ -68,8 +69,8 @@ public class FindActionTest {
     @BeforeClass
     public static void setUpServer() {
         try {
-            final HttpServletServer testServer =
-                    HttpServletServer.factory.build("dmaapSim", "localhost", MOCK_SERVER_PORT, "/", false, true);
+            final HttpServletServer testServer = HttpServletServerFactoryInstance.getServerFactory().build("dmaapSim",
+                            "localhost", MOCK_SERVER_PORT, "/", false, true);
             testServer.addServletClass("/*", DummyRest.class.getName());
             testServer.waitedStart(2000);
             if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L)) {
@@ -83,7 +84,7 @@ public class FindActionTest {
 
     @AfterClass
     public static void tearDownSimulator() {
-        HttpServletServer.factory.destroy();
+        HttpServletServerFactoryInstance.getServerFactory().destroy();
     }
 
     /**