Consolidate PolicyRestAdapter setup
[policy/engine.git] / ONAP-PAP-REST / src / main / java / org / onap / policy / pap / xacml / rest / XACMLPapServlet.java
index 30d09ed..5805420 100644 (file)
@@ -27,6 +27,7 @@ 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;
@@ -42,8 +43,7 @@ import java.util.Properties;
 import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.CopyOnWriteArrayList;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
+
 import javax.persistence.PersistenceException;
 import javax.servlet.Servlet;
 import javax.servlet.ServletConfig;
@@ -53,6 +53,7 @@ import javax.servlet.annotation.WebServlet;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+
 import org.apache.commons.io.IOUtils;
 import org.onap.policy.common.ia.IntegrityAudit;
 import org.onap.policy.common.im.AdministrativeStateException;
@@ -61,8 +62,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;
@@ -77,7 +78,7 @@ import org.onap.policy.pap.xacml.restAuth.CheckPDP;
 import org.onap.policy.rest.XACMLRest;
 import org.onap.policy.rest.XACMLRestProperties;
 import org.onap.policy.rest.dao.PolicyDBException;
-import org.onap.policy.utils.CryptoUtils;
+import org.onap.policy.utils.PeCryptoUtils;
 import org.onap.policy.utils.PolicyUtils;
 import org.onap.policy.xacml.api.XACMLErrorConstants;
 import org.onap.policy.xacml.api.pap.ONAPPapEngineFactory;
@@ -91,10 +92,15 @@ import org.onap.policy.xacml.std.pap.StdPDPPolicy;
 import org.onap.policy.xacml.std.pap.StdPDPStatus;
 
 /**
- * Servlet implementation class XacmlPapServlet
+ * Servlet implementation class XacmlPapServlet.
  */
-@WebServlet(description = "Implements the XACML PAP RESTful API.", urlPatterns = {"/"}, loadOnStartup = 1,
-        initParams = {@WebInitParam(name = "XACML_PROPERTIES_NAME", value = "xacml.pap.properties",
+@WebServlet(
+        description = "Implements the XACML PAP RESTful API.",
+        urlPatterns = {"/"},
+        loadOnStartup = 1,
+        initParams = {@WebInitParam(
+                name = "XACML_PROPERTIES_NAME",
+                value = "xacml.pap.properties",
                 description = "The location of the properties file holding configuration information.")})
 public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeListener, Runnable {
     private static final long serialVersionUID = 1L;
@@ -114,23 +120,22 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
     /*
      * List of Admin Console URLs. Used to send notifications when configuration changes.
      *
-     * The CopyOnWriteArrayList *should* protect from concurrency errors. This list is seldom changed
-     * but often read, so the costs of this approach make sense.
+     * The CopyOnWriteArrayList *should* protect from concurrency errors. This list is seldom
+     * changed but often read, so the costs of this approach make sense.
      */
     private static final CopyOnWriteArrayList<String> adminConsoleURLStringList = new CopyOnWriteArrayList<>();
 
     private static String configHome;
     private static String actionHome;
     /*
-     * This PAP instance's own URL. Need this when creating URLs to send to the PDPs so they can GET the
-     * Policy files from this process.
+     * This PAP instance's own URL. Need this when creating URLs to send to the PDPs so they can GET
+     * the Policy files from this process.
      */
-    public static String papURL = null;
+    private static String papUrl = null;
     // The heartbeat thread.
     private static Heartbeat heartbeat = null;
     private static Thread heartbeatThread = null;
-    private static EntityManagerFactory emf;
-    public static PolicyDBDao policyDBDao;
+    private static PolicyDBDao policyDbDao;
     /*
      * papEngine - This is our engine workhorse that manages the PDP Groups and Nodes.
      */
@@ -159,7 +164,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";
 
     /**
@@ -176,7 +181,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();
@@ -258,19 +263,18 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
             // Create an IntegrityMonitor
             if (properties.getProperty(PERSISTENCE_JDBC_PWD) != null) {
                 properties.setProperty(PERSISTENCE_JDBC_PWD,
-                        CryptoUtils.decryptTxtNoExStr(properties.getProperty(PERSISTENCE_JDBC_PWD, "")));
+                        PeCryptoUtils.decrypt(properties.getProperty(PERSISTENCE_JDBC_PWD, "")));
             }
             im = IntegrityMonitor.getInstance(papResourceName, properties);
             // Create an IntegrityAudit
             ia = new IntegrityAudit(papResourceName, AUDIT_PAP_PERSISTENCE_UNIT, properties);
             ia.startAuditThread();
-
             // we are about to call the PDPs and give them their configuration.
             // To do that we need to have the URL of this PAP so we can
             // construct the Policy file URLs
-            setPAPURL(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL));
+            setPapUrl(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL));
             // Create the policyDBDao
-            setPolicyDBDao();
+            setPolicyDbDao();
             // Load our PAP engine, first create a factory
             ONAPPapEngineFactory factory = ONAPPapEngineFactory
                     .newInstance(XACMLProperties.getProperty(XACMLProperties.PROP_PAP_PAPENGINEFACTORY));
@@ -279,20 +283,21 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
             if (((org.onap.policy.xacml.std.pap.StdEngine) papEngine).wasDefaultGroupJustAdded) {
                 createDefaultGroupOnInit();
             }
-            policyDBDao.setPapEngine(XACMLPapServlet.papEngine);
+            policyDbDao.setPapEngine(XACMLPapServlet.papEngine);
             if (Boolean.parseBoolean(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_RUN_AUDIT_FLAG))) {
                 /*
                  * Auditing the local File System groups to be in sync with the Database
                  */
 
                 // get an AuditTransaction to lock out all other transactions
-                PolicyDBDaoTransaction auditTrans = policyDBDao.getNewAuditTransaction();
+                PolicyDBDaoTransaction auditTrans = policyDbDao.getNewAuditTransaction();
 
                 LOGGER.info("PapServlet: calling auditLocalFileSystem for PDP group audit");
                 LOGGER.info("PapServlet: old group is " + papEngine.getDefaultGroup().toString());
-                // get the current filesystem group and update from the database if needed
+                // get the current filesystem group and update from the database
+                // if needed
                 StdPDPGroup group = (StdPDPGroup) papEngine.getDefaultGroup();
-                StdPDPGroup updatedGroup = policyDBDao.auditLocalFileSystem(group);
+                StdPDPGroup updatedGroup = policyDbDao.auditLocalFileSystem(group);
                 if (updatedGroup != null) {
                     papEngine.updateGroup(updatedGroup);
                 }
@@ -300,7 +305,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
 
                 // sync up the config data from DB to file system
                 LOGGER.info("PapServlet:  Sync config data from DB to file system");
-                policyDBDao.synchronizeConfigDataInFileSystem();
+                policyDbDao.synchronizeConfigDataInFileSystem();
 
                 // release the transaction lock
                 auditTrans.close();
@@ -330,11 +335,11 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
     private void createDefaultGroupOnInit() {
         PolicyDBDaoTransaction addNewGroup = null;
         try {
-            addNewGroup = policyDBDao.getNewTransaction();
+            addNewGroup = policyDbDao.getNewTransaction();
             OnapPDPGroup group = papEngine.getDefaultGroup();
             addNewGroup.createGroup(group.getId(), group.getName(), group.getDescription(), "automaticallyAdded");
             addNewGroup.commitTransaction();
-            addNewGroup = policyDBDao.getNewTransaction();
+            addNewGroup = policyDbDao.getNewTransaction();
             addNewGroup.changeDefaultGroup(group, "automaticallyAdded");
             addNewGroup.commitTransaction();
         } catch (Exception e) {
@@ -365,25 +370,24 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
         XACMLPapServlet.heartbeatThread.start();
     }
 
-    private static void setPolicyDBDao() throws ServletException {
+    private static void setPolicyDbDao() throws ServletException {
         try {
-            policyDBDao = PolicyDBDao.getPolicyDBDaoInstance();
+            policyDbDao = PolicyDBDao.getPolicyDBDaoInstance();
         } catch (Exception e) {
             throw new ServletException("Unable to Create Policy DBDao Instance", e);
         }
     }
 
-    private static void setEMF(Properties properties) throws ServletException {
-        emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT, properties);
-        if (emf == null) {
-            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE
-                    + " Error creating entity manager factory with persistence unit: " + PERSISTENCE_UNIT);
-            throw new ServletException("Unable to create Entity Manager Factory");
-        }
+    public static PolicyDBDao getPolicyDbDao() {
+        return policyDbDao;
+    }
+
+    private static void setPapUrl(String papUrl) {
+        XACMLPapServlet.papUrl = papUrl;
     }
 
-    private static void setPAPURL(String papURL) {
-        XACMLPapServlet.papURL = papURL;
+    public static String getPapUrl() {
+        return papUrl;
     }
 
     private static void setPAPEngine(PAPPolicyEngine newEngine) {
@@ -439,8 +443,8 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
             throw new PAPException("papDbUser is null");
         }
         setPapDbUser(papDbUser);
-        papDbPd = CryptoUtils
-                .decryptTxtNoExStr(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_PASSWORD, ""));
+        PeCryptoUtils.initAesKey(XACMLProperties.getProperty(XACMLRestProperties.PROP_AES_KEY));
+        papDbPd = PeCryptoUtils.decrypt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_PASSWORD));
         if (papDbPd == null) {
             PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "XACMLPapServlet",
                     " ERROR: Bad papDbPassword property entry");
@@ -470,8 +474,9 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
     }
 
     /**
-     * Thread used only during PAP startup to initiate change messages to all known PDPs. This must be
-     * on a separate thread so that any GET requests from the PDPs during this update can be serviced.
+     * Thread used only during PAP startup to initiate change messages to all known PDPs. This must
+     * be on a separate thread so that any GET requests from the PDPs during this update can be
+     * serviced.
      */
     @Override
     public void run() {
@@ -517,15 +522,15 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
     }
 
     /**
-     * Called by: - PDP nodes to register themselves with the PAP, and - Admin Console to make changes
-     * in the PDP Groups.
+     * Called by: - PDP nodes to register themselves with the PAP, and - Admin Console to make
+     * changes in the PDP Groups.
      *
      * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
      */
     @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 {
@@ -534,9 +539,9 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
             loggingContext.metricEnded();
             PolicyLogger.metrics("XACMLPapServlet doPost im startTransaction");
         } catch (AdministrativeStateException ae) {
-            String message = "POST interface called for PAP " + papResourceName + " but it has an Administrative"
-                    + " state of " + im.getStateManager().getAdminState() + "\n Exception Message: "
-                    + PolicyUtils.CATCH_EXCEPTION;
+            String message = "POST interface called for PAP " + papResourceName
+                    + " but it has an Administrative state of " + im.getStateManager().getAdminState()
+                    + "\n Exception Message: " + PolicyUtils.CATCH_EXCEPTION;
             LOGGER.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message, ae);
             loggingContext.metricEnded();
             PolicyLogger.metrics("XACMLPapServlet doPost im startTransaction");
@@ -544,10 +549,12 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
             PolicyLogger.audit("Transaction Failed - See Error.log");
             setResponseError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
             return;
-        } catch (StandbyStatusException se) {
-            String message = "POST interface called for PAP " + papResourceName + " but it has a Standby Status"
-                    + " of " + im.getStateManager().getStandbyStatus() + "\n Exception Message: " + se.getMessage();
-            LOGGER.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message, se);
+        } catch (IntegrityMonitorException ime) {
+            String message =
+                    "POST interface called for PAP " + papResourceName + " but it has an Administrative state of "
+                            + im.getStateManager().getAdminState() + " and a Standby Status of "
+                            + im.getStateManager().getStandbyStatus() + "\n Exception Message: " + ime.getMessage();
+            LOGGER.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message, ime);
             loggingContext.metricEnded();
             PolicyLogger.metrics("XACMLPapServlet doPost im startTransaction");
             loggingContext.transactionEnded();
@@ -604,7 +611,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
                 LOGGER.info("Unknown PDP: " + id);
                 // Check PDP ID
                 if (CheckPDP.validateID(id)) {
-                    pdpTransaction = policyDBDao.getNewTransaction();
+                    pdpTransaction = policyDbDao.getNewTransaction();
                     try {
                         pdpTransaction.addPdpToGroup(id, XACMLPapServlet.papEngine.getDefaultGroup().getId(), id,
                                 "Registered on first startup", Integer.parseInt(jmxport), "PDP autoregister");
@@ -774,7 +781,7 @@ 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);
@@ -797,19 +804,12 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
             im.startTransaction();
             loggingContext.metricEnded();
             PolicyLogger.metrics("XACMLPapServlet doGet im startTransaction");
-        } catch (AdministrativeStateException ae) {
-            String message = "GET interface called for PAP " + papResourceName + " but it has an Administrative"
-                    + " state of " + im.getStateManager().getAdminState() + "\n Exception Message: " + ae.getMessage();
-            LOGGER.info(message, ae);
-            PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message);
-            loggingContext.transactionEnded();
-            PolicyLogger.audit("Transaction Failed - See Error.log");
-            setResponseError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
-            return;
-        } catch (StandbyStatusException se) {
-            String message = "GET interface called for PAP " + papResourceName + " but it has a Standby Status" + " of "
-                    + im.getStateManager().getStandbyStatus() + "\n Exception Message: " + se.getMessage();
-            LOGGER.info(message, se);
+        } catch (IntegrityMonitorException ime) {
+            String message =
+                    "GET interface called for PAP " + papResourceName + " but it has an Administrative state of "
+                            + im.getStateManager().getAdminState() + " and a Standby Status of "
+                            + im.getStateManager().getStandbyStatus() + "\n Exception Message: " + ime.getMessage();
+            LOGGER.info(message, ime);
             PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message);
             loggingContext.transactionEnded();
             PolicyLogger.audit("Transaction Failed - See Error.log");
@@ -979,7 +979,7 @@ 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();
@@ -987,17 +987,10 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
             loggingContext.metricEnded();
             PolicyLogger.metrics("XACMLPapServlet doPut im startTransaction");
         } catch (IntegrityMonitorException e) {
-            String message = "PUT interface called for PAP " + papResourceName;
-            if (e instanceof AdministrativeStateException) {
-                message += " but it has an Administrative state of " + im.getStateManager().getAdminState();
-            } else if (e instanceof StandbyStatusException) {
-                message += " but it has a Standby Status of " + im.getStateManager().getStandbyStatus();
-            } else {
-                message += " but an exception occurred";
-
-            }
-            message += "\n Exception Message: " + e.getMessage();
-
+            String message =
+                    "PUT interface called for PAP " + papResourceName + " but it has an Administrative state of "
+                            + im.getStateManager().getAdminState() + " and a Standby Status of "
+                            + im.getStateManager().getStandbyStatus() + "\n Exception Message: " + e.getMessage();
             LOGGER.info(message, e);
             PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message);
             loggingContext.transactionEnded();
@@ -1091,9 +1084,9 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
             return;
         }
         /*
-         * This is to update the PDP Group with the policy/policies being pushed Part of a 2 step process to
-         * push policies to the PDP that can now be done From both the Admin Console and the PolicyEngine
-         * API
+         * This is to update the PDP Group with the policy/policies being pushed Part of a 2 step
+         * process to push policies to the PDP that can now be done From both the Admin Console and
+         * the PolicyEngine API
          */
         String groupId = request.getParameter(GROUPID);
         if (groupId != null) {
@@ -1194,26 +1187,19 @@ 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();
             im.startTransaction();
             loggingContext.metricEnded();
             PolicyLogger.metrics("XACMLPapServlet doDelete im startTransaction");
-        } catch (AdministrativeStateException ae) {
-            String message = "DELETE interface called for PAP " + papResourceName + " but it has an Administrative"
-                    + " state of " + im.getStateManager().getAdminState() + "\n Exception Message: " + ae.getMessage();
-            LOGGER.info(message, ae);
-            PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message);
-            loggingContext.transactionEnded();
-            PolicyLogger.audit("Transaction Failed - See Error.log");
-            setResponseError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
-            return;
-        } catch (StandbyStatusException se) {
-            String message = "PUT interface called for PAP " + papResourceName + " but it has a Standby Status" + " of "
-                    + im.getStateManager().getStandbyStatus() + "\n Exception Message: " + se.getMessage();
-            LOGGER.info(message, se);
+        } catch (IntegrityMonitorException ime) {
+            String message =
+                    "DELETE interface called for PAP " + papResourceName + " but it has an Administrative state of "
+                            + im.getStateManager().getAdminState() + " and a Standby Status of "
+                            + im.getStateManager().getStandbyStatus() + "\n Exception Message: " + ime.getMessage();
+            LOGGER.info(message, ime);
             PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message);
             loggingContext.transactionEnded();
             PolicyLogger.audit("Transaction Failed - See Error.log");
@@ -1353,8 +1339,8 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
      * @throws IOException
      */
     public void updateGroupsFromAPI(HttpServletRequest request, HttpServletResponse response, String groupId,
-            ONAPLoggingContext loggingContext) throws IOException {
-        PolicyDBDaoTransaction acPutTransaction = policyDBDao.getNewTransaction();
+            OnapLoggingContext loggingContext) throws IOException {
+        PolicyDBDaoTransaction acPutTransaction = policyDbDao.getNewTransaction();
         PolicyLogger.audit("PolicyDBDaoTransaction started for updateGroupsFromAPI");
         try {
             String userId = request.getParameter("userId");
@@ -1390,7 +1376,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
             // Assume that this is an update of an existing PDP Group
             loggingContext.setServiceName("PolicyEngineAPI:PAP.updateGroup");
             try {
-                acPutTransaction.updateGroup(group, "XACMLPapServlet.doACPut", null);
+                acPutTransaction.updateGroup(group, "XACMLPapServlet.doACPut", userId);
             } catch (Exception e) {
                 PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "XACMLPapServlet",
                         " Error while updating group in the database: " + "group=" + group.getId());
@@ -1452,8 +1438,8 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
     }
 
     /*
-     * HELPER to change Group status when PDP status is changed (Must NOT be called from a method that
-     * is synchronized on the papEngine or it may deadlock)
+     * HELPER to change Group status when PDP status is changed (Must NOT be called from a method
+     * that is synchronized on the papEngine or it may deadlock)
      */
     public void setPDPSummaryStatus(OnapPDP pdp, PDPStatus.Status newStatus) throws PAPException {
         setPDPSummaryStatus(pdp, newStatus.toString());
@@ -1475,8 +1461,8 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
     }
 
     /*
-     * Callback methods telling this servlet to notify PDPs of changes made by the PAP StdEngine in the
-     * PDP group directories
+     * Callback methods telling this servlet to notify PDPs of changes made by the PAP StdEngine in
+     * the PDP group directories
      */
     @Override
     public void changed() {
@@ -1493,7 +1479,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 {
@@ -1515,7 +1501,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));
@@ -1535,7 +1521,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)
@@ -1554,7 +1540,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
         }
     }
 
-    private void pdpChanged(OnapPDP pdp, ONAPLoggingContext loggingContext, List<Properties> pdpDataByGroup) {
+    private void pdpChanged(OnapPDP pdp, OnapLoggingContext loggingContext, List<Properties> pdpDataByGroup) {
         Thread t = new Thread(new UpdatePdpThread(pdp, loggingContext, pdpDataByGroup));
         if (CheckPDP.validateID(pdp.getId())) {
             t.start();
@@ -1571,7 +1557,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
         return dataToNotify.setPolicyConfigProperties(pdp, papEngine);
     }
 
-    private void testService(ONAPLoggingContext loggingContext, HttpServletResponse response) throws IOException {
+    private void testService(OnapLoggingContext loggingContext, HttpServletResponse response) throws IOException {
         LOGGER.info("Test request received");
         try {
             im.evaluateSanity();
@@ -1633,12 +1619,12 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
         }
     }
 
-    private void setLoggingContext(ONAPLoggingContext loggingContext, String methodType, String serviceName) {
+    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 {
@@ -1715,10 +1701,6 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
         actionHome = getActionHome();
     }
 
-    public static EntityManagerFactory getEmf() {
-        return emf;
-    }
-
     public IntegrityAudit getIa() {
         return ia;
     }
@@ -1736,7 +1718,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
     }
 
     public static PolicyDBDaoTransaction getDbDaoTransaction() {
-        return policyDBDao.getNewTransaction();
+        return policyDbDao.getNewTransaction();
     }
 
     public static String getPapDbDriver() {
@@ -1787,11 +1769,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;
     }
 }