CHeckstyle and JUnit for base package in ONAP-REST
[policy/engine.git] / ONAP-PDP-REST / src / main / java / org / onap / policy / pdp / rest / XACMLPdpRegisterThread.java
index b33c4bd..56d82bd 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.
@@ -37,25 +37,25 @@ import java.util.UUID;
 
 import org.apache.commons.io.IOUtils;
 import org.onap.policy.pdp.rest.XACMLPdpServlet.PutRequest;
-import org.onap.policy.rest.XACMLRestProperties;
+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;
@@ -86,7 +86,7 @@ public class XACMLPdpRegisterThread implements Runnable {
         /*
         int seconds;
         try {
-            seconds = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_REGISTER_SLEEP));
+            seconds = Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_REGISTER_SLEEP));
         } catch (NumberFormatException e) {
             LOGGER.error( XACMLErrorConstants.ERROR_SYSTEM_ERROR +"REGISTER_SLEEP: ", e);
             seconds = 5;
@@ -96,7 +96,7 @@ public class XACMLPdpRegisterThread implements Runnable {
         }
         int retries;
         try {
-            retries = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_REGISTER_RETRIES));
+            retries = Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_REGISTER_RETRIES));
         } catch (NumberFormatException e) {
             LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR +" REGISTER_SLEEP: ", e);
             retries = -1;
@@ -124,13 +124,13 @@ 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();
                 //
                 // Get the list of PAP Servlet URLs from the property file
                 //
-                //String papUrlList = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL);
+                //String papUrlList = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_URL);
                 //String[] papUrls = papUrlList.split(",");
                 //PapUrlResolver.setPapUrls(papUrls);
                 URL url = new URL(papUrls.getUrl());
@@ -149,8 +149,8 @@ public class XACMLPdpRegisterThread implements Runnable {
                     connection.setRequestProperty("Authorization", "Basic " + encoding);
                     connection.setRequestProperty("Accept", "text/x-java-properties");
                     connection.setRequestProperty("Content-Type", "text/x-java-properties");
-                    connection.setRequestProperty(XACMLRestProperties.PROP_PDP_HTTP_HEADER_ID, XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_ID));
-                    connection.setRequestProperty(XACMLRestProperties.PROP_PDP_HTTP_HEADER_JMX_PORT, XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_JMX_PORT));
+                    connection.setRequestProperty(XacmlRestProperties.PROP_PDP_HTTP_HEADER_ID, XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_ID));
+                    connection.setRequestProperty(XacmlRestProperties.PROP_PDP_HTTP_HEADER_JMX_PORT, XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_JMX_PORT));
                     connection.setRequestProperty("X-ECOMP-RequestID", requestID.toString());
                     connection.setUseCaches(false);
                     //