From f875828ecc091dc505697ac98256ba06aff9a20a Mon Sep 17 00:00:00 2001
From: "adheli.tavares"
Date: Thu, 29 Aug 2024 15:58:06 +0100
Subject: Remove modules not being used
Remove modules common-logging, integrity-audity and
integrity-monitor as they are not being used in any component.
Issue-ID: POLICY-5123
Change-Id: I571f17236a3c8bb9e8e52c99d0298f4098cb5ca9
Signed-off-by: adheli.tavares
---
common-logging/config/policyLogger.properties | 44 -
common-logging/policyLogger.properties | 50 -
common-logging/pom.xml | 124 -
.../policy/common/logging/OnapLoggingContext.java | 567 ----
.../policy/common/logging/OnapLoggingUtils.java | 104 -
.../common/logging/eelf/DroolsPdpMdcInfo.java | 53 -
.../policy/common/logging/eelf/ErrorCodeMap.java | 117 -
.../onap/policy/common/logging/eelf/EventData.java | 80 -
.../policy/common/logging/eelf/EventTrackInfo.java | 85 -
.../common/logging/eelf/EventTrackInfoHandler.java | 96 -
.../onap/policy/common/logging/eelf/MdcInfo.java | 37 -
.../policy/common/logging/eelf/MessageCodes.java | 160 -
.../common/logging/eelf/OnapConfigProperties.java | 87 -
.../policy/common/logging/eelf/PolicyLogger.java | 1423 --------
.../common/logging/flexlogger/DisplayUtils.java | 47 -
.../common/logging/flexlogger/EelfLogger.java | 575 ----
.../common/logging/flexlogger/FlexLogger.java | 218 --
.../policy/common/logging/flexlogger/Logger.java | 249 --
.../common/logging/flexlogger/LoggerType.java | 28 -
.../common/logging/flexlogger/PropertyUtil.java | 340 --
.../common/logging/flexlogger/SystemOutLogger.java | 548 ---
.../policy/common/logging/nsa/LoggingContext.java | 64 -
.../common/logging/nsa/LoggingContextFactory.java | 53 -
.../common/logging/nsa/SharedLoggingContext.java | 37 -
.../common/logging/nsa/impl/SharedContext.java | 52 -
.../logging/nsa/impl/Slf4jLoggingContext.java | 63 -
.../policy/common/logging/nsa/package-info.java | 28 -
.../common/logging/eelf/Resources.properties | 229 --
.../common/logging/eelf/DroolsPdpMdcInfoTest.java | 43 -
.../common/logging/eelf/ErrorCodeMapTest.java | 62 -
.../policy/common/logging/eelf/EventDataTest.java | 172 -
.../logging/eelf/EventTrackInfoHandlerTest.java | 130 -
.../common/logging/eelf/EventTrackInfoTest.java | 131 -
.../common/logging/eelf/PolicyLoggerTest.java | 718 ----
.../common/logging/flexlogger/EelfLoggerTest.java | 390 ---
.../common/logging/flexlogger/FlexLoggerTest.java | 112 -
.../logging/flexlogger/PropertyUtilTest.java | 172 -
.../logging/flexlogger/SystemOutLoggerTest.java | 558 ---
integrity-audit/config/policyLogger.properties | 44 -
integrity-audit/policyLogger.properties | 44 -
integrity-audit/pom.xml | 95 -
.../org/onap/policy/common/ia/AuditThread.java | 771 -----
.../org/onap/policy/common/ia/AuditorTime.java | 54 -
.../java/org/onap/policy/common/ia/DbAudit.java | 503 ---
.../onap/policy/common/ia/DbAuditException.java | 41 -
.../main/java/org/onap/policy/common/ia/DbDao.java | 722 ----
.../common/ia/DbDaoTransactionException.java | 41 -
.../org/onap/policy/common/ia/IntegrityAudit.java | 287 --
.../policy/common/ia/IntegrityAuditException.java | 41 -
.../policy/common/ia/IntegrityAuditProperties.java | 46 -
.../ia/IntegrityAuditPropertiesException.java | 41 -
.../policy/common/ia/jpa/IntegrityAuditEntity.java | 130 -
.../src/main/resources/META-INF/persistence.xml | 47 -
.../src/main/resources/log4j.properties | 48 -
.../org/onap/policy/common/ia/AuditPeriodTest.java | 254 --
.../org/onap/policy/common/ia/AuditorTimeTest.java | 43 -
.../common/ia/DbAuditCompareEntriesTest.java | 551 ---
.../org/onap/policy/common/ia/DbAuditTest.java | 283 --
.../java/org/onap/policy/common/ia/DbDaoTest.java | 452 ---
.../common/ia/DefaultLoggingPatternTest.java | 103 -
.../org/onap/policy/common/ia/ExceptionsTest.java | 53 -
.../common/ia/IntegrityAuditDesignationTest.java | 593 ----
.../onap/policy/common/ia/IntegrityAuditTest.java | 75 -
.../policy/common/ia/IntegrityAuditTestBase.java | 658 ----
.../onap/policy/common/ia/jpa/IaTestEntity.java | 177 -
.../onap/policy/common/ia/jpa/PersonSample.java | 69 -
.../src/test/resources/log4j.properties | 54 -
.../src/test/resources/logback-test.xml | 258 --
.../src/test/resources/logger-test.expectedlog | 1 -
.../src/test/resources/policyLogger.properties | 45 -
.../src/test/resources/xlogger-test.expectedlog | 1 -
integrity-monitor/config/policyLogger.properties | 44 -
integrity-monitor/policyLogger.properties | 44 -
integrity-monitor/pom.xml | 87 -
.../common/im/AdministrativeStateException.java | 41 -
.../policy/common/im/AllSeemsWellException.java | 42 -
.../policy/common/im/ForwardProgressException.java | 41 -
.../onap/policy/common/im/IntegrityMonitor.java | 1915 -----------
.../common/im/IntegrityMonitorException.java | 47 -
.../common/im/IntegrityMonitorProperties.java | 62 -
.../im/IntegrityMonitorPropertiesException.java | 41 -
.../org/onap/policy/common/im/MonitorTime.java | 39 -
.../policy/common/im/StandbyStatusException.java | 47 -
.../onap/policy/common/im/StateChangeNotifier.java | 76 -
.../org/onap/policy/common/im/StateElement.java | 60 -
.../org/onap/policy/common/im/StateManagement.java | 551 ---
.../policy/common/im/StateManagementException.java | 42 -
.../org/onap/policy/common/im/StateTransition.java | 401 ---
.../policy/common/im/StateTransitionException.java | 42 -
.../im/exceptions/EntityRetrievalException.java | 31 -
.../onap/policy/common/im/jmx/ComponentAdmin.java | 226 --
.../common/im/jmx/ComponentAdminException.java | 44 -
.../policy/common/im/jmx/ComponentAdminMBean.java | 49 -
.../policy/common/im/jmx/JmxAgentConnection.java | 120 -
.../org/onap/policy/common/im/jpa/DateEntity.java | 71 -
.../common/im/jpa/ForwardProgressEntity.java | 70 -
.../onap/policy/common/im/jpa/ImTestEntity.java | 89 -
.../common/im/jpa/ResourceRegistrationEntity.java | 68 -
.../common/im/jpa/StateManagementEntity.java | 113 -
.../src/main/resources/META-INF/persistence.xml | 51 -
.../src/main/resources/log4j.properties | 48 -
.../onap/policy/common/im/AllSeemsWellTest.java | 209 --
.../org/onap/policy/common/im/ExceptionsTest.java | 79 -
.../policy/common/im/IntegrityMonitorTest.java | 982 ------
.../policy/common/im/IntegrityMonitorTestBase.java | 268 --
.../org/onap/policy/common/im/MonitorTimeTest.java | 43 -
.../policy/common/im/StateChangeNotifierTest.java | 49 -
.../common/im/StateManagementEntityTest.java | 138 -
.../onap/policy/common/im/StateManagementTest.java | 297 --
.../onap/policy/common/im/StateTransitionTest.java | 3566 --------------------
.../exceptions/EntityRetrievalExceptionTest.java | 37 -
.../src/test/resources/logback-test.xml | 46 -
pom.xml | 3 -
utils-test/pom.xml | 1 -
.../common/utils/security/SelfSignedKeyStore.java | 2 -
115 files changed, 24993 deletions(-)
delete mode 100644 common-logging/config/policyLogger.properties
delete mode 100644 common-logging/policyLogger.properties
delete mode 100644 common-logging/pom.xml
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingContext.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/eelf/DroolsPdpMdcInfo.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/eelf/ErrorCodeMap.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandler.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/eelf/MdcInfo.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/eelf/MessageCodes.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/eelf/OnapConfigProperties.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/DisplayUtils.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/LoggerType.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/nsa/LoggingContext.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/nsa/LoggingContextFactory.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/nsa/SharedLoggingContext.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/SharedContext.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/Slf4jLoggingContext.java
delete mode 100644 common-logging/src/main/java/org/onap/policy/common/logging/nsa/package-info.java
delete mode 100644 common-logging/src/main/resources/org/onap/policy/common/logging/eelf/Resources.properties
delete mode 100644 common-logging/src/test/java/org/onap/policy/common/logging/eelf/DroolsPdpMdcInfoTest.java
delete mode 100644 common-logging/src/test/java/org/onap/policy/common/logging/eelf/ErrorCodeMapTest.java
delete mode 100644 common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventDataTest.java
delete mode 100644 common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandlerTest.java
delete mode 100644 common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventTrackInfoTest.java
delete mode 100644 common-logging/src/test/java/org/onap/policy/common/logging/eelf/PolicyLoggerTest.java
delete mode 100644 common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/EelfLoggerTest.java
delete mode 100644 common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/FlexLoggerTest.java
delete mode 100644 common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/PropertyUtilTest.java
delete mode 100644 common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/SystemOutLoggerTest.java
delete mode 100644 integrity-audit/config/policyLogger.properties
delete mode 100644 integrity-audit/policyLogger.properties
delete mode 100644 integrity-audit/pom.xml
delete mode 100644 integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java
delete mode 100644 integrity-audit/src/main/java/org/onap/policy/common/ia/AuditorTime.java
delete mode 100644 integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java
delete mode 100644 integrity-audit/src/main/java/org/onap/policy/common/ia/DbAuditException.java
delete mode 100644 integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java
delete mode 100644 integrity-audit/src/main/java/org/onap/policy/common/ia/DbDaoTransactionException.java
delete mode 100644 integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java
delete mode 100644 integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditException.java
delete mode 100644 integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java
delete mode 100644 integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditPropertiesException.java
delete mode 100644 integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java
delete mode 100644 integrity-audit/src/main/resources/META-INF/persistence.xml
delete mode 100644 integrity-audit/src/main/resources/log4j.properties
delete mode 100644 integrity-audit/src/test/java/org/onap/policy/common/ia/AuditPeriodTest.java
delete mode 100644 integrity-audit/src/test/java/org/onap/policy/common/ia/AuditorTimeTest.java
delete mode 100644 integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditCompareEntriesTest.java
delete mode 100644 integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java
delete mode 100644 integrity-audit/src/test/java/org/onap/policy/common/ia/DbDaoTest.java
delete mode 100644 integrity-audit/src/test/java/org/onap/policy/common/ia/DefaultLoggingPatternTest.java
delete mode 100644 integrity-audit/src/test/java/org/onap/policy/common/ia/ExceptionsTest.java
delete mode 100644 integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditDesignationTest.java
delete mode 100644 integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTest.java
delete mode 100644 integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java
delete mode 100644 integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java
delete mode 100644 integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/PersonSample.java
delete mode 100644 integrity-audit/src/test/resources/log4j.properties
delete mode 100644 integrity-audit/src/test/resources/logback-test.xml
delete mode 100644 integrity-audit/src/test/resources/logger-test.expectedlog
delete mode 100644 integrity-audit/src/test/resources/policyLogger.properties
delete mode 100644 integrity-audit/src/test/resources/xlogger-test.expectedlog
delete mode 100644 integrity-monitor/config/policyLogger.properties
delete mode 100644 integrity-monitor/policyLogger.properties
delete mode 100644 integrity-monitor/pom.xml
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/AdministrativeStateException.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/AllSeemsWellException.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/ForwardProgressException.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorException.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorPropertiesException.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/MonitorTime.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/StandbyStatusException.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/StateChangeNotifier.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/StateElement.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagementException.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransition.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransitionException.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/exceptions/EntityRetrievalException.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdmin.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdminException.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdminMBean.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/JmxAgentConnection.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/DateEntity.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java
delete mode 100644 integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/StateManagementEntity.java
delete mode 100644 integrity-monitor/src/main/resources/META-INF/persistence.xml
delete mode 100644 integrity-monitor/src/main/resources/log4j.properties
delete mode 100644 integrity-monitor/src/test/java/org/onap/policy/common/im/AllSeemsWellTest.java
delete mode 100644 integrity-monitor/src/test/java/org/onap/policy/common/im/ExceptionsTest.java
delete mode 100644 integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java
delete mode 100644 integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java
delete mode 100644 integrity-monitor/src/test/java/org/onap/policy/common/im/MonitorTimeTest.java
delete mode 100644 integrity-monitor/src/test/java/org/onap/policy/common/im/StateChangeNotifierTest.java
delete mode 100644 integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java
delete mode 100644 integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java
delete mode 100644 integrity-monitor/src/test/java/org/onap/policy/common/im/StateTransitionTest.java
delete mode 100644 integrity-monitor/src/test/java/org/onap/policy/common/im/exceptions/EntityRetrievalExceptionTest.java
delete mode 100644 integrity-monitor/src/test/resources/logback-test.xml
diff --git a/common-logging/config/policyLogger.properties b/common-logging/config/policyLogger.properties
deleted file mode 100644
index 8e4e869a..00000000
--- a/common-logging/config/policyLogger.properties
+++ /dev/null
@@ -1,44 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# ONAP-Logging
-# ================================================================================
-# Copyright (C) 2017 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.
-# 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END=========================================================
-###
-
-################################### Set concurrentHashMap and timer info #######################
-#Timer initial delay and the delay between in milliseconds before task is to be execute.
-timer.delay.time=1000
-#Timer scheduleAtFixedRate period - time in milliseconds between successive task executions.
-check.interval= 30000
-#Longest time an event info can be stored in the concurrentHashMap for logging - in seconds.
-event.expired.time=86400
-#Size of the concurrentHashMap which stores the event starting time, etc - when its size reaches this limit, the Timer gets executed
-#to remove all expired records from this concurrentHashMap.
-concurrentHashMap.limit=5000
-#Size of the concurrentHashMap - when its size drops to this point, stop the Timer
-stop.check.point=2500
-################################### Set logging format #############################################
-# set EELF for EELF logging format, set LOG4J for using log4j, set SYSTEMOUT for using system.out.println
-logger.type=EELF
-#################################### Set level for EELF or SYSTEMOUT logging ##################################
-# Set level for debug file. Set DEBUG to enable .info, .warn and .debug; set INFO for enable .info and .warn; set OFF to disable all
-debugLogger.level=INFO
-# Set level for metrics file. Set OFF to disable; set ON to enable
-metricsLogger.level=ON
-# Set level for error file. Set OFF to disable; set ON to enable
-error.level=ON
-# Set level for audit file. Set OFF to disable; set ON to enable
-audit.level=ON
\ No newline at end of file
diff --git a/common-logging/policyLogger.properties b/common-logging/policyLogger.properties
deleted file mode 100644
index e2335df6..00000000
--- a/common-logging/policyLogger.properties
+++ /dev/null
@@ -1,50 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# ONAP-Logging
-# ================================================================================
-# Copyright (C) 2017 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.
-# 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END=========================================================
-###
-
-################################### Set concurrentHashMap and timer info #######################
-#Timer initial delay and the delay between in milliseconds before task is to be execute.
-timer.delay.time=1000
-#Timer scheduleAtFixedRate period - time in milliseconds between successive task executions.
-check.interval= 30000
-#Longest time an event info can be stored in the concurrentHashMap for logging - in seconds.
-event.expired.time=86400
-#Size of the concurrentHashMap which stores the event starting time, etc - when its size reaches this limit, the Timer gets executed
-#to remove all expired records from this concurrentHashMap.
-concurrentHashMap.limit=5000
-#Size of the concurrentHashMap - when its size drops to this point, stop the Timer
-stop.check.point=2500
-################################### Set logging format #############################################
-# set EELF for EELF logging format, set LOG4J for using log4j, set SYSTEMOUT for using system.out.println
-logger.type=EELF
-#################################### Set level for EELF or SYSTEMOUT logging ##################################
-# Set override flag. Set TRUE for override the level setups in logback.xml. Set FALSE for using the level setups of logback.xml
-override.logback.level.setup=FALSE
-#Only use these setups below if override.logback.level.setup=TRUE
-# Set level for debug file. Set DEBUG to enable .info, .warn and .debug; set INFO for enable .info and .warn; set OFF to disable all
-debugLogger.level=INFO
-# Set level for metrics file. Set OFF to disable; set ON to enable
-metricsLogger.level=ON
-# Set level for error file. Set OFF to disable; set ON to enable
-error.level=ON
-# Set level for audit file. Set OFF to disable; set ON to enable
-audit.level=ON
-#################################### Set Policy Component ##################################
-# Set DROOLS for drools PDP. Set XACML to xacml PDP
-policy.component=DROOLS
diff --git a/common-logging/pom.xml b/common-logging/pom.xml
deleted file mode 100644
index 2a889d0e..00000000
--- a/common-logging/pom.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-
-
-
- 4.0.0
-
-
- org.onap.policy.common
- common-modules
- 3.0.1-SNAPSHOT
-
-
- ONAP-Logging
- ONAP Logging Framework
- jar
-
-
-
- com.att.eelf
- eelf-core
- 2.0.0-oss
-
-
- org.powermock
- powermock-api-mockito
-
-
-
-
- org.projectlombok
- lombok
- provided
-
-
- org.apache.commons
- commons-lang3
-
-
- com.google.re2j
- re2j
-
-
- jakarta.servlet
- jakarta.servlet-api
-
-
- org.assertj
- assertj-core
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- org.springframework
- spring-test
- test
-
-
-
-
-
-
- com.att.eelf
- eelf-maven-plugin
- 2.0.0-oss
-
-
- install
-
- WikiMsgGenerator
-
-
-
-
-
-
- org.onap.policy.common
- ONAP-Logging
- ${project.version}
-
-
-
- target/messages
- messages.html
-
-
- org.onap.policy.common.logging.eelf.MessageCodes
- This needs to be replaced with your Enum
- class name .which
- implements EELFResolvableErrorEnum and have your defined error
- codes.
-
-
- Application Messages
Application Messages
]]>
-
-
-
-
-
-
-
-
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingContext.java b/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingContext.java
deleted file mode 100644
index e457f5f3..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingContext.java
+++ /dev/null
@@ -1,567 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2021 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging;
-
-import java.text.SimpleDateFormat;
-import java.time.Duration;
-import java.time.Instant;
-import java.util.Date;
-import org.onap.policy.common.logging.nsa.LoggingContextFactory;
-import org.onap.policy.common.logging.nsa.SharedLoggingContext;
-import org.slf4j.MDC;
-
-/**
- * A facade over the org.onap.policy.common.logging.nsa.SharedLoggingContext
- * interface/implementation that makes it more convenient to use. SharedLoggingContext builds on the
- * SLF4J/log4j Mapped Diagnostic Context (MDC) feature, which provides a hashmap-based context for
- * data items that need to be logged, where the hashmap is kept in ThreadLocal storage. The data
- * items can be referenced in the log4j configuration using the EnhancedPatternLayout appender
- * layout class, and the notation "%X{key}" in the ConversionPattern string, where "key" is one of
- * the keys in the MDC hashmap (which is determined by what hashmap entries the application code
- * creates). Example: log4j.appender.auditAppender.layout=org.apache.log4j.EnhancedPatternLayout
- * log4j.appender.auditAppender.layout.ConversionPattern=%d|%X{requestId}|%X{serviceInstanceId}|...|%m%n
- * where "requestId" and "serviceInstanceId" are entries in the MDC hashmap.
- *
- *
The notable functionality the SharedLoggingContext adds over MDC is that it maintains its own
- * copy of the MDC data items in a hashmap (not in ThreadLocal storage), which allows more control
- * of the data. The ONAPLoggingContext constructor that takes another ONAPLoggingContext object as a
- * parameter makes use of this feature. For example if there is a thread pulling requests from a
- * queue for processing, it can keep a base logging context with data that is common to all
- * requests, and for each request, create a new logging context with that base context as a
- * parameter; this will create a new logging context with those initial values and none of the
- * request-specific values from the previous request such as a request ID.
- *
- *
The setter methods in this class set corresponding items in the SharedLoggingContext/MDC
- * hashmaps. These items correspond to the fields defined in the "ONAP platform application logging
- * guidelines" document. In addition, there is a pair of convenience functions, transactionStarted()
- * and transactionEnded(), that can be called at the beginning and end of transaction processing to
- * calculate the duration of the transaction and record that value in the "timer" item.
- *
- */
-public class OnapLoggingContext {
-
- private static final String REQUEST_ID = "requestId";
- private static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
- private static final String THREAD_ID = "threadId";
- private static final String SERVER_NAME = "serverName";
- private static final String SERVICE_NAME = "serviceName";
- private static final String PARTNER_NAME = "partnerName";
- private static final String STATUS_CODE = "statusCode";
- private static final String TARGET_ENTITY = "targetEntity";
- private static final String TARGET_SERVICE_NAME = "targetServiceName";
- private static final String INSTANCE_UUID = "instanceUuid";
- private static final String SEVERITY = "severity";
- private static final String SERVER_IP_ADDRESS = "serverIpAddress";
- private static final String SERVER = "server";
- private static final String CLIENT_IP_ADDRESS = "clientIpAddress";
- private static final String CLASSNAME = "classname";
- private static final String TRANSACTION_BEGIN_TIME_STAMP = "TransactionBeginTimestamp";
- private static final String TRANSACTION_END_TIME_STAMP = "TransactionEndTimestamp";
- private static final String TRANSACTION_ELAPSED_TIME = "TransactionElapsedTime";
- private static final String METRIC_BEGIN_TIME_STAMP = "MetricBeginTimestamp";
- private static final String METRIC_END_TIME_STAMP = "MetricEndTimestamp";
- private static final String METRIC_ELAPSED_TIME = "MetricElapsedTime";
- private static final String POLICY = "POLICY";
- private static final String USER = "USER";
- private static final String COMPLETE = "COMPLETE";
- private static final String PE_PROCESS = "PE Process";
- private static final String TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS+00:00";
- private static final String EMPTY_STRING = "";
- private static final int DEFAULT_VALUE = 0;
-
-
- private static LoggingContextFactory.Builder loggingContextBuilder = new LoggingContextFactory.Builder();
-
- protected SharedLoggingContext context = null;
- private Instant transactionStartTime;
- private Instant metricStartTime;
-
- /**
- * Create a new ONAPLoggingContext with no base context.
- */
- public OnapLoggingContext() {
- context = (SharedLoggingContext) loggingContextBuilder.forSharing().build();
- }
-
- /**
- * Create a new ONAPLoggingContext initially populated with the values in the given base
- * context. This can be used for example in a servlet where each incoming request may be
- * processed by a separate thread, but there may be some logging data items that will be
- * unchanging and common to all the threads. That constant data can be populated in a base
- * context, and then each request handler creates new context passing that base context to
- * populate the common data in the new one.
- *
- * @param baseContext onap logging context
- */
- public OnapLoggingContext(OnapLoggingContext baseContext) {
- context = (SharedLoggingContext) loggingContextBuilder.forSharing().build();
- // a logging context could be passed into a thread (e.g. one that is servicing a queue)
- // that already had a logging context established, so the MDC hashmap could contain
- // entries that are no longer appropriate; so clear out the MDC hashmap before
- // transferring the new logging context values.
- // x
- MDC.clear();
- baseContext.context.transferTo(context);
- transactionStartTime = baseContext.transactionStartTime;
- setServiceName(POLICY);
- setPartnerName(USER);
- setStatusCode(COMPLETE);
- setTargetEntity(POLICY);
- setTargetServiceName(PE_PROCESS);
- }
-
- /**
- * Indicate the start of transaction processing. The current system time will be recorded for
- * use by transactionEnded() to calculate the duration of the transaction.
- */
- public void transactionStarted() {
- transactionStartTime = Instant.now();
- setTransactionBeginTimestamp(transactionStartTime);
- }
-
- /**
- * Indicate the end of transaction processing. The difference between the current system time
- * and the time recorded by transactionStarted() will be recorded in the data item
- * with key "TransactionElapsedTime".
- */
- public void transactionEnded() {
- var transactionEndTime = Instant.now();
- setTransactionEndTimestamp(transactionEndTime);
- setTransactionElapsedTime(transactionEndTime);
- }
-
- /**
- * Indicate the start of metric processing. The current system time will be recorded for use by
- * metricEnded() to calculate the duration of the metric.
- */
- public void metricStarted() {
- metricStartTime = Instant.now();
- setMetricBeginTimestamp(metricStartTime);
- }
-
- /**
- * Indicate the end of metric processing. The difference between the current system time and the
- * time recorded by metricStarted() will be recorded in the data item with key
- * "MetricElapsedTime".
- */
- public void metricEnded() {
- var metricEndTime = Instant.now();
- setMetricEndTimestamp(metricEndTime);
- setMetricElapsedTime(metricEndTime);
- }
-
- /**
- * Set the value for the data item with key "requestId".
- *
- * @param id request identifier
- */
- public void setRequestId(String id) {
- context.put(REQUEST_ID, id);
- }
-
- /**
- * Get the value for the data item with key "requestId".
- *
- * @return current value, or empty string if not set
- */
- public String getRequestId() {
- return context.get(REQUEST_ID, EMPTY_STRING);
- }
-
- /**
- * Set the value for the data item with key "serviceInstanceId".
- *
- * @param id service identifier
- */
- public void setServiceInstanceId(String id) {
- context.put(SERVICE_INSTANCE_ID, id);
- }
-
- /**
- * Get the value for the data item with key "serviceInstanceId".
- *
- * @return current value, or empty string if not set
- */
- public String getServiceInstanceId() {
- return context.get(SERVICE_INSTANCE_ID, EMPTY_STRING);
- }
-
- /**
- * Set the value for the data item with key "threadId". An alternative to using this item is to
- * use the %t conversion character in the appender's conversion string.
- *
- * @param id thread identifier
- */
- public void setThreadId(String id) {
- context.put(THREAD_ID, id);
- }
-
- /**
- * Get the value for the data item with key "threadId".
- *
- * @return current value, or empty string if not set
- */
- public String getThreadId() {
- return context.get(THREAD_ID, EMPTY_STRING);
- }
-
- /**
- * Set the value for the data item with key "serverName".
- *
- * @param name server name
- */
- public void setServerName(String name) {
- context.put(SERVER_NAME, name);
- }
-
- /**
- * Get the value for the data item with key "serverName".
- *
- * @return current value, or empty string if not set
- */
- public String getServerName() {
- return context.get(SERVER_NAME, EMPTY_STRING);
- }
-
- /**
- * Set the value for the data item with key "serviceName".
- *
- * @param name service name
- */
- public void setServiceName(String name) {
- context.put(SERVICE_NAME, name);
- }
-
- /**
- * Get the value for the data item with key "serviceName".
- *
- * @return current value, or empty string if not set
- */
- public String getServiceName() {
- return context.get(SERVICE_NAME, EMPTY_STRING);
- }
-
- /**
- * Set the value for the data item with key "partnerName".
- *
- * @param name partner name
- */
- public void setPartnerName(String name) {
- context.put(PARTNER_NAME, name);
- }
-
- /**
- * Get the value for the data item with key "partnerName".
- *
- * @return current value, or empty string if not set
- */
- public String getPartnerName() {
- return context.get(PARTNER_NAME, EMPTY_STRING);
- }
-
- /**
- * Set the value for the data item with key "statusCode".
- *
- * @param name status code
- */
- public void setStatusCode(String name) {
- context.put(STATUS_CODE, name);
- }
-
- /**
- * Get the value for the data item with key "statusCode".
- *
- * @return current value, or empty string if not set
- */
- public String getStatusCode() {
- return context.get(STATUS_CODE, EMPTY_STRING);
- }
-
- /**
- * Set the value for the data item with key "targetEntity".
- *
- * @param name target entity
- */
- public void setTargetEntity(String name) {
- context.put(TARGET_ENTITY, name);
- }
-
- /**
- * Get the value for the data item with key "targetEntity".
- *
- * @return current value, or empty string if not set
- */
- public String getTargetEntity() {
- return context.get(TARGET_ENTITY, EMPTY_STRING);
- }
-
- /**
- * Set the value for the data item with key "targetServiceName".
- *
- * @param name target service name
- */
- public void setTargetServiceName(String name) {
- context.put(TARGET_SERVICE_NAME, name);
- }
-
- /**
- * Get the value for the data item with key "targetServiceName".
- *
- * @return current value, or empty string if not set
- */
- public String getTargetServiceName() {
- return context.get(TARGET_SERVICE_NAME, EMPTY_STRING);
- }
-
- /**
- * Set the value for the data item with key "instanceUuid".
- *
- * @param uuid instance uuid
- */
- public void setInstanceUuid(String uuid) {
- context.put(INSTANCE_UUID, uuid);
- }
-
- /**
- * Get the value for the data item with key "instanceUuid".
- *
- * @return current value, or empty string if not set
- */
- public String getInstanceUuid() {
- return context.get(INSTANCE_UUID, EMPTY_STRING);
- }
-
- /**
- * Set the value for the data item with key "severity".
- *
- * @param severity severity
- */
- public void setSeverity(Long severity) {
- context.put(SEVERITY, severity);
- }
-
- /**
- * Get the value for the data item with key "severity".
- *
- * @return current value, or empty string if not set
- */
- public String getSeverity() {
- return context.get(SEVERITY, EMPTY_STRING);
- }
-
- /**
- * Set the value for the data item with key "serverIp".
- *
- * @param serverIp server ip address
- */
- public void setServerIpAddress(String serverIp) {
- context.put(SERVER_IP_ADDRESS, serverIp);
- }
-
- /**
- * Get the value for the data item with key "serverIp".
- *
- * @return current value, or empty string if not set
- */
- public String getServerIpAddress() {
- return context.get(SERVER_IP_ADDRESS, EMPTY_STRING);
- }
-
- /**
- * Set the value for the data item with key "server".
- *
- * @param server server
- */
- public void setServer(String server) {
- context.put(SERVER, server);
- }
-
- /**
- * Get the value for the data item with key "server".
- *
- * @return current value, or empty string if not set
- */
- public String getServer() {
- return context.get(SERVER, EMPTY_STRING);
- }
-
- /**
- * Set the value for the data item with key "clientIp".
- *
- * @param clientIp client ip address
- */
- public void setClientIpAddress(String clientIp) {
- context.put(CLIENT_IP_ADDRESS, clientIp);
- }
-
- /**
- * Get the value for the data item with key "clientIp".
- *
- * @return current value, or empty string if not set
- */
- public String getClientIpAddress() {
- return context.get(CLIENT_IP_ADDRESS, EMPTY_STRING);
- }
-
- /**
- * Set the value for the data item with key "classname". Use of this item is not recommended
- * (unless it is used to indicate something other than the Java classname) since it would be
- * unwieldy to maintain a correct value across calls to/returns from methods in other classes.
- * Use of the PatternLayout %c conversion character in the conversion string will give a more
- * reliable value.
- *
- * @param classname class name
- */
- public void setClassname(String classname) {
- context.put(CLASSNAME, classname);
- }
-
- /**
- * Get the value for the data item with key "classname".
- *
- * @return current value, or empty string if not set
- */
- public String getClassname() {
- return context.get(CLASSNAME, EMPTY_STRING);
- }
-
- /**
- * Set the value for the data item with key "TransactionBeginTimestamp".
- *
- * @param transactionStartTime transaction start time
- */
- public void setTransactionBeginTimestamp(Instant transactionStartTime) {
- var sdf = new SimpleDateFormat(TIME_FORMAT);
- context.put(TRANSACTION_BEGIN_TIME_STAMP, sdf.format(Date.from(transactionStartTime)));
- }
-
- /**
- * Get the value for the data item with key "TransactionBeginTimestamp".
- *
- * @return current value, or 0 if not set
- */
- public long getTransactionBeginTimestamp() {
- return context.get(TRANSACTION_BEGIN_TIME_STAMP, DEFAULT_VALUE);
- }
-
- /**
- * Set the value for the data item with key "TransactionEndTimestamp".
- *
- * @param transactionEndTime transaction end time
- */
- public void setTransactionEndTimestamp(Instant transactionEndTime) {
- var sdf = new SimpleDateFormat(TIME_FORMAT);
- context.put(TRANSACTION_END_TIME_STAMP, sdf.format(Date.from(transactionEndTime)));
- }
-
- /**
- * Get the value for the data item with key "TransactionEndTimestamp".
- *
- * @return current value, or 0 if not set
- */
- public long getTransactionEndTimestamp() {
- return context.get(TRANSACTION_END_TIME_STAMP, DEFAULT_VALUE);
- }
-
- /**
- * Set the value for the data item with key "TransactionElapsedTime". An alternative to calling
- * this method directly is to call transactionStarted() at the start of transaction
- * processing and transactionEnded() at the end, which will compute the time
- * difference in milliseconds and store the result as the "ns" value.
- *
- * @param transactionEndTime transaction end time
- */
-
- public void setTransactionElapsedTime(Instant transactionEndTime) {
- long ns = Duration.between(transactionStartTime, transactionEndTime).toMillis();
- context.put(TRANSACTION_ELAPSED_TIME, ns);
- }
-
- /**
- * Get the value for the data item with key "TransactionElapsedTime".
- *
- * @return current value, or 0 if not set
- */
- public long getTransactionElapsedTime() {
- return context.get(TRANSACTION_ELAPSED_TIME, DEFAULT_VALUE);
- }
-
- /**
- * Set the value for the data item with key "MetricBeginTimestamp".
- *
- * @param metricStartTime metric start time
- */
- public void setMetricBeginTimestamp(Instant metricStartTime) {
- var sdf = new SimpleDateFormat(TIME_FORMAT);
- context.put(METRIC_BEGIN_TIME_STAMP, sdf.format(Date.from(metricStartTime)));
- }
-
- /**
- * Get the value for the data item with key "MetricBeginTimestamp".
- *
- * @return current value, or 0 if not set
- */
- public long getMetricBeginTimestamp() {
- return context.get(METRIC_BEGIN_TIME_STAMP, DEFAULT_VALUE);
- }
-
- /**
- * Set the value for the data item with key "MetricEndTimestamp".
- *
- * @param metricEndTime metric end time
- */
- public void setMetricEndTimestamp(Instant metricEndTime) {
- var sdf = new SimpleDateFormat(TIME_FORMAT);
- context.put(METRIC_END_TIME_STAMP, sdf.format(Date.from(metricEndTime)));
- }
-
- /**
- * Get the value for the data item with key "MetricEndTimestamp".
- *
- * @return current value, or 0 if not set
- */
- public long getMetricEndTimestamp() {
- return context.get(METRIC_END_TIME_STAMP, DEFAULT_VALUE);
- }
-
- /**
- * Set the value for the data item with key "MetricElapsedTime". An alternative to calling this
- * method directly is to call metricStarted() at the start of metric processing and
- * metricEnded() at the end, which will compute the time difference in milliseconds
- * and store the result as the "ns" value.
- *
- * @param metricEndTime metric end time
- */
-
- public void setMetricElapsedTime(Instant metricEndTime) {
- long ns = Duration.between(metricStartTime, metricEndTime).toMillis();
- context.put(METRIC_ELAPSED_TIME, ns);
- }
-
- /**
- * Get the value for the data item with key "MetricElapsedTime".
- *
- * @return current value, or 0 if not set
- */
- public long getMetricElapsedTime() {
- return context.get(METRIC_ELAPSED_TIME, DEFAULT_VALUE);
- }
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java b/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java
deleted file mode 100644
index 91133d1a..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging;
-
-import com.google.re2j.Pattern;
-import jakarta.servlet.http.HttpServletRequest;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class OnapLoggingUtils {
-
- private static final Pattern COMMA_PAT = Pattern.compile(",");
- private static final Pattern CURLS_PAT = Pattern.compile("[{][}]");
-
- /**
- * Get the ONAPLoggingContext for a request.
- *
- * @param request the request
- * @param baseContext the context to supply to the ONAPLoggingContext
- * @return the ONAPLoggingContext
- */
- public static OnapLoggingContext getLoggingContextForRequest(HttpServletRequest request,
- OnapLoggingContext baseContext) {
- var requestContext = new OnapLoggingContext(baseContext);
- if (request.getLocalAddr() != null) { // may be null in junit tests
- requestContext.setServerIpAddress(request.getLocalAddr());
- }
- // get client IP address as leftmost address in X-Forwarded-For header if present,
- // otherwise from remote address in the request
- String forwarded = request.getHeader("X-Forwarded-For");
- if (forwarded != null && forwarded.trim().length() > 0) {
- forwarded = COMMA_PAT.split(forwarded.trim())[0];
- requestContext.setClientIpAddress(forwarded);
- } else if (request.getRemoteAddr() != null) { // may be null in junit tests
- requestContext.setClientIpAddress(request.getRemoteAddr());
- }
- // RequestID
- // This needs to be renamed to ONAP when the other components in ONAP
- // rename to this.
- String requestId = request.getHeader("X-ECOMP-RequestID");
- if (requestId != null && requestId.trim().length() > 0) {
- requestContext.setRequestId(requestId);
- }
- return requestContext;
- }
-
- /**
- * Create message text replace {} place holder with data
- * if last argument is throwable/exception, pass it as argument to logger.
- * @param format message format can contains text and {}
- * @param arguments output arguments
- * @return the formatted message as a String
- */
- public static String formatMessage(String format, Object...arguments) {
- if (arguments.length <= 0 || arguments[0] == null) {
- return format;
- }
- int index;
- var builder = new StringBuilder();
- String[] token = CURLS_PAT.split(format);
- for (index = 0; index < arguments.length; index++) {
- if (index < token.length) {
- builder.append(token[index]);
- builder.append(arguments[index]);
- } else {
- break;
- }
- }
- for (int index2 = index; index2 < token.length; index2++) {
- builder.append(token[index2]);
- }
-
- return builder.toString();
- }
-
- /**
- * Check object is throwable.
- * @param obj to verify
- * @return true if object is throwable or false otherwise
- */
- public static boolean isThrowable(Object obj) {
- return (obj instanceof Throwable);
- }
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/DroolsPdpMdcInfo.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/DroolsPdpMdcInfo.java
deleted file mode 100644
index 6086a642..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/DroolsPdpMdcInfo.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.eelf;
-
-import com.att.eelf.configuration.Configuration;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-public class DroolsPdpMdcInfo implements MdcInfo {
-
- private static ConcurrentHashMap mdcMap = new ConcurrentHashMap<>();
-
- static {
-
- mdcMap.put(Configuration.MDC_REMOTE_HOST, "");
- mdcMap.put(Configuration.MDC_SERVICE_NAME, "Policy.droolsPdp");
- mdcMap.put(Configuration.MDC_SERVICE_INSTANCE_ID, "Policy.droolsPdp.event");
- mdcMap.put(Configuration.MDC_INSTANCE_UUID, "");
- mdcMap.put(Configuration.MDC_ALERT_SEVERITY, "");
- mdcMap.put(OnapConfigProperties.PARTNER_NAME, "N/A");
- mdcMap.put(OnapConfigProperties.STATUS_CODE, "N/A");
- mdcMap.put(OnapConfigProperties.RESPONSE_CODE, "N/A");
- mdcMap.put(OnapConfigProperties.RESPONSE_DESCRIPTION, "N/A");
- }
-
- /**
- * Get the MMDC Info.
- *
- * @return the instance of ConcurrentHashMap.
- */
- @Override
- public ConcurrentMap getMdcInfo() {
- return mdcMap;
- }
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/ErrorCodeMap.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/ErrorCodeMap.java
deleted file mode 100644
index 0eaa06b0..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/ErrorCodeMap.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2018, 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.eelf;
-
-import java.util.EnumMap;
-import lombok.AccessLevel;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-
-/**
- * ErrorCodeMap contains a HashMap of ErrorCodeInfo (error code and error description).
- * Standard error code:
- * 100 – permission errors
- * 200 – availability errors
- * 300 – data errors
- * 400 – schema errors
- * 500 – business process errors
- * 900 – unknown errors
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ErrorCodeMap {
-
- private static final EnumMap hm = new EnumMap<>(MessageCodes.class);
-
- private static final String CHECK_ERROR_MESSAGE = " Please check the error message for detail information";
-
- private static final String ERROR_PERMISSIONS = "100";
- private static final String ERROR_PERMISSIONS_DESCRIPTION = "This is a Permissions Error." + CHECK_ERROR_MESSAGE;
-
- private static final String ERROR_SCHEMA_INVALID = "400";
- private static final String ERROR_SCHEMA_INVALID_DESCRIPTION = "This is an Invalid Schema Error."
- + CHECK_ERROR_MESSAGE;
-
-
- private static final String UPDATE_ERROR = "300";
- private static final String UPDATE_ERROR_DESCRIPTION = "This is an updating error." + CHECK_ERROR_MESSAGE;
-
- private static final String EXCEPTION_ERROR_CODE = "500";
- private static final String EXCEPTION_ERROR_DESCRIPTION = "This is an exception error message during the process."
- + CHECK_ERROR_MESSAGE;
-
- private static final String MISS_PROPERTY_ERROR = "300";
- private static final String MISS_PROPERTY_ERROR_DESCRIPTION = "This is an error of missing properties."
- + CHECK_ERROR_MESSAGE;
-
- private static final String GENERAL_ERROR_CODE = "500";
- private static final String GENERAL_ERROR_DESCRIPTION = "This is a general error message during the process."
- + CHECK_ERROR_MESSAGE;
-
- private static final String ERROR_SYSTEM_ERROR = "200";
- private static final String ERROR_SYSTEM_ERROR_DESCRIPTION = "This is a System Error." + CHECK_ERROR_MESSAGE;
-
- private static final String ERROR_DATA_ISSUE = "300";
- private static final String ERROR_DATA_ISSUE_DESCRIPTION = "This is a Data Issue Error." + CHECK_ERROR_MESSAGE;
-
- private static final String ERROR_PROCESS_FLOW = "500";
- private static final String ERROR_PROCESS_FLOW_DESCRIPTION = "This is a Process Flow Error." + CHECK_ERROR_MESSAGE;
-
- private static final String ERROR_UNKNOWN = "900";
- private static final String ERROR_UNKNOWN_DESCRIPTION = "This is an Unknown Error." + CHECK_ERROR_MESSAGE;
-
- private static final String ERROR_AUDIT = "300";
- private static final String ERROR_AUDIT_DESCRIPTION = "This is an audit Error." + CHECK_ERROR_MESSAGE;
-
- static {
- hm.put(MessageCodes.EXCEPTION_ERROR, new ErrorCodeInfo(EXCEPTION_ERROR_CODE, EXCEPTION_ERROR_DESCRIPTION));
- hm.put(MessageCodes.GENERAL_ERROR, new ErrorCodeInfo(GENERAL_ERROR_CODE, GENERAL_ERROR_DESCRIPTION));
- hm.put(MessageCodes.MISS_PROPERTY_ERROR,
- new ErrorCodeInfo(MISS_PROPERTY_ERROR, MISS_PROPERTY_ERROR_DESCRIPTION));
- hm.put(MessageCodes.UPDATE_ERROR, new ErrorCodeInfo(UPDATE_ERROR, UPDATE_ERROR_DESCRIPTION));
- hm.put(MessageCodes.ERROR_SYSTEM_ERROR, new ErrorCodeInfo(ERROR_SYSTEM_ERROR, ERROR_SYSTEM_ERROR_DESCRIPTION));
- hm.put(MessageCodes.ERROR_PERMISSIONS, new ErrorCodeInfo(ERROR_PERMISSIONS, ERROR_PERMISSIONS_DESCRIPTION));
- hm.put(MessageCodes.ERROR_DATA_ISSUE, new ErrorCodeInfo(ERROR_DATA_ISSUE, ERROR_DATA_ISSUE_DESCRIPTION));
- hm.put(MessageCodes.ERROR_PROCESS_FLOW, new ErrorCodeInfo(ERROR_PROCESS_FLOW, ERROR_PROCESS_FLOW_DESCRIPTION));
- hm.put(MessageCodes.ERROR_SCHEMA_INVALID,
- new ErrorCodeInfo(ERROR_SCHEMA_INVALID, ERROR_SCHEMA_INVALID_DESCRIPTION));
- hm.put(MessageCodes.ERROR_UNKNOWN, new ErrorCodeInfo(ERROR_UNKNOWN, ERROR_UNKNOWN_DESCRIPTION));
- hm.put(MessageCodes.ERROR_AUDIT, new ErrorCodeInfo(ERROR_AUDIT, ERROR_AUDIT_DESCRIPTION));
- }
-
- public static ErrorCodeInfo getErrorCodeInfo(MessageCodes messageCode) {
- return hm.get(messageCode);
- }
-
- @Getter
- static class ErrorCodeInfo {
-
- private final String errorCode;
- private final String errorDesc;
-
- public ErrorCodeInfo(String errorCode, String errorDesc) {
- this.errorCode = errorCode;
- this.errorDesc = errorDesc;
- }
-
- }
-
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java
deleted file mode 100644
index bdd67a08..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.eelf;
-
-import java.time.Instant;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-
-/**
- * EventData can be used for logging a rule event.
- */
-@Getter
-@Setter
-@NoArgsConstructor
-@AllArgsConstructor
-public class EventData {
-
- private String requestId = null;
- private Instant startTime = null;
- private Instant endTime = null;
-
- @Override
- public String toString() {
- return requestId + " Starting Time : " + this.startTime + " Ending Time : " + this.endTime;
- }
-
- @Override
- public int hashCode() {
- final var prime = 31;
- var result = 1;
- result = prime * result + ((requestId == null) ? 0 : requestId.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (obj instanceof String otherRequestId) {
- return requestId != null && requestId.equals(otherRequestId);
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- EventData other = (EventData) obj;
- if (requestId == null) {
- if (other.requestId != null) {
- return false;
- }
- } else if (!requestId.equals(other.requestId)) {
- return false;
- }
- return true;
- }
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java
deleted file mode 100644
index f6f38d0d..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2019, 2021 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.eelf;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import lombok.Getter;
-
-/**
- * EventTrackInfo contains a ConcurrentHashMap of EventData.
- */
-public class EventTrackInfo {
-
- @Getter
- private final ConcurrentMap eventInfo;
-
- /**
- * Construct an instance.
- */
- public EventTrackInfo() {
- /*
- * An initial capacity of 16 ensures the number of elements before resizing happens Load
- * factor of 0,9 ensures a dense packaging inside ConcurrentHashMap which will optimize
- * memory use Concurrency Level set to 1 will ensure that only one shard is created and
- * maintained
- */
- eventInfo = new ConcurrentHashMap<>(16, 0.9f, 1);
- }
-
- /**
- * Returns an instance of EventData associated to this requestID.
- *
- * @param requestId request id
- * @return EventData
- */
- public EventData getEventDataByRequestId(String requestId) {
- return eventInfo.get(requestId);
- }
-
- /**
- * Stores an EventData object in a ConcurrentHashMap using its requestID as key.
- *
- * @param event event data
- */
- public void storeEventData(EventData event) {
-
- if (event != null) {
- String id = event.getRequestId();
- if (id == null || id.isEmpty()) {
- return;
- }
- // in case override the start time, check the original event was already stored or not
- eventInfo.putIfAbsent(id, event);
- }
- }
-
- /**
- * Removes an EventData object from a ConcurrentHashMap using the eventId as key.
- *
- * @param eventId event id
- */
- public void remove(String eventId) {
- if (eventInfo != null) {
- eventInfo.remove(eventId);
- }
- }
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandler.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandler.java
deleted file mode 100644
index f5203683..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandler.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2021 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.eelf;
-
-import java.time.Duration;
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.TimerTask;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * EventTrackInfoHandler is the handler of clean up all expired event objects.
- */
-public class EventTrackInfoHandler extends TimerTask {
-
- String className = this.getClass().getSimpleName();
-
- @Override
- public void run() {
-
- PolicyLogger.info(className + " Release expired event records start...");
-
- cleanUp();
-
- PolicyLogger.info(className + " Release expired event records done");
- }
-
- /**
- * Removes all expired event objects from the ConcurrentHashMap of EventData.
- */
- private void cleanUp() {
-
- var eventTrackInfo = PolicyLogger.getEventTracker();
- if (eventTrackInfo == null) {
- return;
- }
- ConcurrentMap eventInfo = eventTrackInfo.getEventInfo();
- if (eventInfo == null || eventInfo.isEmpty()) {
- return;
- }
-
- Instant startTime;
- long ns;
-
- ArrayList expiredEvents = null;
-
- for (Map.Entry entry : eventInfo.entrySet()) {
- EventData event = entry.getValue();
- startTime = event.getStartTime();
- ns = Duration.between(startTime, Instant.now()).getSeconds();
-
- PolicyLogger.info(className + " duration time : " + ns);
-
- PolicyLogger.info(className + " PolicyLogger.EXPIRED_TIME : " + PolicyLogger.expiredTime);
-
- // if longer than EXPIRED_TIME, remove the object
-
- if (ns > PolicyLogger.expiredTime) {
- if (expiredEvents == null) {
- expiredEvents = new ArrayList<>();
- }
- expiredEvents.add(entry.getKey());
-
- PolicyLogger.info(className + " add expired event request ID: " + event.getRequestId());
- }
- }
-
- synchronized (eventInfo) {
- if (expiredEvents != null) {
- for (String expiredKey : expiredEvents) {
- eventInfo.remove(expiredKey);
- PolicyLogger.info(className + " removed expired event request ID: " + expiredKey);
- }
- }
- }
- }
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MdcInfo.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MdcInfo.java
deleted file mode 100644
index 59b8e8c3..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MdcInfo.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.eelf;
-
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * Interface needs to be implemented by DroolsPDPMDCInfo.
- */
-@FunctionalInterface
-public interface MdcInfo {
-
- /**
- * Returns MDC info.
- *
- * @return MDC info
- */
- ConcurrentMap getMdcInfo();
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MessageCodes.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MessageCodes.java
deleted file mode 100644
index 0535b9d7..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MessageCodes.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.eelf;
-
-import com.att.eelf.i18n.EELFResolvableResourceEnum;
-import com.att.eelf.i18n.EELFResourceManager;
-
-/**
- * MessageCodes contains all the messagge codes for EELF logging messages.
- */
-public enum MessageCodes implements EELFResolvableResourceEnum {
- // Below is a list of Error Messages taken from com.att.research.xacml.api XACMLErrorConstants
- // found under:
- // policy-engine\XACML\src\main\java\com\att\research\xacml\api\XACMLErrorConstants.java
-
- ERROR_PERMISSIONS,
-
- ERROR_SYSTEM_ERROR,
-
- ERROR_DATA_ISSUE,
-
- ERROR_SCHEMA_INVALID,
-
- ERROR_PROCESS_FLOW,
-
- ERROR_UNKNOWN,
-
- ERROR_AUDIT,
-
- // Above is a list of Error Messages taken from com.att.research.xacml.api XACMLErrorConstants
- // found under:
- // policy-engine\XACML\src\main\java\com\att\research\xacml\api\XACMLErrorConstants.java
-
- // ----------------------5000-5099 Business/Flow Processing Related --------------------/
-
- BAD_TYPE_WARNING,
-
- GENERAL_INFO,
-
- GENERAL_WARNING,
-
- MISS_PROPERTY_ERROR,
-
- EXCEPTION_ERROR,
-
- MISS_PROPERTY_INFO,
-
- RULE_AUDIT_EXEC_INFO,
-
- RULE_AUDIT_BEGIN_INFO,
-
- RULE_AUDIT_END_INFO,
-
- RULE_AUDIT_START_END_INFO,
-
- RULE_METRICS_INFO,
-
- UPDATE_ERROR,
-
- GENERAL_ERROR,
-
- // ----------------------New enums should be added above this line
- // ------------------------------------------------------------------/
-
- // --------------------- The enums below are old code. They should not be used since 1607
- // release and eventually will be removed -----/
- /**
- * Application message which requires no arguments.
- */
- MESSAGE_SAMPLE_NOARGS,
-
- /**
- * Application message which requires one argument {0}.
- */
- MESSAGE_SAMPLE_ONEARGUMENT,
-
- /**
- * Audit message which requires one argument {0}.
- */
- AUDIT_MESSAGE_ONEARGUMENT,
-
- /**
- * Error message which requires one argument {0}.
- */
- ERROR_MESSAGE_ONEARGUMENT,
-
- /**
- * Metrics message which requires one argument {0}.
- */
- METRICS_MESSAGE_ONEARGUMENT,
-
- /**
- * Debug message which requires one argument {0}.
- */
- DEBUG_MESSAGE_ONEARGUMENT,
-
- /**
- * Application message which requires two argument {0} and another argument {1}.
- */
- MESSAGE_SAMPLE_TWOARGUMENTS,
-
- /**
- * Sample error exception.
- */
- MESSAGE_SAMPLE_EXCEPTION,
-
- /**
- * Sample warning message.
- */
- MESSAGE_WARNING_SAMPLE,
-
- /**
- * Sample exception in method {0}.
- */
- MESSAGE_SAMPLE_EXCEPTION_ONEARGUMENT,
-
- /**
- * Sample trace message.
- */
- MESSAGE_TRACE_SAMPLE,
-
- /**
- * Sample error message.
- */
- MESSAGE_ERROR_SAMPLE;
-
-
- /*
- * Static initializer to ensure the resource bundles for this class are loaded... Here this
- * application loads messages from three bundles.
- */
- static {
- EELFResourceManager.loadMessageBundle("org/onap/policy/common/logging/eelf/Resources");
- String id = EELFResourceManager.getIdentifier(RULE_AUDIT_EXEC_INFO);
- String value = EELFResourceManager.getMessage(RULE_AUDIT_EXEC_INFO);
-
- PolicyLogger.info("*********************** Rule audit id: " + id);
- PolicyLogger.info("*********************** Rule audit value: " + value);
-
- }
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/OnapConfigProperties.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/OnapConfigProperties.java
deleted file mode 100644
index cfb14643..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/OnapConfigProperties.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2018, 2020-2021 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.eelf;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class OnapConfigProperties {
-
- /**
- * The Date-time of the start of a transaction.
- */
- public static final String BEGIN_TIME_STAMP = "BeginTimestamp";
-
- /**
- * The Date-time of the end of transaction.
- */
- public static final String END_TIME_STAMP = "EndTimestamp";
-
- /**
- * Externally advertised API invoked by clients of this component.
- */
- public static final String SERVICE_NAME = "ServiceName";
-
- /**
- * Client or user invoking the API.
- */
- public static final String PARTNER_NAME = "PartnerName";
-
- public static final String TARGET_ENTITY = "TargetEntity";
-
- public static final String TARGET_SERVICE_NAME = "TargetServiceName";
-
- /**
- * High level success or failure (COMPLETE or ERROR).
- */
- public static final String STATUS_CODE = "StatusCode";
-
- /**
- * Application specific response code.
- */
- public static final String RESPONSE_CODE = "ResponseCode";
-
- /**
- * Human-readable description of the application specific response code.
- */
- public static final String RESPONSE_DESCRIPTION = "ResponseDescription";
-
- /**
- * Externally advertised API invoked by clients of this component.
- */
- public static final String ELAPSED_TIME = "ElapsedTime";
-
- /**
- * High level failure (ERROR).
- */
- public static final String ERROR_CATEGORY = "ErrorCategory";
-
- public static final String ERROR_CODE = "ErrorCode";
-
- public static final String ERROR_DESCRIPTION = "ErrorDescription";
-
- public static final String CLASS_NAME = "ClassName";
-
- public static final String SERVER_NAME = "ServerName";
-
- public static final String INVOCATION_ID = "InvocationID";
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java
deleted file mode 100644
index 662ca764..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java
+++ /dev/null
@@ -1,1423 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2021 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.eelf;
-
-import static com.att.eelf.configuration.Configuration.MDC_ALERT_SEVERITY;
-import static com.att.eelf.configuration.Configuration.MDC_INSTANCE_UUID;
-import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID;
-import static com.att.eelf.configuration.Configuration.MDC_REMOTE_HOST;
-import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN;
-import static com.att.eelf.configuration.Configuration.MDC_SERVER_IP_ADDRESS;
-import static com.att.eelf.configuration.Configuration.MDC_SERVICE_INSTANCE_ID;
-import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.BEGIN_TIME_STAMP;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.ELAPSED_TIME;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.END_TIME_STAMP;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.ERROR_CATEGORY;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.ERROR_CODE;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.ERROR_DESCRIPTION;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.INVOCATION_ID;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.PARTNER_NAME;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.RESPONSE_CODE;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.RESPONSE_DESCRIPTION;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.SERVER_NAME;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.STATUS_CODE;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.TARGET_ENTITY;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.TARGET_SERVICE_NAME;
-import static org.onap.policy.common.logging.flexlogger.DisplayUtils.displayErrorMessage;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFLogger.Level;
-import com.att.eelf.configuration.EELFManager;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.text.SimpleDateFormat;
-import java.time.Duration;
-import java.time.Instant;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Timer;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentMap;
-import java.util.function.Consumer;
-import lombok.AccessLevel;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.policy.common.logging.OnapLoggingUtils;
-import org.onap.policy.common.logging.flexlogger.LoggerType;
-import org.slf4j.MDC;
-
-/**
- * PolicyLogger contains all the static methods for EELF logging.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public class PolicyLogger {
-
- private static EELFLogger errorLogger = EELFManager.getErrorLogger();
-
- private static EELFLogger metricsLogger = EELFManager.getMetricsLogger();
-
- private static EELFLogger auditLogger = EELFManager.getAuditLogger();
-
- private static EELFLogger debugLogger = EELFManager.getDebugLogger();
-
- private static final String POLICY_LOGGER = "PolicyLogger";
-
- private static EventTrackInfo eventTracker = new EventTrackInfo();
-
- private static String hostName = null;
- private static String hostAddress = null;
- private static String component = null;
-
- private static boolean isEventTrackerRunning = false;
- private static Timer timer = null;
-
- // Default:Timer initial delay and the delay between in milliseconds before task is to be
- // execute
- private static int timerDelayTime = 1000;
-
- // Default:Timer scheduleAtFixedRate period - time in milliseconds between successive task
- // executions
- private static int checkInterval = 30 * 1000;
-
- // Default:longest time an event info can be stored in the concurrentHashMap for logging - in
- // seconds
- static int expiredTime = 60 * 60 * 1000 * 24; // one day
-
- // Default:the size of the concurrentHashMap which stores the event starting time - when its
- // size reaches this limit, the Timer get executed
- private static int concurrentHashMapLimit = 5000;
-
- // Default:the size of the concurrentHashMap which stores the event starting time - when its
- // size drops to this point, stop the Timer
- private static int stopCheckPoint = 2500;
-
- @Getter
- @Setter
- private static boolean overrideLogbackLevel = false;
-
- private static Level debugLevel = Level.INFO;
- private static Level auditLevel = Level.INFO;
- private static Level metricsLevel = Level.INFO;
- private static Level errorLevel = Level.ERROR;
- private static String classNameProp = "ClassName";
-
- private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS+00:00";
- private static final String COMPLETE_STATUS = "COMPLETE";
- private static final String ERROR_CATEGORY_VALUE = "ERROR";
-
- static {
- if (hostName == null || hostAddress == null) {
- try {
- hostName = InetAddress.getLocalHost().getHostName();
- hostAddress = InetAddress.getLocalHost().getHostAddress();
- } catch (UnknownHostException e) {
- PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, POLICY_LOGGER, "UnknownHostException");
- }
- }
- }
-
- public static synchronized Level getDebugLevel() {
- return debugLevel;
- }
-
- public static synchronized void setDebugLevel(Level level) {
- debugLevel = level;
- }
-
- /**
- * Sets Debug Level.
- */
- public static synchronized void setDebugLevel(String newDebugLevel) {
-
- if (overrideLogbackLevel) {
- PolicyLogger.debugLevel = Level.valueOf(newDebugLevel);
- debugLogger.setLevel(debugLevel);
- }
-
- }
-
- public static synchronized Level getAuditLevel() {
- return auditLevel;
- }
-
- public static synchronized void setAuditLevel(Level level) {
- auditLevel = level;
- }
-
- /**
- * Sets Audit OFF or ON.
- */
- public static synchronized void setAuditLevel(String newAuditLevel) {
-
- if (overrideLogbackLevel) {
- if ("OFF".equalsIgnoreCase(newAuditLevel)) {
- PolicyLogger.auditLevel = Level.OFF;
- auditLogger.setLevel(auditLevel);
- } else {
- // --- set default value
- auditLogger.setLevel(Level.INFO);
- PolicyLogger.auditLevel = Level.INFO;
- }
- }
- }
-
- public static synchronized Level getMetricsLevel() {
- return metricsLevel;
- }
-
- public static synchronized void setMetricsLevel(Level level) {
- metricsLevel = level;
- }
-
- /**
- * Sets Metrics OFF or ON.
- */
- public static synchronized void setMetricsLevel(String newMetricsLevel) {
-
- if (overrideLogbackLevel) {
- if ("OFF".equalsIgnoreCase(newMetricsLevel)) {
- PolicyLogger.metricsLevel = Level.OFF;
- metricsLogger.setLevel(metricsLevel);
- } else {
- // --- set default value
- metricsLogger.setLevel(Level.INFO);
- PolicyLogger.metricsLevel = Level.INFO;
- }
- }
-
- }
-
- public static synchronized Level getErrorLevel() {
- return errorLevel;
- }
-
- public static synchronized void setErrorLevel(Level level) {
- errorLevel = level;
- }
-
- /**
- * Sets Error OFF or ON.
- */
- public static synchronized void setErrorLevel(String newErrorLevel) {
-
- if (overrideLogbackLevel) {
- if ("OFF".equalsIgnoreCase(newErrorLevel)) {
- PolicyLogger.errorLevel = Level.OFF;
- errorLogger.setLevel(errorLevel);
- } else {
- // --- set default value
- errorLogger.setLevel(Level.ERROR);
- PolicyLogger.errorLevel = Level.ERROR;
- }
- }
- }
-
- public static synchronized String getClassname() {
- return classNameProp;
- }
-
- public static synchronized void setClassname(String name) {
- classNameProp = name;
- }
-
- /**
- * Populates MDC info.
- *
- * @param transId the transaction ID
- * @return String
- */
- public static String postMdcInfoForEvent(String transId) {
- MDC.clear();
-
- String transactionId = transId;
-
- if (transactionId == null || transactionId.isEmpty()) {
- transactionId = UUID.randomUUID().toString();
- }
-
- if ("DROOLS".equalsIgnoreCase(component)) {
- MDC.put(TARGET_ENTITY, "POLICY");
- MDC.put(TARGET_SERVICE_NAME, "drools evaluate rule");
- return postMdcInfoForEvent(transactionId, new DroolsPdpMdcInfo());
- } else {
- // For Xacml
- MDC.put(TARGET_ENTITY, "POLICY");
- MDC.put(TARGET_SERVICE_NAME, "PE Process");
- }
-
- MDC.put(MDC_REMOTE_HOST, "");
- MDC.put(MDC_KEY_REQUEST_ID, transactionId);
- MDC.put(MDC_SERVICE_NAME, "Policy.xacmlPdp");
- MDC.put(MDC_SERVICE_INSTANCE_ID, "Policy.xacmlPdp.event");
-
- setMdcHostInfo();
- seTimeStamps();
-
- return transactionId;
- }
-
- /**
- * Populate MDC Info using the passed in mdcInfo.
- *
- * @param transId the transaction ID
- * @param mdcInfo the MDC info
- * @return String
- */
- private static String postMdcInfoForEvent(String transId, MdcInfo mdcInfo) {
-
- MDC.put(MDC_KEY_REQUEST_ID, transId);
- if (mdcInfo != null && mdcInfo.getMdcInfo() != null && !mdcInfo.getMdcInfo().isEmpty()) {
-
- ConcurrentMap mdcMap = mdcInfo.getMdcInfo();
- Iterator keyIterator = mdcMap.keySet().iterator();
- String key;
-
- while (keyIterator.hasNext()) {
- key = keyIterator.next();
- MDC.put(key, mdcMap.get(key));
- }
- }
-
- setMdcHostInfo();
-
- var startTime = Instant.now();
- var endTime = Instant.now();
-
- seTimeStamps(startTime, endTime);
-
- return transId;
- }
-
- /**
- * Sets transaction Id to MDC.
- *
- * @param eventObject event object
- */
- public static void postMdcInfoForEvent(Object eventObject) {
- postMdcInfoForEvent("" + eventObject);
- }
-
- private static void setMdcHostInfo() {
- try {
- MDC.put(MDC_SERVER_FQDN, hostName);
- MDC.put(MDC_SERVER_IP_ADDRESS, hostAddress);
- } catch (Exception e) {
- errorLogger.error(MessageCodes.EXCEPTION_ERROR, e, POLICY_LOGGER);
- }
- }
-
- /**
- * Set Timestamps for start, end and duration of logging a transaction.
- */
- private static void seTimeStamps() {
- MDC.put(MDC_INSTANCE_UUID, "");
- MDC.put(MDC_ALERT_SEVERITY, "");
-
- var startTime = Instant.now();
- var endTime = Instant.now();
-
- seTimeStamps(startTime, endTime);
-
- MDC.put(PARTNER_NAME, "N/A");
-
- MDC.put(STATUS_CODE, COMPLETE_STATUS);
- MDC.put(RESPONSE_CODE, "N/A");
- MDC.put(RESPONSE_DESCRIPTION, "N/A");
-
- }
-
- private static void seTimeStamps(Instant startTime, Instant endTime) {
- var sdf = new SimpleDateFormat(DATE_FORMAT);
-
- String formatedTime = sdf.format(Date.from(startTime));
- MDC.put(BEGIN_TIME_STAMP, formatedTime);
-
- // set default values for these required fields below, they can be overridden
- formatedTime = sdf.format(Date.from(endTime));
- MDC.put(END_TIME_STAMP, formatedTime);
- MDC.put(ELAPSED_TIME, Long.toString(Duration.between(startTime, endTime).toMillis()));
- }
-
- /**
- * Sets transaction Id to MDC.
- *
- * @param transId the transaction ID
- */
- public static void setTransId(String transId) {
-
- MDC.put(MDC_KEY_REQUEST_ID, transId);
- }
-
- /**
- * Returns current transaction Id used in MDC.
- *
- * @return transId
- */
- public static String getTransId() {
-
- return MDC.get(MDC_KEY_REQUEST_ID);
- }
-
- /**
- * Resets transaction Id in MDC for the rule triggered by this event.
- *
- * @param transId the transaction ID
- * @return String
- */
- public static String postMdcInfoForTriggeredRule(String transId) {
-
- String transactionId = transId;
-
- MDC.clear();
-
- if (transactionId == null || transactionId.isEmpty()) {
- transactionId = UUID.randomUUID().toString();
- }
- MDC.put(MDC_REMOTE_HOST, "");
- MDC.put(MDC_KEY_REQUEST_ID, transactionId);
- MDC.put(MDC_SERVICE_NAME, "Policy.droolsPdp");
- MDC.put(MDC_SERVICE_INSTANCE_ID, "");
- setMdcHostInfo();
- MDC.put(MDC_INSTANCE_UUID, "");
- MDC.put(MDC_ALERT_SEVERITY, "");
- MDC.put(STATUS_CODE, COMPLETE_STATUS);
-
- return transactionId;
-
- }
-
- /**
- * Resets transaction Id in MDC for the rule triggered by this event.
- *
- * @param obj object
- */
- public static void postMdcUuidForTriggeredRule(Object obj) {
-
- postMdcInfoForTriggeredRule("" + obj);
-
- }
-
- // ************************************************************************************************
- /**
- * Records the Info event with String [] arguments.
- *
- * @param msg the message code
- * @param className the class name
- * @param arguments the messages
- */
- public static void info(MessageCodes msg, String className, String... arguments) {
- MDC.put(classNameProp, className);
- debugLogger.info(msg, arguments);
- }
-
- /**
- * Records only one String message.
- *
- * @param arg0 the message
- */
- public static void info(Object arg0) {
- MDC.put(classNameProp, "");
- debugLogger.info(MessageCodes.GENERAL_INFO, String.valueOf(arg0));
- }
-
- /**
- * Records a message with passed in message code, Throwable object, a list of string values.
- *
- * @param msg the message code
- * @param arg0 the throwable
- * @param arguments the messages
- */
- public static void info(MessageCodes msg, Throwable arg0, String... arguments) {
- MDC.put(classNameProp, "");
- String arguments2 = getNormalizedStackTrace(arg0, arguments);
- debugLogger.info(msg, arguments2);
- }
-
- /**
- * Records a message with passed in message code, class name, Throwable object, a list of string
- * values.
- *
- * @param msg the message code
- * @param className the class name
- * @param arg0 the throwable
- * @param arguments the messages
- */
- public static void info(MessageCodes msg, String className, Throwable arg0, String... arguments) {
- MDC.put(classNameProp, className);
- String arguments2 = getNormalizedStackTrace(arg0, arguments);
- debugLogger.info(msg, arguments2);
- }
-
- /**
- * Records a message with passed in message text and variable number of arguments.
- *
- * @param message class name if one argument, otherwise message text
- * @param arguments variable number of arguments
- */
- public static void info(String message, Object... arguments) {
- if (!debugLogger.isInfoEnabled()) {
- return;
- }
- if (arguments.length == 1 && !OnapLoggingUtils.isThrowable(arguments[0])) {
- MDC.put(classNameProp, message);
- debugLogger.info(MessageCodes.GENERAL_INFO,
- arguments[0] == null ? "" : arguments[0].toString());
- return;
- }
- if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- String arguments2 = getNormalizedStackTrace((Throwable) arguments[0], "");
- debugLogger.info(MessageCodes.GENERAL_INFO, message + arguments2);
- return;
- }
-
- MDC.put(classNameProp, "");
- debugLogger.info(message, arguments);
- }
-
- /**
- * Records only one String message.
- *
- * @param arg0 the message
- */
- public static void warn(Object arg0) {
- MDC.put(classNameProp, "");
- debugLogger.warn(MessageCodes.GENERAL_WARNING, "" + arg0);
- }
-
- /**
- * Records only one String message without its class name passed in.
- *
- * @param arg0 the message
- */
- public static void warn(String arg0) {
- MDC.put(classNameProp, "");
- debugLogger.warn(MessageCodes.GENERAL_WARNING, arg0);
- }
-
- /**
- * Records a message with passed in message code, class name and a list of string values.
- *
- * @param msg the message code
- * @param className the class name
- * @param arguments the messages
- */
- public static void warn(MessageCodes msg, String className, String... arguments) {
- MDC.put(classNameProp, className);
- debugLogger.warn(msg, arguments);
- }
-
- /**
- * Records a message with passed in message code, Throwable object, a list of string values.
- *
- * @param msg the message code
- * @param arg0 the throwable
- * @param arguments the messages
- */
- public static void warn(MessageCodes msg, Throwable arg0, String... arguments) {
- MDC.put(classNameProp, "");
- String arguments2 = getNormalizedStackTrace(arg0, arguments);
- debugLogger.warn(msg, arguments2);
- }
-
- /**
- * Records a message with passed in message code, Throwable object, a list of string values.
- *
- * @param msg the message code
- * @param className the class name
- * @param arg0 the throwable
- * @param arguments the messages
- */
- public static void warn(MessageCodes msg, String className, Throwable arg0, String... arguments) {
- MDC.put(classNameProp, className);
- String arguments2 = getNormalizedStackTrace(arg0, arguments);
- debugLogger.warn(msg, arguments2);
- }
-
- /**
- * Records a message with passed in message text and variable number of arguments.
- *
- * @param message class name if one argument, otherwise message text
- * @param arguments variable number of arguments
- */
- public static void warn(String message, Object... arguments) {
- if (!debugLogger.isWarnEnabled()) {
- return;
- }
- if (arguments.length == 1 && !OnapLoggingUtils.isThrowable(arguments[0])) {
- MDC.put(classNameProp, message);
- debugLogger.warn(MessageCodes.GENERAL_INFO,
- arguments[0] == null ? "" : arguments[0].toString());
- return;
- }
- if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- String arguments2 = getNormalizedStackTrace((Throwable) arguments[0], "");
- debugLogger.warn(MessageCodes.GENERAL_INFO, message + arguments2);
- return;
- }
- MDC.put(classNameProp, "");
- debugLogger.warn(message, arguments);
- }
-
- /**
- * Records only one String message.
- *
- * @param arg0 the message
- */
- public static void error(String arg0) {
- MDC.put(classNameProp, "");
- setErrorCode(MessageCodes.GENERAL_ERROR);
- errorLogger.error(MessageCodes.GENERAL_ERROR, arg0);
- }
-
- /**
- * Records only one String message.
- *
- * @param arg0 the message
- */
- public static void error(Object arg0) {
- MDC.put(classNameProp, "");
- setErrorCode(MessageCodes.GENERAL_ERROR);
- errorLogger.error(MessageCodes.GENERAL_ERROR, "" + arg0);
- }
-
- /**
- * Records a message with passed in message code, Throwable object, a list of string values.
- *
- * @param msg the message code
- * @param arg0 the throwable
- * @param arguments the messages
- */
- public static void error(MessageCodes msg, Throwable arg0, String... arguments) {
- MDC.put(classNameProp, "");
- setErrorCode(msg);
- String arguments2 = getNormalizedStackTrace(arg0, arguments);
- errorLogger.error(msg, arguments2);
- }
-
- /**
- * Records a message with passed in message code, class name, Throwable object, a list of string
- * values.
- *
- * @param msg the message code
- * @param className the class name
- * @param arg0 the throwable
- * @param arguments the messages
- */
- public static void error(MessageCodes msg, String className, Throwable arg0, String... arguments) {
- MDC.put(classNameProp, className);
- setErrorCode(msg);
- String arguments2 = getNormalizedStackTrace(arg0, arguments);
- errorLogger.error(msg, arguments2);
- }
-
- /**
- * Records a message with passed in message code and a list of string values.
- *
- * @param msg the message code
- * @param arguments the messages
- */
- public static void error(MessageCodes msg, String... arguments) {
- MDC.put(classNameProp, "");
- setErrorCode(msg);
- errorLogger.error(msg, arguments);
- }
-
- /**
- * Records a message with passed in message text and variable number of arguments.
- *
- * @param message class name if one argument, otherwise message text
- * @param arguments variable number of arguments
- */
- public static void error(String message, Object... arguments) {
- if (!errorLogger.isErrorEnabled()) {
- return;
- }
- if (arguments.length == 1 && !OnapLoggingUtils.isThrowable(arguments[0])) {
- MDC.put(classNameProp, message);
- setErrorCode(MessageCodes.GENERAL_ERROR);
- errorLogger.error(MessageCodes.GENERAL_ERROR,
- arguments[0] == null ? "" : arguments[0].toString());
- return;
- }
- if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- String arguments2 = getNormalizedStackTrace((Throwable) arguments[0], "");
- errorLogger.error(MessageCodes.GENERAL_ERROR, message + arguments2);
- return;
- }
- MDC.put(classNameProp, "");
- setErrorCode(MessageCodes.GENERAL_ERROR);
- errorLogger.error(message, arguments);
- }
-
- /**
- * Records a message with passed in message code and a list of string values.
- *
- * @param msg the message code
- * @param arguments the messages
- */
- public static void debug(MessageCodes msg, String... arguments) {
- MDC.put(classNameProp, "");
- debugLogger.debug(msg, arguments);
- }
-
- /**
- * Records only one String message.
- *
- * @param arg0 the message
- */
- public static void debug(String arg0) {
- MDC.put(classNameProp, "");
- debugLogger.debug(arg0);
- }
-
- /**
- * Records only one String message.
- *
- * @param arg0 the message
- */
- public static void debug(Object arg0) {
-
- MDC.put(classNameProp, "");
- debugLogger.debug("{}", arg0);
- }
-
- /**
- * Records a message with passed in message code, hrowable object, a list of string values.
- *
- * @param msg the message code
- * @param arg0 the throwable
- * @param arguments the messages
- */
- public static void debug(MessageCodes msg, Throwable arg0, String... arguments) {
- MDC.put(classNameProp, "");
- String arguments2 = getNormalizedStackTrace(arg0, arguments);
- debugLogger.debug(msg, arguments2);
- }
-
- /**
- * Records a message with passed in message code, class name, Throwable object, a list of
- * string. values
- *
- * @param msg the message code
- * @param className the class name
- * @param arg0 the throwable
- * @param arguments the messages
- */
- public static void debug(MessageCodes msg, String className, Throwable arg0, String... arguments) {
- MDC.put(classNameProp, className);
- String arguments2 = getNormalizedStackTrace(arg0, arguments);
- debugLogger.debug(msg, arguments2);
- }
-
- /**
- * Records a message with passed in message text and variable number of arguments.
- *
- * @param message class name if one argument, otherwise message text
- * @param arguments variable number of arguments
- */
- public static void debug(String message, Object... arguments) {
- if (!debugLogger.isDebugEnabled()) {
- return;
- }
- if (arguments.length == 1 && !OnapLoggingUtils.isThrowable(arguments[0])) {
- MDC.put(classNameProp, message);
- debugLogger.debug(MessageCodes.GENERAL_INFO,
- arguments[0] == null ? "" : arguments[0].toString());
- return;
- }
- if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- String arguments2 = getNormalizedStackTrace((Throwable) arguments[0], "");
- debugLogger.debug(MessageCodes.GENERAL_INFO, message + arguments2);
- return;
- }
- MDC.put(classNameProp, "");
- debugLogger.debug(message, arguments);
- }
-
- /**
- * Records only one String message.
- *
- * @param arg0 the message
- */
- public static void audit(Object arg0) {
- MDC.put(INVOCATION_ID, MDC.get(MDC_KEY_REQUEST_ID));
- MDC.put(STATUS_CODE, COMPLETE_STATUS);
- MDC.put(RESPONSE_CODE, "0");
- MDC.put(classNameProp, "");
- auditLogger.info("{}", arg0);
- }
-
- /**
- * Records a message with passed in message text and variable number of arguments.
- *
- * @param message class name if one argument, otherwise message text
- * @param arguments variable number of arguments
- */
- public static void audit(String message, Object... arguments) {
- if (!auditLogger.isInfoEnabled()) {
- return;
- }
- MDC.put(INVOCATION_ID, postMdcInfoForEvent(null));
- MDC.put(STATUS_CODE, COMPLETE_STATUS);
- MDC.put(RESPONSE_CODE, "0");
- if (arguments.length == 1 && !OnapLoggingUtils.isThrowable(arguments[0])) {
- MDC.put(classNameProp, message);
- auditLogger.info("{}", arguments[0] == null ? "" : arguments[0].toString());
- return;
- }
-
- MDC.put(classNameProp, "");
- auditLogger.info(message, arguments);
- }
-
- /**
- * returns true for enabled, false for not enabled.
- */
- public static boolean isDebugEnabled() {
-
- return debugLogger.isDebugEnabled();
- }
-
- /**
- * returns true for enabled, false for not enabled.
- */
- public static boolean isErrorEnabled() {
-
- return errorLogger.isErrorEnabled();
- }
-
- /**
- * returns true for enabled, false for not enabled.
- */
- public static boolean isWarnEnabled() {
-
- return debugLogger.isWarnEnabled();
- }
-
- /**
- * returns true for enabled, false for not enabled.
- */
- public static boolean isInfoEnabled1() {
-
- return debugLogger.isInfoEnabled();
- }
-
- /**
- * returns true for enabled, false for not enabled.
- */
- public static boolean isAuditEnabled() {
-
- return debugLogger.isInfoEnabled();
- }
-
- /**
- * returns true for enabled, false for not enabled.
- */
- public static boolean isInfoEnabled() {
-
- return debugLogger.isInfoEnabled();
- }
-
- /**
- * Records only one String message with its class name.
- *
- * @param className the class name
- * @param arg0 the message
- */
- public static void trace(String className, String arg0) {
- MDC.put(classNameProp, className);
- debugLogger.trace(MessageCodes.GENERAL_INFO, arg0);
- }
-
- /**
- * Records only one String message.
- *
- * @param arg0 the message
- */
- public static void trace(Object arg0) {
-
- MDC.put(classNameProp, "");
- debugLogger.trace("{}", arg0);
- }
-
- /**
- * Records the starting time of the event with its request Id as the key.
- *
- * @param eventId the event ID
- */
- public static void recordAuditEventStart(String eventId) {
-
- MDC.put(STATUS_CODE, COMPLETE_STATUS);
- postMdcInfoForEvent(eventId);
-
- if (eventTracker == null) {
- eventTracker = new EventTrackInfo();
- }
- var event = new EventData();
- event.setRequestId(eventId);
- event.setStartTime(Instant.now());
- eventTracker.storeEventData(event);
- MDC.put(MDC_KEY_REQUEST_ID, eventId);
- debugLogger.info("CONCURRENTHASHMAP_LIMIT : {}", concurrentHashMapLimit);
- // --- Tracking the size of the concurrentHashMap, if it is above limit, keep EventTrack
- // Timer running
- int size = eventTracker.getEventInfo().size();
-
- debugLogger.info("EventInfo concurrentHashMap Size : {} on {}", size, new Date());
- debugLogger.info("isEventTrackerRunning : {}", isEventTrackerRunning);
-
- if (size >= concurrentHashMapLimit) {
-
-
- if (!isEventTrackerRunning) {
-
- startCleanUp();
- isEventTrackerRunning = true;
- }
-
- } else if (size <= stopCheckPoint && isEventTrackerRunning) {
-
- stopCleanUp();
- }
- }
-
- /**
- * Records the starting time of the event with its request Id as the key.
- *
- * @param eventId the event ID
- */
- public static void recordAuditEventStart(UUID eventId) {
-
- if (eventId == null) {
- return;
- }
-
- if (eventTracker == null) {
- eventTracker = new EventTrackInfo();
- }
-
- recordAuditEventStart(eventId.toString());
-
- }
-
- /**
- * Records the ending time of the event with its request Id as the key.
- *
- * @param eventId the event ID
- * @param rule the rule
- */
- public static void recordAuditEventEnd(String eventId, String rule) {
-
- if (eventTracker == null) {
- return;
- }
- if (eventId == null) {
- return;
- }
-
- creatAuditEventTrackingRecord(eventId, rule, "");
-
- }
-
- /**
- * Records the ending time of the event with its request Id as the key.
- *
- * @param eventId the event ID
- * @param rule the rule
- * @param policyVersion the policy version
- */
- public static void recordAuditEventEnd(String eventId, String rule, String policyVersion) {
-
- if (eventTracker == null) {
- return;
- }
- if (eventId == null) {
- return;
- }
-
- creatAuditEventTrackingRecord(eventId, rule, policyVersion);
-
- }
-
- /**
- * Records the ending time of the event with its request Id as the key.
- *
- * @param eventId the event ID
- * @param rule the rule
- * @param policyVersion the policy version
- */
- public static void recordAuditEventEnd(UUID eventId, String rule, String policyVersion) {
-
- if (eventId == null) {
- return;
- }
-
- recordAuditEventEnd(eventId.toString(), rule, policyVersion);
-
- }
-
-
- /**
- * Records the ending time of the event with its request Id as the key.
- *
- * @param eventId the event ID
- * @param rule the rule
- */
- public static void recordAuditEventEnd(UUID eventId, String rule) {
-
- if (eventId == null) {
- return;
- }
-
- recordAuditEventEnd(eventId.toString(), rule);
-
- }
-
- /**
- * Records the ending time of the event with its request Id as the key.
- *
- * @param eventId the event ID
- * @param rule the rule
- * @param policyVersion the policy version
- */
- public static void creatAuditEventTrackingRecord(String eventId, String rule, String policyVersion) {
-
- if (eventTracker == null) {
- return;
- }
-
- var event = eventTracker.getEventDataByRequestId(eventId);
-
- if (event != null) {
- Instant endTime = event.getEndTime();
- if (endTime == null) {
- endTime = Instant.now();
- }
- MDC.put(STATUS_CODE, COMPLETE_STATUS);
- recordAuditEventStartToEnd(eventId, rule, event.getStartTime(), endTime, policyVersion);
- }
- }
-
- /**
- * Records the ending time of the event with its request Id as the key.
- *
- * @param eventId the event ID
- * @param rule the rule
- */
- public static void creatAuditEventTrackingRecord(UUID eventId, String rule) {
-
- if (eventId == null) {
- return;
- }
-
- if (eventTracker == null) {
- return;
- }
-
- var event = eventTracker.getEventDataByRequestId(eventId.toString());
-
- if (event != null) {
- Instant endTime = event.getEndTime();
- if (endTime == null) {
- endTime = Instant.now();
- }
-
- recordAuditEventStartToEnd(eventId.toString(), rule, event.getStartTime(), endTime, "N/A");
- }
- }
-
- public static EventTrackInfo getEventTracker() {
- return eventTracker;
- }
-
- /**
- * Records the audit with an event starting and ending times.
- *
- * @param eventId the event ID
- * @param rule the rule
- * @param startTime the start time
- * @param endTime the end time
- * @param policyVersion the policy version
- */
- public static void recordAuditEventStartToEnd(String eventId, String rule, Instant startTime, Instant endTime,
- String policyVersion) {
-
- if (startTime == null || endTime == null) {
- return;
- }
- if (eventId != null && !eventId.isEmpty()) {
- MDC.put(MDC_KEY_REQUEST_ID, eventId);
- }
-
- seTimeStamps(startTime, endTime);
-
- MDC.put(RESPONSE_CODE, "N/A");
- MDC.put(RESPONSE_DESCRIPTION, "N/A");
-
- long ns = Duration.between(startTime, endTime).toMillis();
-
- auditLogger.info(MessageCodes.RULE_AUDIT_START_END_INFO, MDC.get(MDC_SERVICE_NAME), rule, startTime.toString(),
- endTime.toString(), Long.toString(ns), policyVersion);
-
- // --- remove the record from the concurrentHashMap
- if (eventTracker != null && eventTracker.getEventDataByRequestId(eventId) != null) {
-
- eventTracker.remove(eventId);
- debugLogger.info("eventTracker.remove({})", eventId);
-
- }
- }
-
- /**
- * Records the metrics with an event Id and log message.
- *
- * @param eventId the event ID
- * @param arg1 the message
- */
- public static void recordMetricEvent(String eventId, String arg1) {
-
- seTimeStamps();
-
- String serviceName = MDC.get(MDC_SERVICE_NAME);
- MDC.put(MDC_KEY_REQUEST_ID, eventId);
- MDC.put(STATUS_CODE, COMPLETE_STATUS);
- metricsLogger.info(MessageCodes.RULE_AUDIT_END_INFO, serviceName, arg1);
-
- }
-
- /**
- * Records the metrics with an event Id, class name and log message.
- *
- * @param eventId the event ID
- * @param className the class name
- * @param arg1 the message
- */
- public static void recordMetricEvent(String eventId, String className, String arg1) {
-
- seTimeStamps();
-
- MDC.put(classNameProp, className);
- String serviceName = MDC.get(MDC_SERVICE_NAME);
- MDC.put(MDC_KEY_REQUEST_ID, eventId);
- MDC.put(STATUS_CODE, COMPLETE_STATUS);
- metricsLogger.info(MessageCodes.RULE_AUDIT_END_INFO, serviceName, arg1);
- }
-
- /**
- * Records the metrics with an event Id and log message.
- *
- * @param eventId the event ID
- * @param arg1 the message
- */
- public static void recordMetricEvent(UUID eventId, String arg1) {
-
- if (eventId == null) {
- return;
- }
- String serviceName = MDC.get(MDC_SERVICE_NAME);
- MDC.put(MDC_KEY_REQUEST_ID, eventId.toString());
- metricsLogger.info(MessageCodes.RULE_AUDIT_END_INFO, serviceName, arg1);
- }
-
- /**
- * Records a String message for metrics logs.
- *
- * @param arg0 the message
- */
- public static void recordMetricEvent(String arg0) {
- seTimeStamps();
- String serviceName = MDC.get(MDC_SERVICE_NAME);
- metricsLogger.info(MessageCodes.RULE_METRICS_INFO, serviceName, arg0);
- }
-
-
- /**
- * Records the metrics event with a String message.
- *
- * @param arg0 the message
- */
- public static void metrics(String arg0) {
- seTimeStamps();
- MDC.put(INVOCATION_ID, MDC.get(MDC_KEY_REQUEST_ID));
- MDC.put(RESPONSE_CODE, "0");
- String serviceName = MDC.get(MDC_SERVICE_NAME);
- metricsLogger.info(MessageCodes.RULE_METRICS_INFO, serviceName, arg0);
- }
-
- /**
- * Records the metrics event with a String message.
- *
- * @param arg0 the message
- */
- public static void metrics(Object arg0) {
- seTimeStamps();
- MDC.put(INVOCATION_ID, MDC.get(MDC_KEY_REQUEST_ID));
- MDC.put(RESPONSE_CODE, "0");
- MDC.put(classNameProp, "");
- String serviceName = MDC.get(MDC_SERVICE_NAME);
- metricsLogger.info(MessageCodes.RULE_METRICS_INFO, serviceName, "" + arg0);
- }
-
- /**
- * Records a message with passed in message text and variable number of arguments.
- *
- * @param message class name if one argument, otherwise message text
- * @param arguments variable number of arguments
- */
- public static void metrics(String message, Object... arguments) {
- if (!metricsLogger.isInfoEnabled()) {
- return;
- }
- seTimeStamps();
- MDC.put(INVOCATION_ID, MDC.get(MDC_KEY_REQUEST_ID));
- MDC.put(RESPONSE_CODE, "0");
- if (arguments.length == 1 && !OnapLoggingUtils.isThrowable(arguments[0])) {
- MDC.put(classNameProp, message);
- String serviceName = MDC.get(MDC_SERVICE_NAME);
- metricsLogger.info(MessageCodes.RULE_METRICS_INFO, serviceName,
- arguments[0] == null ? "" : arguments[0].toString());
- return;
- }
- if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- String arguments2 = getNormalizedStackTrace((Throwable) arguments[0], "");
- metricsLogger.info(MessageCodes.RULE_METRICS_INFO, message + arguments2);
- return;
- }
-
- MDC.put(classNameProp, "");
- metricsLogger.info(message, arguments);
- }
-
- /**
- * Records the metrics event with a String message.
- *
- * @param arg0 the message
- */
- public static void metricsPrintln(String arg0) {
- MDC.clear();
- metricsLogger.info(arg0);
- }
-
- /**
- * Removes all the return lines from the printStackTrace.
- *
- * @param throwable the throwable
- * @param arguments the messages
- */
- private static String getNormalizedStackTrace(Throwable throwable, String... arguments) {
- var sw = new StringWriter();
- var pw = new PrintWriter(sw);
- throwable.printStackTrace(pw);
- String newStValue = sw.toString().replace('|', '!').replace("\n", " - ");
- int curSize = arguments == null ? 0 : arguments.length;
- var newArgument = new StringBuilder();
- for (var i = 0; i < curSize; i++) {
- newArgument.append(arguments[i]);
- newArgument.append(":");
- }
- newArgument.append(newStValue);
- return newArgument.toString();
- }
-
- /**
- * Starts the process of cleaning up the ConcurrentHashMap of EventData.
- */
- private static void startCleanUp() {
-
- if (!isEventTrackerRunning) {
- var ttrcker = new EventTrackInfoHandler();
- timer = new Timer(true);
- timer.scheduleAtFixedRate(ttrcker, timerDelayTime, checkInterval);
- debugLogger.info("EventTrackInfoHandler begins! : {}", new Date());
- } else {
- debugLogger.info("Timer is still running : {}", new Date());
-
- }
- }
-
-
- /**
- * Stops the process of cleaning up the ConcurrentHashMap of EventData.
- */
- private static void stopCleanUp() {
-
- if (isEventTrackerRunning && timer != null) {
- timer.cancel();
- timer.purge();
- debugLogger.info("Timer stopped: {}", new Date());
- } else {
- debugLogger.info("Timer was already stopped : {}", new Date());
-
- }
- isEventTrackerRunning = false;
-
- }
-
- /**
- * Loads all the attributes from policyLogger.properties file
- */
- public static LoggerType init(Properties properties) {
-
- var loggerProperties = getLoggerProperties(properties);
-
- // fetch and verify definitions of some properties
- try {
- setOverrideLogbackLevels(loggerProperties);
-
- setLoggerLevel(loggerProperties, "debugLogger.level", "INFO", PolicyLogger::setDebugLevel);
-
- // Only check if it is to turn on or off
- setLoggerOnOff(loggerProperties, "metricsLogger.level", PolicyLogger::setMetricsLevel);
- setLoggerOnOff(loggerProperties, "audit.level", PolicyLogger::setAuditLevel);
- setLoggerOnOff(loggerProperties, "error.level", PolicyLogger::setErrorLevel);
-
- isEventTrackerRunning = false;
-
- timerDelayTime = getIntProp(loggerProperties, "timer.delay.time", timerDelayTime);
- checkInterval = getIntProp(loggerProperties, "check.interval", checkInterval);
- expiredTime = getIntProp(loggerProperties, "event.expired.time", expiredTime);
- concurrentHashMapLimit = getIntProp(loggerProperties, "concurrentHashMap.limit", concurrentHashMapLimit);
- stopCheckPoint = getIntProp(loggerProperties, "stop.check.point", stopCheckPoint);
-
- component = loggerProperties.getProperty("policy.component", "DROOLS");
- debugLogger.info("component: {}", component);
-
- return detmLoggerType(loggerProperties);
-
- } catch (Exception e) {
- MDC.put(ERROR_CATEGORY, ERROR_CATEGORY_VALUE);
-
- if (ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR) != null) {
- MDC.put(ERROR_CODE, ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorCode());
- MDC.put(ERROR_DESCRIPTION, ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorDesc());
-
- }
- errorLogger.error("failed to get the policyLogger.properties, so use their default values", e);
-
- return LoggerType.EELF;
- }
-
- }
-
- private static int getIntProp(Properties properties, String propName, int defaultValue) {
- final var propValue = Integer.parseInt(properties.getProperty(propName, String.valueOf(defaultValue)));
-
- debugLogger.info("{} value: {}", propName, propValue);
-
- if (propValue > 0) {
- return propValue;
-
- } else {
- MDC.put(ERROR_CATEGORY, ERROR_CATEGORY_VALUE);
- if (ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR) != null) {
- MDC.put(ERROR_CODE, ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorCode());
- MDC.put(ERROR_DESCRIPTION,
- ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR).getErrorDesc());
-
- }
- errorLogger.error("failed to get the {}, so use its default value: {}", propName, defaultValue);
- return defaultValue;
- }
- }
-
- private static Properties getLoggerProperties(Properties properties) {
- if (properties != null) {
- return properties;
- } else {
- displayErrorMessage("PolicyLogger cannot find its configuration - continue");
- return new Properties();
- }
- }
-
- private static void setLoggerLevel(Properties properties, String propName, String defaultValue,
- Consumer setter) {
-
- final String propValue = properties.getProperty(propName, defaultValue);
-
- if (!StringUtils.isBlank(propValue)) {
- debugLogger.info("{} level: {}", propName, propValue);
- }
-
- setter.accept(propValue);
- }
-
- private static void setLoggerOnOff(Properties properties, String propName, Consumer setter) {
- final String propValue = properties.getProperty(propName, "ON");
-
- if (Level.OFF.toString().equalsIgnoreCase(propValue)) {
- debugLogger.info("{} level: {}", propName, propValue);
- }
-
- setter.accept(propValue);
- }
-
- private static void setOverrideLogbackLevels(Properties loggerProperties) {
- final var overrideLogbackLevelText = loggerProperties.getProperty("override.logback.level.setup");
-
- if (!StringUtils.isBlank(overrideLogbackLevelText)) {
- overrideLogbackLevel = "TRUE".equalsIgnoreCase(overrideLogbackLevelText);
- }
- }
-
- private static LoggerType detmLoggerType(Properties loggerProperties) {
- final String loggerTypeProp = loggerProperties.getProperty("logger.type", LoggerType.EELF.toString());
- debugLogger.info("loggerType value: {}", loggerTypeProp);
-
- switch (loggerTypeProp.toUpperCase()) {
- case "EELF":
- return LoggerType.EELF;
- case "SYSTEMOUT":
- return LoggerType.SYSTEMOUT;
-
- default:
- return LoggerType.EELF;
- }
- }
-
- /**
- * Sets server information to MDC.
- */
- public static void setServerInfo(String serverHost, String serverPort) {
- MDC.put(SERVER_NAME, serverHost + ":" + serverPort);
- }
-
- /**
- * Sets error category, code and description.
- */
- private static void setErrorCode(MessageCodes errcode) {
- MDC.put(ERROR_CATEGORY, ERROR_CATEGORY_VALUE);
- if (ErrorCodeMap.getErrorCodeInfo(errcode) != null) {
- MDC.put(ERROR_CODE, ErrorCodeMap.getErrorCodeInfo(errcode).getErrorCode());
- MDC.put(ERROR_DESCRIPTION, ErrorCodeMap.getErrorCodeInfo(errcode).getErrorDesc());
- } else {
- MDC.put(ERROR_CODE,
- ErrorCodeMap.getErrorCodeInfo(MessageCodes.ERROR_UNKNOWN).getErrorCode());
- MDC.put(ERROR_DESCRIPTION,
- ErrorCodeMap.getErrorCodeInfo(MessageCodes.ERROR_UNKNOWN).getErrorDesc());
- }
- }
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/DisplayUtils.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/DisplayUtils.java
deleted file mode 100644
index 425c62a4..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/DisplayUtils.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2019-2021 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.flexlogger;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-/**
- * Utilities to display messages. These are generally used while logging is being
- * configured, or when logging being directed to System.out. As a result, it directly
- * writes to System.out rather than to a logger.
- */
-
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public class DisplayUtils {
-
- /*
- * As the comment above says, these purposely write to System.out rather than a
- * logger, thus sonar is disabled.
- */
-
- public static void displayMessage(Object message) {
- System.out.println(message); // NOSONAR
- }
-
- public static void displayErrorMessage(Object msg) {
- System.err.println(msg); // NOSONAR
- }
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java
deleted file mode 100644
index 0e0ef2bf..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java
+++ /dev/null
@@ -1,575 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2021 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.flexlogger;
-
-import com.att.eelf.configuration.EELFLogger.Level;
-import java.io.Serializable;
-import java.util.UUID;
-import lombok.Getter;
-import org.onap.policy.common.logging.eelf.MessageCodes;
-import org.onap.policy.common.logging.eelf.PolicyLogger;
-
-/**
- * EelfLogger implements all the methods of interface Logger by calling PolicyLogger methods.
- */
-
-public class EelfLogger implements Logger, Serializable {
-
- private static final long serialVersionUID = 5385586713941277192L;
- private String className = "";
- @Getter
- private String transId = UUID.randomUUID().toString();
-
- /**
- * Constructor.
- *
- * @param clazz the class
- */
- public EelfLogger(Class> clazz) {
- if (clazz != null) {
- className = clazz.getName();
- }
- PolicyLogger.postMdcInfoForEvent(null);
- }
-
- /**
- * Constructor.
- *
- * @param className the class name
- */
- public EelfLogger(String className) {
- if (className != null) {
- this.className = className;
- }
- PolicyLogger.postMdcInfoForEvent(null);
- }
-
- /**
- * Constructor.
- *
- * @param clazz the class
- * @param isNewTransaction is a new transaction
- */
- public EelfLogger(Class> clazz, boolean isNewTransaction) {
- if (clazz != null) {
- className = clazz.getName();
- }
- if (isNewTransaction) {
- transId = PolicyLogger.postMdcInfoForEvent(null);
- } else {
- transId = PolicyLogger.getTransId();
- }
- }
-
- /**
- * Constructor.
- *
- * @param className the class name
- * @param isNewTransaction is a new transaction
- */
- public EelfLogger(String className, boolean isNewTransaction) {
- if (className != null) {
- this.className = className;
- }
- if (isNewTransaction) {
- transId = PolicyLogger.postMdcInfoForEvent(null);
- } else {
- transId = PolicyLogger.getTransId();
- }
- }
-
- /**
- * Constructor.
- *
- * @param clazz the class
- * @param transId the transaction ID
- */
- public EelfLogger(Class> clazz, String transId) {
- if (clazz != null) {
- className = clazz.getName();
- }
- PolicyLogger.postMdcInfoForEvent(transId);
- this.transId = transId;
- }
-
- /**
- * Constructor.
- *
- * @param className the class name
- * @param transId the transaction ID
- */
- public EelfLogger(String className, String transId) {
- if (className != null) {
- this.className = className;
- }
- PolicyLogger.postMdcInfoForEvent(transId);
- this.transId = transId;
- }
-
- /**
- * Sets transaction Id for logging.
- *
- * @param transId the transaction ID
- */
- @Override
- public void setTransId(String transId) {
-
- PolicyLogger.setTransId(transId);
- this.transId = transId;
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- */
- @Override
- public void debug(Object message) {
- PolicyLogger.debug(className, "" + message);
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- * @param throwable the throwable
- */
- @Override
- public void debug(Object message, Throwable throwable) {
- PolicyLogger.debug(MessageCodes.GENERAL_INFO, throwable, message.toString());
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- * @param arguments the arguments for message
- */
- @Override
- public void debug(String message, Object... arguments) {
- PolicyLogger.debug(message, arguments);
- }
-
- /**
- * Records an error message.
- *
- * @param message the message
- */
- @Override
- public void error(Object message) {
- PolicyLogger.error(className, "" + message);
- }
-
- /**
- * Records an error message.
- *
- * @param message the message
- * @param throwable the throwable
- */
- @Override
- public void error(Object message, Throwable throwable) {
- PolicyLogger.error(MessageCodes.ERROR_UNKNOWN, throwable, message.toString());
- }
-
- /**
- * Records an error message.
- *
- * @param msg the message code
- * @param throwable the throwable
- * @param arguments the messages
- */
- @Override
- public void error(MessageCodes msg, Throwable throwable, String... arguments) {
- PolicyLogger.error(msg, className, throwable, arguments);
- }
-
- /**
- * Records an error message.
- *
- * @param msg the message code
- * @param arguments the messages
- */
- @Override
- public void error(MessageCodes msg, String... arguments) {
- PolicyLogger.error(msg, arguments);
- }
-
- /**
- * Records an error message.
- *
- * @param message the message
- * @param arguments the arguments for message
- */
- @Override
- public void error(String message, Object... arguments) {
- PolicyLogger.error(message, arguments);
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- */
- @Override
- public void info(Object message) {
- PolicyLogger.info(className, "" + message);
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- * @param throwable the throwable
- */
- @Override
- public void info(Object message, Throwable throwable) {
- PolicyLogger.info(MessageCodes.GENERAL_INFO, throwable, message.toString());
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- * @param arguments the arguments for message
- */
- @Override
- public void info(String message, Object... arguments) {
- PolicyLogger.info(message, arguments);
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- */
- @Override
- public void warn(Object message) {
- PolicyLogger.warn(className, "" + message);
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- * @param throwable the throwable
- */
- @Override
- public void warn(Object message, Throwable throwable) {
- PolicyLogger.warn(MessageCodes.GENERAL_WARNING, throwable, message.toString());
- }
-
- /**
- * Records a message.
- *
- * @param msg the message codes
- * @param arguments the messages
- */
- @Override
- public void warn(MessageCodes msg, String... arguments) {
- PolicyLogger.warn(msg, className, arguments);
- }
-
- /**
- * Records a message.
- *
- * @param msg the message
- * @param throwable the throwable
- * @param arguments the messages
- */
- @Override
- public void warn(MessageCodes msg, Throwable throwable, String... arguments) {
- PolicyLogger.warn(msg, className, throwable, arguments);
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- * @param arguments the arguments for message
- */
- @Override
- public void warn(String message, Object... arguments) {
- PolicyLogger.warn(message, arguments);
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- */
- @Override
- public void trace(Object message) {
- PolicyLogger.trace(className, "" + message);
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- * @param throwable the throwable
- */
- @Override
- public void trace(Object message, Throwable throwable) {
- PolicyLogger.trace(message);
- }
-
- /**
- * Returns true for debug enabled, or false for not.
- *
- * @return boolean
- */
- @Override
- public boolean isDebugEnabled() {
- return PolicyLogger.isDebugEnabled();
- }
-
- /**
- * Returns true for info enabled, or false for not.
- *
- * @return boolean
- */
- @Override
- public boolean isInfoEnabled() {
- return PolicyLogger.isInfoEnabled();
- }
-
- /**
- * Returns true for warn enabled, or false for not.
- *
- * @return boolean
- */
- @Override
- public boolean isWarnEnabled() {
- return PolicyLogger.isWarnEnabled();
- }
-
- /**
- * Returns true for error enabled, or false for not.
- *
- * @return boolean
- */
- @Override
- public boolean isErrorEnabled() {
- return PolicyLogger.isErrorEnabled();
- }
-
- /**
- * Returns true for audit enabled, or false for not.
- *
- * @return boolean
- */
- @Override
- public boolean isAuditEnabled() {
- return (PolicyLogger.getAuditLevel() != Level.OFF);
- }
-
- /**
- * Returns true for metrics enabled, or false for not.
- *
- * @return boolean
- */
- @Override
- public boolean isMetricsEnabled() {
- return (PolicyLogger.getMetricsLevel() != Level.OFF);
- }
-
- /**
- * Returns true for trace enabled, or false for not.
- *
- * @return boolean
- */
- @Override
- public boolean isTraceEnabled() {
- return PolicyLogger.isDebugEnabled();
- }
-
- /**
- * Records an audit message.
- *
- * @param arg0 the message
- */
- @Override
- public void audit(Object arg0) {
- PolicyLogger.audit(className, "" + arg0);
- }
-
- /**
- * Records an audit message.
- *
- * @param message the message
- * @param throwable the throwable
- */
- @Override
- public void audit(Object message, Throwable throwable) {
- PolicyLogger.audit(message);
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- * @param arguments the arguments for message
- */
- @Override
- public void audit(String message, Object... arguments) {
- PolicyLogger.audit(message, arguments);
- }
-
- /**
- * Records an audit message.
- *
- * @param eventId the event ID
- */
- @Override
- public void recordAuditEventStart(String eventId) {
- PolicyLogger.recordAuditEventStart(eventId);
- }
-
- /**
- * Records an audit message.
- *
- * @param eventId the event ID
- */
- @Override
- public void recordAuditEventStart(UUID eventId) {
- PolicyLogger.recordAuditEventStart(eventId);
- }
-
- /**
- * Records an audit message.
- *
- * @param eventId the event ID
- * @param rule the rule
- * @param policyVersion the policy cersion
- */
- @Override
- public void recordAuditEventEnd(String eventId, String rule, String policyVersion) {
- PolicyLogger.recordAuditEventEnd(eventId, rule, policyVersion);
- }
-
- /**
- * Records an audit message.
- *
- * @param eventId the event ID
- * @param rule the rule
- * @param policyVersion the policy version
- */
- @Override
- public void recordAuditEventEnd(UUID eventId, String rule, String policyVersion) {
- PolicyLogger.recordAuditEventEnd(eventId, rule, policyVersion);
- }
-
- /**
- * Records an audit message.
- *
- * @param eventId the event ID
- * @param rule the rule
- */
- @Override
- public void recordAuditEventEnd(String eventId, String rule) {
- PolicyLogger.recordAuditEventEnd(eventId, rule);
- }
-
- /**
- * Records an audit message.
- *
- * @param eventId the event ID
- * @param rule the rule
- */
- @Override
- public void recordAuditEventEnd(UUID eventId, String rule) {
- PolicyLogger.recordAuditEventEnd(eventId, rule);
- }
-
- /**
- * Records a metrics message.
- *
- * @param eventId the event ID
- * @param message the message
- */
- @Override
- public void recordMetricEvent(String eventId, String message) {
- PolicyLogger.recordMetricEvent(eventId, message);
- }
-
- /**
- * Records a metrics message.
- *
- * @param eventId the event ID
- * @param message the message
- */
- @Override
- public void recordMetricEvent(UUID eventId, String message) {
- PolicyLogger.recordMetricEvent(eventId, message);
- }
-
- /**
- * Records a metrics message.
- *
- * @param message the message
- */
- @Override
- public void metrics(Object message) {
- PolicyLogger.metrics(className, message);
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- * @param arguments the arguments for message
- */
- @Override
- public void metrics(String message, Object... arguments) {
- PolicyLogger.metrics(message, arguments);
- }
-
- /**
- * Populates MDC Info.
- *
- * @param transId the transaction ID
- */
- @Override
- public String postMdcInfoForEvent(String transId) {
- return PolicyLogger.postMdcInfoForEvent(transId);
- }
-
- /**
- * Populates MDC Info.
- *
- * @param obj the object
- */
- @Override
- public void postMdcInfoForEvent(Object obj) {
- PolicyLogger.postMdcInfoForEvent(obj);
- }
-
- /**
- * Populates MDC Info for the rule triggered.
- *
- * @param transId the transaction ID
- */
- @Override
- public void postMdcInfoForTriggeredRule(String transId) {
- PolicyLogger.postMdcInfoForTriggeredRule(transId);
- }
-
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java
deleted file mode 100644
index 7bfcb5d4..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.flexlogger;
-
-import static org.onap.policy.common.logging.flexlogger.DisplayUtils.displayMessage;
-
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.time.Instant;
-import java.util.Date;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import org.onap.policy.common.logging.eelf.PolicyLogger;
-import org.onap.policy.common.logging.flexlogger.PropertyUtil.Listener;
-
-/**
- * FlexLogger acts as factory to generate instances of Logger based on logger type.
- */
-public class FlexLogger {
-
- private static final String GET_LOGGER_PREFIX = "FlexLogger:getLogger : loggerType = ";
- private static LoggerType loggerType = LoggerType.EELF;
- private static ConcurrentHashMap eelfLoggerMap = new ConcurrentHashMap<>();
- private static ConcurrentHashMap systemOutMap = new ConcurrentHashMap<>();
-
- // --- init logger first
- static {
- loggerType = initLogger();
- }
-
- /**
- * Returns an instance of Logger.
- *
- * @param clazz the class
- */
- public static Logger getLogger(Class> clazz) {
- return getLogger(clazz, false);
- }
-
- /**
- * Returns an instance of Logger.
- */
- public static Logger getLogger() {
- return getLogger(null);
- }
-
- /**
- * Returns an instance of Logger.
- *
- * @param clazz the class
- * @param isNewTransaction is a new transaction
- */
- public static Logger getLogger(Class> clazz, boolean isNewTransaction) {
- Logger logger;
- displayMessage(GET_LOGGER_PREFIX + loggerType);
- if (loggerType == LoggerType.EELF) {
- logger = getEelfLogger(clazz, isNewTransaction);
- } else {
- logger = getSystemOutLogger();
- }
-
- return logger;
- }
-
- /**
- * Returns an instance of Logger.
- *
- * @param isNewTransaction is a new transaction
- */
- public static Logger getLogger(boolean isNewTransaction) {
- return getLogger(null, isNewTransaction);
- }
-
- /**
- * Returns the calling class name.
- */
- public String getClassName() {
- StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
- if (stackTrace.length > 3) {
- return stackTrace[3].getClassName();
- }
- return "UnknownClass";
- }
-
- /**
- * Returns an instance of EelfLogger.
- *
- * @param clazz the class
- * @param isNewTransaction is a new transaction
- */
- private static EelfLogger getEelfLogger(Class> clazz, boolean isNewTransaction) {
-
- String className;
- EelfLogger logger;
- if (clazz != null) {
- className = clazz.getName();
- } else {
- className = new FlexLogger().getClassName();
- }
-
- logger = eelfLoggerMap.computeIfAbsent(className, key -> new EelfLogger(clazz, isNewTransaction));
-
- if (isNewTransaction) {
- String transId = PolicyLogger.postMdcInfoForEvent(null);
- logger.setTransId(transId);
- }
-
- displayMessage("eelfLoggerMap size : " + eelfLoggerMap.size() + " class name: " + className);
- return logger;
- }
-
- /**
- * Returns an instance of SystemOutLogger.
- */
- private static SystemOutLogger getSystemOutLogger() {
-
- String className = new FlexLogger().getClassName();
-
- return systemOutMap.computeIfAbsent(className, SystemOutLogger::new);
- }
-
- /**
- * loads the logger properties.
- */
- private static LoggerType initLogger() {
- var loggerType = LoggerType.EELF;
- Properties properties = null;
-
- try {
- properties = PropertyUtil.getProperties("config/policyLogger.properties");
- displayMessage("FlexLogger:properties => " + properties);
-
- String overrideLogbackLevel = properties.getProperty("override.logback.level.setup");
- displayMessage("FlexLogger:overrideLogbackLevel => " + overrideLogbackLevel);
- var loggerTypeString = properties.getProperty("logger.type");
- if ("EELF".equalsIgnoreCase(loggerTypeString) && "TRUE".equalsIgnoreCase(overrideLogbackLevel)) {
- displayMessage("FlexLogger: start listener.");
- properties = PropertyUtil.getProperties("config/policyLogger.properties",
- new PropertiesCallBack("FlexLogger-CallBack"));
- }
- } catch (IOException e1) {
- displayMessage("initLogger" + e1);
- } finally {
- // OK to pass no properties (null)
- loggerType = PolicyLogger.init(properties);
- }
-
- return loggerType;
- }
-
- /**
- * PropertiesCallBack is listening any updates on the policyLogger.properties
- */
- public static class PropertiesCallBack implements Listener {
- String name;
-
- public PropertiesCallBack(String name) {
- this.name = name;
- }
-
- /**
- * This method will be called automatically if he policyLogger.properties got updated
- */
- @Override
- public void propertiesChanged(Properties properties, Set changedKeys) {
-
- String debugLevel = properties.getProperty("debugLogger.level");
- String metricsLevel = properties.getProperty("metricsLogger.level");
- String auditLevel = properties.getProperty("audit.level");
- String errorLevel = properties.getProperty("error.level");
-
- var sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS+00:00");
- var startTime = Instant.now();
- String formattedTime = sdf.format(Date.from(startTime));
- displayMessage("FlexLogger.propertiesChanged : called at time : " + formattedTime);
- displayMessage("FlexLogger.propertiesChanged : debugLevel : " + debugLevel);
-
- if (changedKeys != null) {
-
- if (changedKeys.contains("debugLogger.level")) {
- PolicyLogger.setDebugLevel(debugLevel);
- }
-
- if (changedKeys.contains("metricsLogger.level")) {
- PolicyLogger.setMetricsLevel(metricsLevel);
- }
-
- if (changedKeys.contains("error.level")) {
- PolicyLogger.setErrorLevel(errorLevel);
- }
-
- if (changedKeys.contains("audit.level")) {
- PolicyLogger.setAuditLevel(auditLevel);
- }
- }
- }
- }
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger.java
deleted file mode 100644
index ad155a4c..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2020 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.flexlogger;
-
-import java.util.UUID;
-import org.onap.policy.common.logging.eelf.MessageCodes;
-
-/**
- * Interface Logger - implemented by Logger4J, EelfLogger and SystemOutLogger.
- *
- */
-public interface Logger {
-
- /**
- * Prints messages with the level.DEBUG
- */
- public void debug(Object message);
-
- /**
- * Prints messages with the level.DEBUG
- */
- public void debug(Object message, Throwable throwable);
-
- /**
- * Prints messages with the level.DEBUG
- */
- public void debug(String message, Object... arguments);
-
- /**
- * Prints messages with the level.ERROR
- */
- public void error(Object message);
-
- /**
- * Prints messages with the level.ERROR
- */
- public void error(Object message, Throwable throwable);
-
- /**
- * Prints messages with the level.ERROR
- */
- public void error(MessageCodes msg, String... arguments);
-
- /**
- * Prints messages with the level.ERROR
- */
- public void error(MessageCodes msg, Throwable arg0, String... arguments);
-
- /**
- * Prints messages with the level.ERROR
- */
- public void error(String message, Object... arguments);
-
- /**
- * Prints messages with the level.INFO
- */
- public void info(Object message);
-
- /**
- * Prints messages with the level.INFO
- */
- public void info(Object message, Throwable throwable);
-
- /**
- * Prints messages with the level.INFO
- */
- public void info(String message, Object... arguments);
-
- /**
- * Prints messages with the level.WARN
- */
- public void warn(Object message);
-
- /**
- * Prints messages with the level.WARN
- */
- public void warn(Object message, Throwable throwable);
-
- /**
- * Prints messages with the level.WARN
- */
- public void warn(MessageCodes msg, String... arguments);
-
- /**
- * Prints messages with the level.WARN
- */
- public void warn(MessageCodes msg, Throwable arg0, String... arguments);
-
- /**
- * Prints messages with the level.WARN
- */
- public void warn(String message, Object... arguments);
-
- /**
- * Prints messages with the level.TRACE
- */
- public void trace(Object message);
-
- /**
- * Prints messages with the level.TRACE
- */
- public void trace(Object message, Throwable throwable);
-
- /**
- * Prints messages in audit log with the level.INFO
- */
- public void audit(Object arg0);
-
- /**
- * Prints messages in audit log with the level.INFO
- */
- public void audit(Object arg0, Throwable throwable);
-
- /**
- * Prints messages in audit log with the level.INFO
- */
- public void audit(String message, Object... arguments);
-
- /**
- * Records event Id in audit log with the level.INFO
- */
- public void recordAuditEventStart(String eventId);
-
- /**
- * Records the starting time of the event with its request Id as the key.
- */
- public void recordAuditEventStart(UUID eventId);
-
- /**
- * Records the ending time of the event with its request Id as the key.
- */
- public void recordAuditEventEnd(String eventId, String rule, String policyVersion);
-
- /**
- * Records the ending time of the event with its request Id as the key.
- */
- public void recordAuditEventEnd(UUID eventId, String rule, String policyVersion);
-
- /**
- * Records the ending time of the event with its request Id as the key.
- */
- public void recordAuditEventEnd(String eventId, String rule);
-
- /**
- * Records the ending time of the event with its request Id as the key.
- */
- public void recordAuditEventEnd(UUID eventId, String rule);
-
-
- /**
- * Records the Metrics with event Id and log message.
- */
- public void recordMetricEvent(String eventId, String arg1);
-
- /**
- * Records the Metrics with event Id and log message.
- */
- public void recordMetricEvent(UUID eventId, String arg1);
-
- /**
- * Records the Metrics log message.
- */
- public void metrics(Object arg0);
-
- /**
- * Records the Metrics log message.
- */
- public void metrics(String message, Object... arguments);
-
- /**
- * Returns a boolean value, true for debug logging enabled, false for not enabled.
- */
- public boolean isDebugEnabled();
-
- /**
- * Returns a boolean value, true for error logging enabled, false for not enabled.
- */
- public boolean isErrorEnabled();
-
- /**
- * Returns a boolean value, true for warn logging enabled, false for not enabled.
- */
- public boolean isWarnEnabled();
-
- /**
- * Returns a boolean value, true for info logging enabled, false for not enabled.
- */
- public boolean isInfoEnabled();
-
- /**
- * Returns a boolean value, true for error logging enabled, false for not enabled.
- */
- public boolean isAuditEnabled();
-
- /**
- * Returns a boolean value, true for warn logging enabled, false for not enabled.
- */
- public boolean isMetricsEnabled();
-
- /**
- * Returns a boolean value, true for trace logging enabled, false for not enabled.
- */
- public boolean isTraceEnabled();
-
-
- /**
- * Populates MDC info.
- */
- public String postMdcInfoForEvent(String transId);
-
- /**
- * Populates MDC Info.
- */
- public void postMdcInfoForEvent(Object obj);
-
- /**
- * Sets transaction Id.
- */
- public void setTransId(String transId);
-
- /**
- * Returns transaction Id.
- */
- String getTransId();
-
- /**
- * Populates MDC Info for the rule triggered.
- */
- public void postMdcInfoForTriggeredRule(String transId);
-
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/LoggerType.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/LoggerType.java
deleted file mode 100644
index f73bc4bc..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/LoggerType.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2020 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.flexlogger;
-
-/**
- * Logger types.
- */
-public enum LoggerType {
- EELF, SYSTEMOUT
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java
deleted file mode 100644
index ef6c2e95..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2021 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.flexlogger;
-
-import static org.onap.policy.common.logging.flexlogger.DisplayUtils.displayErrorMessage;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-/**
- * This class provides utilities to read properties from a properties file, and optionally get
- * notifications of future changes.
- */
-public final class PropertyUtil {
-
-
- @NoArgsConstructor(access = AccessLevel.PRIVATE)
- protected static class LazyHolder {
- /**
- * Timer thread. Will not be allocated by the JVM until it is first referenced.
- * This may be overridden by junit tests.
- */
- private static Timer timer = new Timer("PropertyUtil-Timer", true);
- }
-
- // this table maps canonical file into a 'ListenerRegistration' instance
- private static HashMap registrations = new HashMap<>();
-
- /**
- * Read in a properties file.
- *
- * @param file the properties file
- * @return a Properties object, containing the associated properties
- * @throws IOException - subclass 'FileNotFoundException' if the file does not exist or can't be
- * opened, and 'IOException' if there is a problem loading the properties file.
- */
- public static Properties getProperties(File file) throws IOException {
- // create an InputStream (may throw a FileNotFoundException)
- try (var fis = new FileInputStream(file)) {
- // create the properties instance
- var rval = new Properties();
-
- // load properties (may throw an IOException)
- rval.load(fis);
- return rval;
- }
- }
-
- /**
- * Read in a properties file.
- *
- * @param fileName the properties file
- * @return a Properties object, containing the associated properties
- * @throws IOException - subclass 'FileNotFoundException' if the file does not exist or can't be
- * opened, and 'IOException' if there is a problem loading the properties file.
- */
- public static Properties getProperties(String fileName) throws IOException {
- return getProperties(new File(fileName));
- }
-
- /* ============================================================ */
-
- /**
- * This is the callback interface, used for sending notifications of changes in the properties
- * file.
- */
- @FunctionalInterface
- public interface Listener {
- /**
- * Notification of a properties file change.
- *
- * @param properties the new properties
- * @param changedKeys the set of property names that have changed, including additions and
- * removals
- */
- void propertiesChanged(Properties properties, Set changedKeys);
- }
-
- /**
- * This is an internal class - one instance of this exists for each property file that is being
- * monitored. Note that multiple listeners can be registered for the same file.
- */
- private static class ListenerRegistration {
- // the canonical path of the file being monitored
- File file;
-
- // the most recent value of 'file.lastModified()'
- long lastModified;
-
- // the most recent set of properties
- Properties properties;
-
- // the set of listeners monitoring this file
- LinkedList listeners;
-
- // the 'TimerTask' instance, used for periodic polling
- TimerTask timerTask;
-
- /**
- * Constructor - create a 'ListenerRegistration' instance for this file, but with no
- * listeners.
- */
- ListenerRegistration(File file) throws IOException {
- this.file = file;
-
- // The initial value of 'lastModified' is set to 0 to ensure that we
- // correctly handle the case where the file is modified within the
- // same second that polling begins.
- lastModified = 0;
-
- // fetch current properties
- properties = getProperties(file);
-
- // no listeners yet
- listeners = new LinkedList<>();
-
- // add to static table, so this instance can be shared
- registrations.put(file, this);
-
- // create and schedule the timer task, so this is periodically polled
- timerTask = new TimerTask() {
- @Override
- public void run() {
- try {
- poll();
- } catch (Exception e) {
- displayErrorMessage(e);
- }
- }
- };
- LazyHolder.timer.schedule(timerTask, 10000L, 10000L);
- }
-
- /**
- * Add a listener to the notification list.
- *
- * @param listener this is the listener to add to the list
- * @return the properties at the moment the listener was added to the list
- */
- synchronized Properties addListener(Listener listener) {
- listeners.add(listener);
- return (Properties) properties.clone();
- }
-
- /**
- * Remove a listener from the notification list.
- *
- * @param listener this is the listener to remove
- */
- synchronized void removeListener(Listener listener) {
- listeners.remove(listener);
-
- // See if we need to remove this 'ListenerRegistration' instance
- // from the table. The 'synchronized' block is needed in case
- // another listener is being added at about the same time that this
- // one is being removed.
- synchronized (registrations) {
- if (listeners.isEmpty()) {
- timerTask.cancel();
- registrations.remove(file);
- }
- }
- }
-
- /**
- * This method is periodically called to check for property list updates.
- *
- * @throws IOException if there is an error in reading the properties file
- */
- synchronized void poll() throws IOException {
- long timestamp = file.lastModified();
- if (timestamp != lastModified) {
- // update the record, and send out the notifications
- lastModified = timestamp;
-
- // Save old set, and initial set of changed properties.
- var oldProperties = properties;
- HashSet changedProperties = new HashSet<>(oldProperties.stringPropertyNames());
-
- // Fetch the list of listeners that we will potentially notify,
- // and the new properties. Note that this is in a 'synchronized'
- // block to ensure that all listeners receiving notifications
- // actually have a newer list of properties than the one
- // returned on the initial 'getProperties' call.
- properties = getProperties(file);
-
- Set newPropertyNames = properties.stringPropertyNames();
- changedProperties.addAll(newPropertyNames);
-
- // At this point, 'changedProperties' is the union of all properties
- // in both the old and new properties files. Iterate through all
- // of the entries in the new properties file - if the entry
- // matches the one in the old file, remove it from
- // 'changedProperties'.
- for (String name : newPropertyNames) {
- if (properties.getProperty(name).equals(oldProperties.getProperty(name))) {
- // Apparently, any property that exists must be of type
- // 'String', and can't be null. For this reason, we don't
- // need to worry about the case where
- // 'properties.getProperty(name)' returns 'null'. Note that
- // 'oldProperties.getProperty(name)' may be 'null' if the
- // old property does not exist.
- changedProperties.remove(name);
- }
- }
-
- // 'changedProperties' should be correct at this point
- if (!changedProperties.isEmpty()) {
- // there were changes - notify everyone in 'listeners'
- for (final Listener notify : listeners) {
- // Copy 'properties' and 'changedProperties', so it doesn't
- // cause problems if the recipient makes changes.
- final var tmpProperties = (Properties) (properties.clone());
- final HashSet tmpChangedProperties = new HashSet<>(changedProperties);
-
- // Do the notification in a separate thread, so blocking
- // won't cause any problems.
- new Thread() {
- @Override
- public void run() {
- notify.propertiesChanged(tmpProperties, tmpChangedProperties);
- }
- }.start();
- }
- }
- }
- }
- }
-
- /**
- * Read in a properties file, and register for update notifications. NOTE: it is possible that
- * the first callback will occur while this method is still in progress. To avoid this problem,
- * use 'synchronized' blocks around this invocation and in the callback -- that will ensure that
- * the processing of the initial properties complete before any updates are processed.
- *
- * @param file the properties file
- * @param listener notify if not null, this is a callback interface that is used for
- * notifications of changes
- * @return a Properties object, containing the associated properties
- * @throws IOException - subclass 'FileNotFoundException' if the file does not exist or can't be
- * opened, and 'IOException' if there is a problem loading the properties file.
- */
- public static Properties getProperties(File file, Listener listener) throws IOException {
- if (listener == null) {
- // no listener specified -- just fetch the properties
- return getProperties(file);
- }
-
- // Convert the file to a canonical form in order to avoid the situation
- // where different names refer to the same file.
- var tempFile = file.getCanonicalFile();
-
- // See if there is an existing registration. The 'synchronized' block
- // is needed to handle the case where a new listener is added at about
- // the same time that another one is being removed.
- synchronized (registrations) {
- ListenerRegistration reg = registrations.get(tempFile);
- if (reg == null) {
- // a new registration is needed
- reg = new ListenerRegistration(tempFile);
- }
- return reg.addListener(listener);
- }
- }
-
- /**
- * Read in a properties file, and register for update notifications. NOTE: it is possible that
- * the first callback will occur while this method is still in progress. To avoid this problem,
- * use 'synchronized' blocks around this invocation and in the callback -- that will ensure that
- * the processing of the initial properties complete before any updates are processed.
- *
- * @param fileName the properties file
- * @param listener notify if not null, this is a callback interface that is used for
- * notifications of changes
- * @return a Properties object, containing the associated properties
- * @throws IOException - subclass 'FileNotFoundException' if the file does not exist or can't be
- * opened, and 'IOException' if there is a problem loading the properties file.
- */
- public static Properties getProperties(String fileName, Listener listener) throws IOException {
- return getProperties(new File(fileName), listener);
- }
-
- /**
- * Stop listenening for updates.
- *
- * @param file the properties file
- * @param listener notify if not null, this is a callback interface that was used for
- * notifications of changes
- * @throws IOException If an I/O error occurs
- */
- public static void stopListening(File file, Listener listener) throws IOException {
- if (listener != null) {
- ListenerRegistration reg = registrations.get(file.getCanonicalFile());
- if (reg != null) {
- reg.removeListener(listener);
- }
- }
- }
-
- /**
- * Stop listenening for updates.
- *
- * @param fileName the properties file
- * @param listener notify if not null, this is a callback interface that was used for
- * notifications of changes
- * @throws IOException If an I/O error occurs
- */
- public static void stopListening(String fileName, Listener listener) throws IOException {
- stopListening(new File(fileName), listener);
- }
-
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java
deleted file mode 100644
index d16a1d7a..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java
+++ /dev/null
@@ -1,548 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2021 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.flexlogger;
-
-import static org.onap.policy.common.logging.flexlogger.DisplayUtils.displayMessage;
-
-import com.att.eelf.configuration.EELFLogger.Level;
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.UUID;
-import lombok.Getter;
-import org.onap.policy.common.logging.OnapLoggingUtils;
-import org.onap.policy.common.logging.eelf.MessageCodes;
-import org.onap.policy.common.logging.eelf.PolicyLogger;
-
-/**
- * SystemOutLogger implements all the methods of interface Logger by calling System.out.println
- */
-@Getter
-public class SystemOutLogger implements Logger, Serializable {
-
- private static final long serialVersionUID = 4956408061058933929L;
- private String className = "";
- private boolean debugEnabled = true;
- private boolean infoEnabled = true;
- private boolean warnEnabled = true;
- private boolean errorEnabled = true;
- private boolean auditEnabled = true;
- private boolean metricsEnabled = true;
- private String transId = UUID.randomUUID().toString();
-
- /**
- * Constructor.
- *
- * @param clazz the class
- */
- public SystemOutLogger(Class> clazz) {
- displayMessage("create instance of SystemOutLogger");
- if (clazz != null) {
- className = clazz.getName();
- }
- initLevel();
- }
-
- /**
- * Constructor.
- *
- * @param className the class name
- */
- public SystemOutLogger(String className) {
- displayMessage("create instance of SystemOutLogger");
- if (className != null) {
- this.className = className;
- }
- initLevel();
- }
-
- /**
- * Sets logging levels.
- */
- private void initLevel() {
-
- if (PolicyLogger.getDebugLevel() == Level.DEBUG) {
- debugEnabled = true;
- infoEnabled = true;
- warnEnabled = true;
- } else {
- debugEnabled = false;
- }
-
- if (PolicyLogger.getDebugLevel() == Level.INFO) {
- infoEnabled = true;
- warnEnabled = true;
- debugEnabled = false;
- }
-
- if (PolicyLogger.getDebugLevel() == Level.OFF) {
- infoEnabled = false;
- warnEnabled = false;
- debugEnabled = false;
- }
-
- if (PolicyLogger.getErrorLevel() == Level.OFF) {
- errorEnabled = false;
- }
-
- if (PolicyLogger.getAuditLevel() == Level.OFF) {
- auditEnabled = false;
- }
-
- if (PolicyLogger.getMetricsLevel() == Level.OFF) {
- metricsEnabled = false;
- }
- }
-
- /**
- * Sets transaction Id.
- */
- @Override
- public void setTransId(String transId) {
-
- displayMessage(transId);
- this.transId = transId;
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- */
- @Override
- public void debug(Object message) {
-
- displayMessage(transId + "|" + className + " : " + message);
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- * @param throwable the throwable
- */
- @Override
- public void debug(Object message, Throwable throwable) {
- displayMessage(transId + "|" + className + " : " + message + ":" + throwable);
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- * @param arguments variable number of arguments
- */
- @Override
- public void debug(String message, Object...arguments) {
- if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- displayMessage(transId + "|" + className + " : " + message + ":" + arguments[0]);
- } else {
- displayMessage(OnapLoggingUtils.formatMessage(message, arguments));
- }
- }
-
- /**
- * Records an error message.
- *
- * @param message the message
- */
- @Override
- public void error(Object message) {
-
- displayMessage(transId + "|" + className + " : " + message);
- }
-
- /**
- * Records an error message.
- *
- * @param message the message
- * @param throwable the throwable
- */
- @Override
- public void error(Object message, Throwable throwable) {
- displayMessage(transId + "|" + className + " : " + message + ":" + throwable);
- }
-
- /**
- * Records an error message.
- *
- * @param msg the message code
- * @param throwable the throwable
- * @param arguments the messages
- */
- @Override
- public void error(MessageCodes msg, Throwable throwable, String... arguments) {
- displayMessage(className + " : " + "MessageCodes :" + msg + Arrays.asList(arguments));
- }
-
- /**
- * Records an error message.
- *
- * @param msg the message code
- * @param arguments the messages
- */
- @Override
- public void error(MessageCodes msg, String... arguments) {
- displayMessage(transId + "|" + className + " : " + "MessageCode:" + msg + Arrays.asList(arguments));
- }
-
- /**
- * Records a error message.
- *
- * @param message the message
- * @param arguments variable number of arguments
- */
- @Override
- public void error(String message, Object...arguments) {
- if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- displayMessage(transId + "|" + className + " : " + message + ":" + arguments[0]);
- } else {
- displayMessage(OnapLoggingUtils.formatMessage(message, arguments));
- }
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- */
- @Override
- public void info(Object message) {
- displayMessage(transId + "|" + className + " : " + message);
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- * @param throwable the throwable
- */
- @Override
- public void info(Object message, Throwable throwable) {
- displayMessage(transId + "|" + className + " : " + message + ":" + throwable);
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- * @param arguments variable number of arguments
- */
- @Override
- public void info(String message, Object...arguments) {
- if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- displayMessage(transId + "|" + className + " : " + message + ":" + arguments[0]);
- } else {
- displayMessage(OnapLoggingUtils.formatMessage(message, arguments));
- }
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- */
- @Override
- public void warn(Object message) {
- displayMessage(transId + "|" + className + " : " + message);
- }
-
- /**
- * Records a message.
- *
- * @param msg the message code
- * @param arguments the messages
- */
- @Override
- public void warn(MessageCodes msg, String... arguments) {
-
- displayMessage(transId + "|" + className + " : " + "MessageCodes:" + msg + Arrays.asList(arguments));
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- * @param throwable the throwable
- */
- @Override
- public void warn(Object message, Throwable throwable) {
- displayMessage(transId + "|" + className + " : " + message + ":" + throwable);
- }
-
- /**
- * Records a message.
- *
- * @param msg the message code
- * @param throwable the throwable
- * @param arguments the messages
- */
- @Override
- public void warn(MessageCodes msg, Throwable throwable, String... arguments) {
-
- displayMessage(transId + "|" + className + " : " + "MessageCodes:" + msg + Arrays.asList(arguments));
-
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- * @param arguments variable number of arguments
- */
- @Override
- public void warn(String message, Object...arguments) {
- if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- displayMessage(transId + "|" + className + " : " + message + ":" + arguments[0]);
- } else {
- displayMessage(OnapLoggingUtils.formatMessage(message, arguments));
- }
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- */
- @Override
- public void trace(Object message) {
- displayMessage(transId + "|" + className + " : " + message);
- }
-
- /**
- * Records a message.
- *
- * @param message the message
- * @param throwable the throwable
- */
- @Override
- public void trace(Object message, Throwable throwable) {
- displayMessage(transId + "|" + className + " : " + message + ":" + throwable);
- }
-
- /**
- * Records an audit message.
- *
- * @param message the message
- */
- @Override
- public void audit(Object message) {
-
- displayMessage(transId + "|" + className + " : " + message);
- }
-
- /**
- * Records an audit message.
- *
- * @param message the message
- * @param throwable the throwable
- */
- @Override
- public void audit(Object message, Throwable throwable) {
- displayMessage(transId + "|" + className + " : " + message + ":" + throwable);
- }
-
- /**
- * Records an audit message.
- *
- * @param message the message
- */
- @Override
- public void audit(String message, Object... arguments) {
- if (arguments.length == 1) {
- displayMessage(transId + "|" + className + " : " + message + ":" + arguments[0]);
- } else {
- displayMessage(OnapLoggingUtils.formatMessage(message, arguments));
- }
- }
-
- /**
- * Records an audit message.
- *
- * @param eventId the event ID
- */
- @Override
- public void recordAuditEventStart(String eventId) {
-
- displayMessage(transId + "|" + className + " : " + eventId);
-
- }
-
- /**
- * Records an audit message.
- *
- * @param eventId the event ID
- */
- @Override
- public void recordAuditEventStart(UUID eventId) {
-
- displayMessage(eventId);
- }
-
- /**
- * Records an audit message.
- *
- * @param eventId the event ID
- * @param rule the rule
- * @param policyVersion the policy version
- */
- @Override
- public void recordAuditEventEnd(String eventId, String rule, String policyVersion) {
-
- displayMessage(className + " : " + eventId + ":" + rule + ":" + policyVersion);
- }
-
- /**
- * Records an audit message.
- *
- * @param eventId the event ID
- * @param rule the rule
- * @param policyVersion the policy version
- */
- @Override
- public void recordAuditEventEnd(UUID eventId, String rule, String policyVersion) {
-
- displayMessage(className + " : " + eventId + ":" + rule + ":" + policyVersion);
- }
-
- /**
- * Records an audit message.
- *
- * @param eventId the event ID
- * @param rule the rule
- */
- @Override
- public void recordAuditEventEnd(String eventId, String rule) {
-
- displayMessage(className + " : " + eventId + ":" + rule);
- }
-
- /**
- * Records an audit message.
- *
- * @param eventId the event ID
- * @param rule the rule
- */
- @Override
- public void recordAuditEventEnd(UUID eventId, String rule) {
-
- displayMessage(className + " : " + eventId + ":" + rule);
- }
-
- /**
- * Records a metrics message.
- *
- * @param eventId the event ID
- * @param message the message
- */
- @Override
- public void recordMetricEvent(String eventId, String message) {
-
- displayMessage(className + " : " + "eventId:" + eventId + "message:" + message);
-
- }
-
- /**
- * Records a metrics message.
- *
- * @param eventId the event ID
- * @param message the message
- */
- @Override
- public void recordMetricEvent(UUID eventId, String message) {
-
- displayMessage(className + " : " + eventId + ":" + message);
- }
-
- /**
- * Records a metrics message.
- *
- * @param message the message
- */
- @Override
- public void metrics(Object message) {
-
- displayMessage(className + " : " + message);
- }
-
- /**
- * Records a metrics message.
- *
- * @param message the message
- * @param arguments the arguments
- */
- @Override
- public void metrics(String message, Object... arguments) {
- if (arguments.length == 1) {
- displayMessage(className + " : " + message + " : " + arguments[0]);
- } else {
- displayMessage(OnapLoggingUtils.formatMessage(message, arguments));
- }
- }
-
- /**
- * Returns transaction Id.
- *
- * @param transId the transaction ID
- */
- @Override
- public String postMdcInfoForEvent(String transId) {
-
- String transactionId = transId;
- if (transactionId == null || transactionId.isEmpty()) {
- transactionId = UUID.randomUUID().toString();
- }
-
- return transactionId;
- }
-
- /**
- * Records transaction Id.
- *
- * @param message the message
- */
- @Override
- public void postMdcInfoForEvent(Object message) {
- displayMessage(message);
- }
-
-
- /**
- * Returns true for trace enabled, or false for not.
- *
- * @return boolean
- */
- @Override
- public boolean isTraceEnabled() {
- // default
- return false;
- }
-
- /**
- * Records transaction Id.
- *
- * @param transId the transaction ID
- */
- @Override
- public void postMdcInfoForTriggeredRule(String transId) {
-
- displayMessage(transId);
- }
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/LoggingContext.java b/common-logging/src/main/java/org/onap/policy/common/logging/nsa/LoggingContext.java
deleted file mode 100644
index a8dde087..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/LoggingContext.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.nsa;
-
-/**
- * An interface for providing data into the underlying logging context. Systems should use this
- * interface rather than log system specific MDC solutions in order to reduce dependencies.
- *
- *
A LoggingContext is specific to the calling thread.
- *
- */
-public interface LoggingContext {
- /**
- * Put a key/value pair into the logging context, replacing an entry with the same key.
- *
- * @param key the key
- * @param value the value
- */
- void put(String key, String value);
-
- /**
- * Put a key/value pair into the logging context, replacing an entry with the same key.
- *
- * @param key the key
- * @param value the value
- */
- void put(String key, long value);
-
- /**
- * Get a string value, returning the default value if the value is missing.
- *
- * @param key the key
- * @param defaultValue the default value
- * @return a string value
- */
- String get(String key, String defaultValue);
-
- /**
- * Get a long value, returning the default value if the value is missing or not a long.
- *
- * @param key the key
- * @param defaultValue the default value
- * @return a long value
- */
- long get(String key, long defaultValue);
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/LoggingContextFactory.java b/common-logging/src/main/java/org/onap/policy/common/logging/nsa/LoggingContextFactory.java
deleted file mode 100644
index eb2b318e..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/LoggingContextFactory.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2019, 2021 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.nsa;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.onap.policy.common.logging.nsa.impl.SharedContext;
-import org.onap.policy.common.logging.nsa.impl.Slf4jLoggingContext;
-
-/**
- * A factory for setting up a LoggingContext.
- *
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public class LoggingContextFactory {
- public static class Builder {
-
- private LoggingContext baseContext = null;
- private boolean forShared = false;
-
- public Builder withBaseContext(LoggingContext lc) {
- baseContext = lc;
- return this;
- }
-
- public Builder forSharing() {
- forShared = true;
- return this;
- }
-
- public LoggingContext build() {
- return forShared ? new SharedContext(baseContext) : new Slf4jLoggingContext(baseContext);
- }
- }
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/SharedLoggingContext.java b/common-logging/src/main/java/org/onap/policy/common/logging/nsa/SharedLoggingContext.java
deleted file mode 100644
index 1d844fa0..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/SharedLoggingContext.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.nsa;
-
-/**
- * A logging context must be thread-specific. Contexts that implement SharedLoggingContext are
- * expected to be shared across threads, and they have to be able to populate another logging
- * context with their data.
- *
- */
-public interface SharedLoggingContext extends LoggingContext {
- /**
- * Copy this context's data to the given context. This must work across threads so that a base
- * context can be shared in another thread.
- *
- * @param lc the shared logging context
- */
- void transferTo(SharedLoggingContext lc);
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/SharedContext.java b/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/SharedContext.java
deleted file mode 100644
index 13b38fc0..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/SharedContext.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2018, 2020 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.nsa.impl;
-
-import java.util.HashMap;
-import java.util.Map.Entry;
-import org.onap.policy.common.logging.nsa.LoggingContext;
-import org.onap.policy.common.logging.nsa.SharedLoggingContext;
-
-/**
- * A shared logging context for SLF4J.
- *
- */
-public class SharedContext extends Slf4jLoggingContext implements SharedLoggingContext {
- private final HashMap contextMap;
-
- public SharedContext(LoggingContext base) {
- super(base);
- contextMap = new HashMap<>();
- }
-
- @Override
- public void put(String key, String value) {
- super.put(key, value);
- contextMap.put(key, value);
- }
-
- @Override
- public void transferTo(SharedLoggingContext lc) {
- for (Entry e : contextMap.entrySet()) {
- lc.put(e.getKey(), e.getValue());
- }
- }
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/Slf4jLoggingContext.java b/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/Slf4jLoggingContext.java
deleted file mode 100644
index 33e9f637..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/Slf4jLoggingContext.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.nsa.impl;
-
-import org.onap.policy.common.logging.nsa.LoggingContext;
-import org.slf4j.MDC;
-
-/**
- * A logging context for SLF4J.
- *
- */
-public class Slf4jLoggingContext implements LoggingContext {
- public Slf4jLoggingContext(LoggingContext base) {
- // Default constructor
- }
-
- @Override
- public void put(String key, String value) {
- MDC.put(key, value);
- }
-
- @Override
- public void put(String key, long value) {
- put(key, Long.toString(value));
- }
-
- @Override
- public String get(String key, String defaultValue) {
- String result = MDC.get(key);
- if (result == null) {
- result = defaultValue;
- }
- return result;
- }
-
- @Override
- public long get(String key, long defaultValue) {
- final String str = get(key, Long.toString(defaultValue));
- try {
- return Long.parseLong(str);
- } catch (NumberFormatException x) {
- return defaultValue;
- }
- }
-}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/package-info.java b/common-logging/src/main/java/org/onap/policy/common/logging/nsa/package-info.java
deleted file mode 100644
index 76554c49..00000000
--- a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/package-info.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2017 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-/**
- * This package provides a logging context infrastructure and a corresponding implementation based
- * on the SLF4J/Log4j "MDC" (Mapped Diagnostic Context) feature.
- *
- */
-
-package org.onap.policy.common.logging.nsa;
-
diff --git a/common-logging/src/main/resources/org/onap/policy/common/logging/eelf/Resources.properties b/common-logging/src/main/resources/org/onap/policy/common/logging/eelf/Resources.properties
deleted file mode 100644
index 0f9d0f8c..00000000
--- a/common-logging/src/main/resources/org/onap/policy/common/logging/eelf/Resources.properties
+++ /dev/null
@@ -1,229 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# ONAP-Logging
-# ================================================================================
-# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
-# Modifications Copyright (C) 2024 Nordix Foundation.
-# ================================================================================
-# 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END=========================================================
-###
-
-#Resource key=Error Code|Message text|Resolution text |Description text
-#######
-# {APP}-{4-digit}{classification}
-
-#Newlines can be utilized to add some clarity ensuring continuing line
-#has atleast one leading space
-#ResourceKey=\
-# ERR0000E\
-# Sample error msg txt\
-# Sample resolution msg\
-# Sample description txt
-#
-######
-#Error code classification category
-#100-199 Permission/Security Related
-#200-299 Availability/Timeout Related
-#300-399 Data Access/Integrity Related
-#400-499 Schema Interface type/validation Related
-#500-599 Business/Flow Processing Related
-#900-999 Unknown errors
-#
-#{classification} description
-# I = Information
-# W = Warning
-# E = Error
-# F = Fatal
-
-########################################################################
-
-GENERAL_INFO=\
- POLICY-500I|\
- INFO: {0}|\
- No resolution needed|\
- General flow processing info
-GENERAL_WARNING=\
- POLICY-501W|\
- WARNING: {0}|\
- Please check other logs for more information|\
- General warning
-UPDATE_ERROR=\
- POLICY-502E|\
- ERROR: Could not update {0}|\
- Please check other logs for more information|\
- Exception caught during server management
-
-EXCEPTION_ERROR=\
- POLICY-503E|\
- ERROR: Error Message: {0}|\
- Please check other logs for more information|\
- Exception caught during server management
-
-MISS_PROPERTY_ERROR=\
- POLICY-504E|\
- ERROR: {0} property not set in {1}.properties|\
- Please check other logs for more information|\
- Exception caught during server management
-
-BAD_TYPE_WARNING=\
- POLICY-505W|\
- WARNING: Bad types for Double Metric: {0} path: {1}|\
- Please check other logs for more information|\
- General warning
-
-MISS_PROPERTY_INFO=\
- POLICY-506I|\
- INFO: report: {0} not set|\
- No resolution needed|\
- General flow processing info
-
-RULE_AUDIT_EXEC_INFO=\
- POLICY-507I|\
- Service Name: {0}:Executing rule: {1}|\
- No resolution needed|\
- Executing method
-
-RULE_AUDIT_BEGIN_INFO=\
- POLICY-508I|\
- Service Name: {0}:Entering rule: {1}|\
- No resolution needed|\
- Entering method
-
-RULE_AUDIT_END_INFO=\
- POLICY-509I|\
- Service Name: {0}:Exiting rule: {1}|\
- No resolution needed|\
- Exiting method
-
-RULE_METRICS_INFO=\
- POLICY-510I|\
- Service Name: {0}:Executing method: {1}|\
- No resolution needed|\
- Generate information for Metric events
-
-
-
-RULE_AUDIT_START_END_INFO=\
- POLICY-514I|\
- Service Name: \
- {0}:Executing rule:{1}:Starting Time:{2}:Ending Time:{3}:Executing Time:{4}:Policy version:{5}|\
- No resolution needed|\
- Executing method
-
-GENERAL_ERROR=\
- POLICY-515E|\
- ERROR: {0}|\
- Please check other logs for more information|\
- error caught during server management
-
-ERROR_SYSTEM_ERROR=\
- POLICY-516E|\
- ERROR: {0}|\
- Please check other logs for more information|\
- error caught during server management
-
-ERROR_DATA_ISSUE=\
- POLICY-517E|\
- ERROR: {0}|\
- Please check other logs for more information|\
- error caught during server management
-
-ERROR_PERMISSIONS=\
- POLICY-100E|\
- ERROR: {0}|\
- Please check other logs for more information|\
- error caught during server management
-
-ERROR_PROCESS_FLOW=\
- POLICY-518E|\
- ERROR: {0}|\
- Please check other logs for more information|\
- error caught during server management
-
-ERROR_SCHEMA_INVALID=\
- POLICY-400E|\
- ERROR: {0}|\
- Please check other logs for more information|\
- error caught during server management
-
-ERROR_UNKNOWN=\
- POLICY-519E|\
- ERROR: {0}|\
- Please check other logs for more information|\
- error caught during server management
-
-ERROR_AUDIT=\
- POLICY-520E|\
- ERROR: {0}|\
- Please check other logs for more information|\
- error caught during audit process
-
-########################################################################
-########################################################################
-########################################################################
-#---------------- The message codes below should not be used anymore since 1607 release -----------------------------
-
-MESSAGE_SAMPLE_NOARGS=\
- APP1234I|\
- App1 message text sample1|\
- App1 resolution text sample1|\
- App1 description text sample1
-
-MESSAGE_SAMPLE_ONEARGUMENT=\
- APP3456I|\
- App1 msg smpl w arg: {0}|\
- App1 resolution text sample2|\
- App1 description text sample2
-
-AUDIT_MESSAGE_ONEARGUMENT=\
- AUD0000I|\
- Audit msg: {0}|\
- Audit resolution text sample2|\
- Audit description text sample2
-
-ERROR_MESSAGE_ONEARGUMENT=\
- ERR0000E|\
- Error msg: {0}|\
- Error resolution text sample2|\
- Error description text sample2
-
-METRICS_MESSAGE_ONEARGUMENT=\
- MET0000I|\
- Metrics msg: {0}|\
- Metrics resolution text sample2|\
- Metrics description text sample2
-
-DUBUG_MESSAGE_ONEARGUMENT=\
- DEB0000I|\
- Debug msg: {0}|\
- Debug resolution text sample2|\
- Debug description text sample2
-MESSAGE_SAMPLE_TWOARGUMENTS=\
- APP4567I|\
- App1 message text sample with argument {0} and {1}|\
- App1 resolution text sample3|\
- App1 description text sample3
-
-MESSAGE_SAMPLE_EXCEPTION=\
- APP6789E|\
- App1 message text sample4|\
- App1 resolution text sample4|\
- App1 description text sample4
-
-MESSAGE_SAMPLE_EXCEPTION_ONEARGUMENT=\
- APP6790E|\
- This is the text exception in method {0}|\
- App1 resolution text sample5|\
- App1 description text sample5
-
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/DroolsPdpMdcInfoTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/eelf/DroolsPdpMdcInfoTest.java
deleted file mode 100644
index ba72f36b..00000000
--- a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/DroolsPdpMdcInfoTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine - Common Modules
- * ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.eelf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import com.att.eelf.configuration.Configuration;
-import org.junit.jupiter.api.Test;
-
-class DroolsPdpMdcInfoTest {
-
- /**
- * Test method for {@link org.onap.policy.common.logging.eelf.DroolsPdpMdcInfo#getMdcInfo()}.
- */
- @Test
- void testGetMdcInfo() {
- DroolsPdpMdcInfo di = new DroolsPdpMdcInfo();
-
- assertNotNull(di.getMdcInfo());
- assertEquals("Policy.droolsPdp", di.getMdcInfo().get(Configuration.MDC_SERVICE_NAME));
- }
-
-}
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/ErrorCodeMapTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/eelf/ErrorCodeMapTest.java
deleted file mode 100644
index 764b41b2..00000000
--- a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/ErrorCodeMapTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 AT&T.
- * Modifications Copyright (C) 2024 Nordix Foundation
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.eelf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import org.junit.jupiter.api.Test;
-import org.onap.policy.common.logging.eelf.ErrorCodeMap.ErrorCodeInfo;
-
-class ErrorCodeMapTest {
-
- @Test
- void testGetErrorCodeInfo() {
- assertNotNull(ErrorCodeMap.getErrorCodeInfo(MessageCodes.EXCEPTION_ERROR));
- assertNotNull(ErrorCodeMap.getErrorCodeInfo(MessageCodes.GENERAL_ERROR));
- assertNotNull(ErrorCodeMap.getErrorCodeInfo(MessageCodes.MISS_PROPERTY_ERROR));
- assertNotNull(ErrorCodeMap.getErrorCodeInfo(MessageCodes.UPDATE_ERROR));
- assertNotNull(ErrorCodeMap.getErrorCodeInfo(MessageCodes.ERROR_SYSTEM_ERROR));
- assertNotNull(ErrorCodeMap.getErrorCodeInfo(MessageCodes.ERROR_DATA_ISSUE));
- assertNotNull(ErrorCodeMap.getErrorCodeInfo(MessageCodes.ERROR_PERMISSIONS));
- assertNotNull(ErrorCodeMap.getErrorCodeInfo(MessageCodes.ERROR_DATA_ISSUE));
- assertNotNull(ErrorCodeMap.getErrorCodeInfo(MessageCodes.ERROR_PROCESS_FLOW));
- assertNotNull(ErrorCodeMap.getErrorCodeInfo(MessageCodes.ERROR_SCHEMA_INVALID));
- assertNotNull(ErrorCodeMap.getErrorCodeInfo(MessageCodes.ERROR_UNKNOWN));
- assertNotNull(ErrorCodeMap.getErrorCodeInfo(MessageCodes.ERROR_AUDIT));
- }
-
- @Test
- void testErrorCodeInfoGetErrorCode() {
- ErrorCodeInfo errorCodeInfo = ErrorCodeMap.getErrorCodeInfo(MessageCodes.EXCEPTION_ERROR);
- assertEquals("500", errorCodeInfo.getErrorCode());
- }
-
- @Test
- void testErrorCodeInfoGetErrorDesc() {
- ErrorCodeInfo errorCodeInfo = ErrorCodeMap.getErrorCodeInfo(MessageCodes.EXCEPTION_ERROR);
- assertEquals("This is an exception error message during the process. Please check the error message for detail "
- + "information", errorCodeInfo.getErrorDesc());
- }
-
-}
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventDataTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventDataTest.java
deleted file mode 100644
index 6e518c22..00000000
--- a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventDataTest.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine - Common Modules
- * ================================================================================
- * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.eelf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-import java.time.Instant;
-import org.junit.jupiter.api.Test;
-
-class EventDataTest {
- private static final Instant istart = Instant.ofEpochMilli(100000L);
- private static final Instant iend = Instant.ofEpochMilli(200000L);
-
- /**
- * Test method for {@link EventData#EventData()}.
- */
- @Test
- void testEventData() {
- EventData eventData = new EventData();
-
- assertNull(eventData.getEndTime());
- assertNull(eventData.getRequestId());
- assertNull(eventData.getStartTime());
- }
-
- /**
- * Test method for {@link EventData#EventData(String, Instant, Instant)}.
- */
- @Test
- void testEventDataStringInstantInstant() {
- EventData eventData = new EventData("myreq", istart, iend);
-
- assertEquals("myreq", eventData.getRequestId());
- assertEquals(istart, eventData.getStartTime());
- assertEquals(iend, eventData.getEndTime());
- }
-
- /**
- * Test method for {@link EventData#getRequestId()} and {@link EventData#setRequestId(String)}.
- */
- @Test
- void testGetSetRequestId() {
- EventData eventData = new EventData();
- assertNull(eventData.getRequestId());
-
- eventData.setRequestId("abc");
- assertEquals("abc", eventData.getRequestId());
-
- eventData.setRequestId("def");
- assertEquals("def", eventData.getRequestId());
- }
-
- /**
- * Test method for {@link EventData#getStartTime()} and {@link EventData#setStartTime(Instant)}.
- */
- @Test
- void testGetSetStartTime() {
- EventData eventData = new EventData();
- assertNull(eventData.getStartTime());
-
- eventData.setStartTime(istart);
- assertEquals(istart, eventData.getStartTime());
-
- eventData.setStartTime(iend);
- assertEquals(iend, eventData.getStartTime());
-
- // setting end-time should not effect start-time
- eventData.setEndTime(istart);
- assertEquals(iend, eventData.getStartTime());
- }
-
- /**
- * Test method for {@link EventData#getEndTime()} and {@link EventData#setEndTime(Instant)}.
- */
- @Test
- void testGetSetEndTime() {
- EventData eventData = new EventData();
- assertNull(eventData.getEndTime());
-
- eventData.setEndTime(iend);
- assertEquals(iend, eventData.getEndTime());
-
- eventData.setEndTime(istart);
- assertEquals(istart, eventData.getEndTime());
-
- // setting start-time should not effect end-time
- eventData.setStartTime(iend);
- assertEquals(istart, eventData.getEndTime());
- }
-
- /**
- * Test method for {@link EventData#toString()}.
- */
- @Test
- void testToString() {
- EventData eventData = new EventData("myreq", istart, iend);
- assertEquals("myreq Starting Time : 1970-01-01T00:01:40Z Ending Time : 1970-01-01T00:03:20Z",
- eventData.toString());
- }
-
- /**
- * Test method for {@link EventData#hashCode()}.
- */
- @Test
- void testHashCode() {
- int hc1 = new EventData("abc", istart, iend).hashCode();
-
- assertNotEquals(hc1, new EventData("abd", istart, iend).hashCode());
- assertEquals(hc1, new EventData("abc", iend, istart).hashCode());
- }
-
- /**
- * Test method for {@link EventData#equals(Object)}.
- */
- @Test
- void testEqualsObject() {
- final EventData d1 = new EventData("abc", istart, iend);
- final EventData d2 = new EventData("abd", istart, iend);
- final EventData d3 = new EventData("abc", iend, istart);
-
- // same object
- assertEquals(d1, d1);
-
- // compare with null
- assertNotEquals(null, d1);
-
- // compare with request id
- // note: ignoring sonar because we want to test d1.equals(), not "abc".equals()
- assertEquals(d1, "abc"); // NOSONAR
- assertNotEquals("abd", d1);
-
- // compare with int - different class type
- assertNotEquals(10, d1);
-
- // "this" has null request id
- assertNotEquals(new EventData(), d1);
-
- // both null
- assertEquals(new EventData(), new EventData());
-
- // this request id is not null, other is null
- assertNotEquals(d1, new EventData());
-
- // neither null, same
- assertEquals(d1, d3);
-
- // neither null, diff
- assertNotEquals(d1, d2);
- }
-
-}
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandlerTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandlerTest.java
deleted file mode 100644
index 92d24009..00000000
--- a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandlerTest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine - Common Modules
- * ================================================================================
- * Copyright (C) 2018, 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.eelf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import java.time.Instant;
-import java.util.concurrent.ConcurrentMap;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-class EventTrackInfoHandlerTest {
-
- private static final Instant inow = Instant.now();
- private static final Instant iexpired = Instant.ofEpochMilli(10000L);
-
- private static final EventData data1 = new EventData("abc", inow, inow);
- private static final EventData data2 = new EventData("def", inow, inow);
-
- private static EventTrackInfo tracker;
- private static ConcurrentMap info;
-
- private EventTrackInfoHandler hdlr;
-
- @BeforeAll
- public static void setUpBeforeClass() {
- tracker = PolicyLogger.getEventTracker();
- info = tracker.getEventInfo();
- }
-
- /**
- * Perform set up for test cases.
- */
- @BeforeEach
- void setUp() {
- info.clear();
-
- hdlr = new EventTrackInfoHandler();
- }
-
- @Test
- void testNoEvents() {
- hdlr.run();
- assertEquals(0, info.size());
- }
-
- @Test
- void testNothingExpired() {
- tracker.storeEventData(data1);
- tracker.storeEventData(data2);
-
- hdlr.run();
- assertEquals(2, info.size());
- }
-
- @Test
- void testSomeExpired() {
- // not expired
- tracker.storeEventData(data1);
- tracker.storeEventData(data2);
-
- // start time is expired
- tracker.storeEventData(new EventData("expiredA", iexpired, inow));
- tracker.storeEventData(new EventData("expiredB", iexpired, inow));
-
- // end time is expired, but that has no impact - these should be retained
- EventData oka = new EventData("okA", inow, iexpired);
- EventData okb = new EventData("okB", inow, iexpired);
-
- tracker.storeEventData(oka);
- tracker.storeEventData(okb);
-
- hdlr.run();
- assertEquals(4, info.size());
-
- assertEquals(data1, info.get("abc"));
- assertEquals(data2, info.get("def"));
- assertEquals(oka, info.get("okA"));
- assertEquals(okb, info.get("okB"));
- }
-
- @Test
- void testMultipleRuns() {
-
- hdlr.run();
- assertEquals(0, info.size());
-
- // not expired
- tracker.storeEventData(data1);
- tracker.storeEventData(data2);
-
- hdlr.run();
- assertEquals(2, info.size());
-
- // start time is expired
- tracker.storeEventData(new EventData("expiredA", iexpired, inow));
- tracker.storeEventData(new EventData("expiredB", iexpired, inow));
-
- // end time is expired, but that has no impact - these should be retained
- tracker.storeEventData(new EventData("okA", inow, iexpired));
- tracker.storeEventData(new EventData("okB", inow, iexpired));
-
- hdlr.run();
- assertEquals(4, info.size());
-
- hdlr.run();
- assertEquals(4, info.size());
- }
-
-}
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventTrackInfoTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventTrackInfoTest.java
deleted file mode 100644
index 49a3463f..00000000
--- a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/EventTrackInfoTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine - Common Modules
- * ================================================================================
- * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.eelf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertSame;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.time.Instant;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-class EventTrackInfoTest {
-
- private static final Instant istart = Instant.ofEpochMilli(100000L);
- private static final Instant iend = Instant.ofEpochMilli(200000L);
-
- private static final EventData data1 = new EventData("abc", istart, iend);
- private static final EventData data2 = new EventData("def", iend, istart);
-
- private EventTrackInfo info;
-
- @BeforeEach
- void setUp() {
- info = new EventTrackInfo();
-
- }
-
- /**
- * Test method for {@link EventTrackInfo#EventTrackInfo()}.
- */
- @Test
- void testEventTrackInfo() {
- assertNotNull(info.getEventInfo());
- }
-
- /**
- * Test method for {@link EventTrackInfo#getEventDataByRequestId(String)}.
- */
- @Test
- void testGetEventDataByRequestId() {
- info.storeEventData(data1);
- info.storeEventData(data2);
-
- assertSame(data1, info.getEventDataByRequestId("abc"));
- assertSame(data2, info.getEventDataByRequestId("def"));
- assertNull(info.getEventDataByRequestId("hello"));
- }
-
- /**
- * Test method for {@link EventTrackInfo#storeEventData(EventData)}.
- */
- @Test
- void testStoreEventData() {
- // should ignore null
- info.storeEventData(null);
- assertTrue(info.getEventInfo().isEmpty());
-
- // should ignore if request id is null or empty
- info.storeEventData(new EventData());
- info.storeEventData(new EventData("", istart, iend));
- assertTrue(info.getEventInfo().isEmpty());
-
- info.storeEventData(data1);
- info.storeEventData(data2);
- assertEquals(2, info.getEventInfo().size());
-
- // look-up by request id
- assertSame(data1, info.getEventDataByRequestId("abc"));
- assertSame(data2, info.getEventDataByRequestId("def"));
-
- // doesn't replace existing value
- info.storeEventData(new EventData("abc", iend, istart));
- assertEquals(2, info.getEventInfo().size());
- assertSame(data1, info.getEventDataByRequestId("abc"));
- assertSame(data2, info.getEventDataByRequestId("def"));
- }
-
- /**
- * Test method for {@link EventTrackInfo#remove(String)}.
- */
- @Test
- void testRemove() {
- info.storeEventData(data1);
- info.storeEventData(data2);
-
- info.remove("abc");
-
- // ensure only that item was removed
- assertEquals(1, info.getEventInfo().size());
-
- // look-up by request id
- assertNull(info.getEventDataByRequestId("abc"));
- assertSame(data2, info.getEventDataByRequestId("def"));
- }
-
- /**
- * Test method for {@link EventTrackInfo#getEventInfo()}.
- */
- @Test
- void testGetEventInfo() {
- info.storeEventData(data1);
- info.storeEventData(data2);
-
- assertEquals(2, info.getEventInfo().size());
- assertSame(data1, info.getEventInfo().get("abc"));
- assertSame(data2, info.getEventInfo().get("def"));
- }
-
-}
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/PolicyLoggerTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/eelf/PolicyLoggerTest.java
deleted file mode 100644
index d7239f4e..00000000
--- a/common-logging/src/test/java/org/onap/policy/common/logging/eelf/PolicyLoggerTest.java
+++ /dev/null
@@ -1,718 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-
-package org.onap.policy.common.logging.eelf;
-
-import static com.att.eelf.configuration.Configuration.MDC_ALERT_SEVERITY;
-import static com.att.eelf.configuration.Configuration.MDC_INSTANCE_UUID;
-import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID;
-import static com.att.eelf.configuration.Configuration.MDC_REMOTE_HOST;
-import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN;
-import static com.att.eelf.configuration.Configuration.MDC_SERVER_IP_ADDRESS;
-import static com.att.eelf.configuration.Configuration.MDC_SERVICE_INSTANCE_ID;
-import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME;
-import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.Mockito.never;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.PARTNER_NAME;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.RESPONSE_CODE;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.RESPONSE_DESCRIPTION;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.SERVER_NAME;
-import static org.onap.policy.common.logging.eelf.OnapConfigProperties.STATUS_CODE;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFLogger.Level;
-import java.time.Instant;
-import java.util.Properties;
-import java.util.UUID;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-import org.slf4j.MDC;
-import org.springframework.test.util.ReflectionTestUtils;
-
-class PolicyLoggerTest {
-
- /**
- * Perform set up for test cases.
- */
- @BeforeEach
- void setUp() {
- Properties properties = new Properties();
- properties.setProperty("policy.component", "XACML");
- PolicyLogger.init(properties);
- }
-
- @Test
- void testSetAndGetDebugLevelLevel() {
- PolicyLogger.setDebugLevel(Level.INFO);
- assertEquals(Level.INFO, PolicyLogger.getDebugLevel());
- PolicyLogger.setDebugLevel(Level.DEBUG);
- assertEquals(Level.DEBUG, PolicyLogger.getDebugLevel());
- }
-
- @Test
- void testSetAndGetAuditLevelLevel() {
- PolicyLogger.setAuditLevel(Level.INFO);
- assertEquals(Level.INFO, PolicyLogger.getAuditLevel());
- PolicyLogger.setAuditLevel(Level.DEBUG);
- assertEquals(Level.DEBUG, PolicyLogger.getAuditLevel());
- }
-
- @Test
- void testSetAndGetMetricsLevelLevel() {
- PolicyLogger.setMetricsLevel(Level.INFO);
- assertEquals(Level.INFO, PolicyLogger.getMetricsLevel());
- PolicyLogger.setMetricsLevel(Level.DEBUG);
- assertEquals(Level.DEBUG, PolicyLogger.getMetricsLevel());
- }
-
- @Test
- void testSetAndGetErrorLevelLevel() {
- PolicyLogger.setErrorLevel(Level.INFO);
- assertEquals(Level.INFO, PolicyLogger.getErrorLevel());
- PolicyLogger.setErrorLevel(Level.DEBUG);
- assertEquals(Level.DEBUG, PolicyLogger.getErrorLevel());
- }
-
- @Test
- void testSetAndGetClassname() {
- assertEquals("ClassName", PolicyLogger.getClassname());
- PolicyLogger.setClassname("PolicyLoggerTest");
- assertEquals("PolicyLoggerTest", PolicyLogger.getClassname());
- }
-
- @Test
- void testPostMdcInfoForEventString() {
- PolicyLogger.postMdcInfoForEvent("transactionId");
-
- assertEquals("", MDC.get(MDC_REMOTE_HOST));
- assertEquals("transactionId", MDC.get(MDC_KEY_REQUEST_ID));
- assertEquals("Policy.xacmlPdp", MDC.get(MDC_SERVICE_NAME));
- assertEquals("Policy.xacmlPdp.event", MDC.get(MDC_SERVICE_INSTANCE_ID));
- assertEquals("", MDC.get(MDC_INSTANCE_UUID));
- assertEquals("", MDC.get(MDC_ALERT_SEVERITY));
- assertEquals("N/A", MDC.get(PARTNER_NAME));
- assertEquals("COMPLETE", MDC.get(STATUS_CODE));
- assertEquals("N/A", MDC.get(RESPONSE_CODE));
- assertEquals("N/A", MDC.get(RESPONSE_DESCRIPTION));
- }
-
- @Test
- void testPostMdcInfoForEventStringDrools() {
- Properties properties = new Properties();
- properties.setProperty("policy.component", "DROOLS");
- PolicyLogger.init(properties);
-
- PolicyLogger.postMdcInfoForEvent("transactionId");
-
- assertEquals("transactionId", MDC.get(MDC_KEY_REQUEST_ID));
- assertEquals("Policy.droolsPdp", MDC.get(MDC_SERVICE_NAME));
- assertEquals("Policy.droolsPdp.event", MDC.get(MDC_SERVICE_INSTANCE_ID));
- }
-
- @Test
- void testSetAndGetTransId() {
- PolicyLogger.setTransId("123456");
- assertEquals("123456", PolicyLogger.getTransId());
- }
-
- @Test
- void testPostMdcInfoForEventObject() {
- PolicyLogger.postMdcInfoForEvent(1);
-
- assertEquals("", MDC.get(MDC_REMOTE_HOST));
- assertEquals("1", MDC.get(MDC_KEY_REQUEST_ID));
- assertEquals("Policy.xacmlPdp", MDC.get(MDC_SERVICE_NAME));
- assertEquals("Policy.xacmlPdp.event", MDC.get(MDC_SERVICE_INSTANCE_ID));
- assertEquals("", MDC.get(MDC_INSTANCE_UUID));
- assertEquals("", MDC.get(MDC_ALERT_SEVERITY));
- assertEquals("N/A", MDC.get(PARTNER_NAME));
- assertEquals("COMPLETE", MDC.get(STATUS_CODE));
- assertEquals("N/A", MDC.get(RESPONSE_CODE));
- assertEquals("N/A", MDC.get(RESPONSE_DESCRIPTION));
- }
-
- @Test
- void testPostMdcInfoForTriggeredRule() {
- PolicyLogger.postMdcInfoForTriggeredRule("transactionId");
-
- assertEquals("", MDC.get(MDC_REMOTE_HOST));
- assertEquals("transactionId", MDC.get(MDC_KEY_REQUEST_ID));
- assertEquals("Policy.droolsPdp", MDC.get(MDC_SERVICE_NAME));
- assertEquals("", MDC.get(MDC_SERVICE_INSTANCE_ID));
- assertNotNull(MDC.get(MDC_SERVER_FQDN));
- assertNotNull(MDC.get(MDC_SERVER_IP_ADDRESS));
- assertEquals("", MDC.get(MDC_INSTANCE_UUID));
- assertEquals("", MDC.get(MDC_ALERT_SEVERITY));
- assertEquals("COMPLETE", MDC.get(STATUS_CODE));
- }
-
- @Test
- void testPostMdcUuidForTriggeredRule() {
- PolicyLogger.postMdcUuidForTriggeredRule(1);
-
- assertEquals("", MDC.get(MDC_REMOTE_HOST));
- assertEquals("1", MDC.get(MDC_KEY_REQUEST_ID));
- assertEquals("Policy.droolsPdp", MDC.get(MDC_SERVICE_NAME));
- assertEquals("", MDC.get(MDC_SERVICE_INSTANCE_ID));
- assertNotNull(MDC.get(MDC_SERVER_FQDN));
- assertNotNull(MDC.get(MDC_SERVER_IP_ADDRESS));
- assertEquals("", MDC.get(MDC_INSTANCE_UUID));
- assertEquals("", MDC.get(MDC_ALERT_SEVERITY));
- assertEquals("COMPLETE", MDC.get(STATUS_CODE));
- }
-
- @Test
- void testInfoMessageCodesStringStringArray() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.info(MessageCodes.ERROR_DATA_ISSUE, "str1", "str2");
- Mockito.verify(mockLogger).info(MessageCodes.ERROR_DATA_ISSUE, "str2");
- }
-
- @Test
- void testInfoStringString() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.info("str1", "str2");
- Mockito.verify(mockLogger, never()).info(Mockito.anyString(), Mockito.anyString());
- Mockito.when(mockLogger.isInfoEnabled()).thenReturn(true);
- PolicyLogger.info("str1", "str2");
- Mockito.verify(mockLogger).info(MessageCodes.GENERAL_INFO, "str2");
- }
-
- @Test
- void testInfoObject() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.info("str1");
- Mockito.verify(mockLogger).info(MessageCodes.GENERAL_INFO, "str1");
- }
-
- @Test
- void testInfoMessageCodesThrowableStringArray() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.info(MessageCodes.ERROR_DATA_ISSUE, new NullPointerException(), "str1", "str2");
- Mockito.verify(mockLogger).info((MessageCodes) Mockito.any(),
- Mockito.startsWith("str1:str2:java.lang.NullPointerException"));
- }
-
- @Test
- void testInfoMessageCodesStringThrowableStringArray() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.info(MessageCodes.ERROR_DATA_ISSUE, "PolicyLoggerTest", new NullPointerException(), "str1",
- "str2");
- Mockito.verify(mockLogger).info((MessageCodes) Mockito.any(),
- Mockito.startsWith("str1:str2:java.lang.NullPointerException"));
- }
-
- @Test
- void testWarnMessageCodesStringStringArray() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.warn(MessageCodes.ERROR_DATA_ISSUE, "str1");
- Mockito.verify(mockLogger).warn(MessageCodes.ERROR_DATA_ISSUE);
- }
-
- @Test
- void testWarnStringString() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.warn("str1", "str2");
- Mockito.verify(mockLogger, never()).info(Mockito.anyString(), Mockito.anyString());
- Mockito.when(mockLogger.isWarnEnabled()).thenReturn(true);
- PolicyLogger.warn("str1", "str2");
- Mockito.verify(mockLogger).warn(MessageCodes.GENERAL_INFO, "str2");
- }
-
- @Test
- void testWarnObject() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.warn(1);
- Mockito.verify(mockLogger).warn(MessageCodes.GENERAL_WARNING, "1");
- }
-
- @Test
- void testWarnMessageCodesThrowableStringArray() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.warn(MessageCodes.ERROR_DATA_ISSUE, new NullPointerException(), "str1", "str2");
- Mockito.verify(mockLogger).warn((MessageCodes) Mockito.any(),
- Mockito.startsWith("str1:str2:java.lang.NullPointerException"));
- }
-
- @Test
- void testWarnMessageCodesStringThrowableStringArray() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.warn(MessageCodes.ERROR_DATA_ISSUE, "PolicyLoggerTest", new NullPointerException(), "str1",
- "str2");
- Mockito.verify(mockLogger).warn((MessageCodes) Mockito.any(),
- Mockito.startsWith("str1:str2:java.lang.NullPointerException"));
- }
-
- @Test
- void testWarnString() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.warn("str1");
- Mockito.verify(mockLogger).warn(MessageCodes.GENERAL_WARNING, "str1");
- }
-
- @Test
- void testErrorStringString() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "errorLogger", mockLogger);
- PolicyLogger.error("str1", "str2");
- Mockito.verify(mockLogger, never()).info(Mockito.anyString(), Mockito.anyString());
- Mockito.when(mockLogger.isErrorEnabled()).thenReturn(true);
- PolicyLogger.error("str1", "str2");
- Mockito.verify(mockLogger).error(MessageCodes.GENERAL_ERROR, "str2");
- assertEquals("500", MDC.get("ErrorCode"));
- assertEquals("This is a general error message during the process. Please check the error message for detail "
- + "information", MDC.get("ErrorDescription"));
- }
-
- @Test
- void testErrorString() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "errorLogger", mockLogger);
- PolicyLogger.error("str1");
- Mockito.verify(mockLogger).error(MessageCodes.GENERAL_ERROR, "str1");
- assertEquals("ERROR", MDC.get("ErrorCategory"));
- assertEquals("500", MDC.get("ErrorCode"));
- assertEquals("This is a general error message during the process. Please check the error message for detail "
- + "information", MDC.get("ErrorDescription"));
- }
-
- @Test
- void testErrorObject() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "errorLogger", mockLogger);
- PolicyLogger.error(1);
- Mockito.verify(mockLogger).error(MessageCodes.GENERAL_ERROR, "1");
- assertEquals("ERROR", MDC.get("ErrorCategory"));
- assertEquals("500", MDC.get("ErrorCode"));
- assertEquals("This is a general error message during the process. Please check the error message for detail "
- + "information", MDC.get("ErrorDescription"));
- }
-
- @Test
- void testErrorMessageCodesThrowableStringArray() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "errorLogger", mockLogger);
- PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, new NullPointerException(), "str1", "str2");
- Mockito.verify(mockLogger).error((MessageCodes) Mockito.any(),
- Mockito.startsWith("str1:str2:java.lang.NullPointerException"));
- }
-
- @Test
- void testErrorMessageCodesStringThrowableStringArray() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "errorLogger", mockLogger);
- PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "PolicyLoggerTest", new NullPointerException(), "str1",
- "str2");
- Mockito.verify(mockLogger).error((MessageCodes) Mockito.any(),
- Mockito.startsWith("str1:str2:java.lang.NullPointerException"));
- }
-
- @Test
- void testErrorMessageCodesStringArray() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "errorLogger", mockLogger);
- PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "str1", "str2");
- Mockito.verify(mockLogger).error(MessageCodes.ERROR_DATA_ISSUE, "str1", "str2");
- }
-
- @Test
- void testDebugMessageCodesStringArray() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.debug(MessageCodes.ERROR_DATA_ISSUE, "str1", "str2");
- Mockito.verify(mockLogger).debug(MessageCodes.ERROR_DATA_ISSUE, "str1", "str2");
- }
-
- @Test
- void testDebugStringString() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.debug("str1", "str2");
- Mockito.verify(mockLogger, never()).info(Mockito.anyString(), Mockito.anyString());
- Mockito.when(mockLogger.isDebugEnabled()).thenReturn(true);
- PolicyLogger.debug("str1", "str2");
- Mockito.verify(mockLogger).debug(MessageCodes.GENERAL_INFO, "str2");
- }
-
- @Test
- void testDebugString() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.debug("str1");
- Mockito.verify(mockLogger).debug("str1");
- }
-
- @Test
- void testDebugObject() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.debug(1);
- Mockito.verify(mockLogger).debug("{}", 1);
- }
-
- @Test
- void testAuditStringObject() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "auditLogger", mockLogger);
- PolicyLogger.audit("PolicyLoggerTest", 1);
- Mockito.verify(mockLogger, never()).info(Mockito.anyString(), Mockito.anyString());
- Mockito.when(mockLogger.isInfoEnabled()).thenReturn(true);
- PolicyLogger.audit("PolicyLoggerTest", 1);
- assertEquals("PolicyLoggerTest", MDC.get("ClassName"));
- assertEquals("COMPLETE", MDC.get("StatusCode"));
- Mockito.verify(mockLogger).info("{}", "1");
- }
-
- @Test
- void testAuditObject() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "auditLogger", mockLogger);
- PolicyLogger.audit(1);
- assertEquals("", MDC.get("ClassName"));
- assertEquals("COMPLETE", MDC.get("StatusCode"));
- Mockito.verify(mockLogger).info("{}", 1);
- }
-
- @Test
- void testDebugMessageCodesThrowableStringArray() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.debug(MessageCodes.ERROR_DATA_ISSUE, new NullPointerException(), "str1", "str2");
- Mockito.verify(mockLogger).debug((MessageCodes) Mockito.any(),
- Mockito.startsWith("str1:str2:java.lang.NullPointerException"));
- }
-
- @Test
- void testDebugMessageCodesStringThrowableStringArray() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.debug(MessageCodes.ERROR_DATA_ISSUE, "PolicyLoggerTest", new NullPointerException(), "str1",
- "str2");
- Mockito.verify(mockLogger).debug((MessageCodes) Mockito.any(),
- Mockito.startsWith("str1:str2:java.lang.NullPointerException"));
- }
-
- @Test
- void testIsDebugEnabled() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- Mockito.when(mockLogger.isDebugEnabled()).thenReturn(false).thenReturn(true);
- assertFalse(PolicyLogger.isDebugEnabled());
- assertTrue(PolicyLogger.isDebugEnabled());
- }
-
- @Test
- void testIsErrorEnabled() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "errorLogger", mockLogger);
- Mockito.when(mockLogger.isErrorEnabled()).thenReturn(false).thenReturn(true);
- assertFalse(PolicyLogger.isErrorEnabled());
- assertTrue(PolicyLogger.isErrorEnabled());
- }
-
- @Test
- void testIsWarnEnabled() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- Mockito.when(mockLogger.isWarnEnabled()).thenReturn(false).thenReturn(true);
- assertFalse(PolicyLogger.isWarnEnabled());
- assertTrue(PolicyLogger.isWarnEnabled());
- }
-
- @Test
- void testIsInfoEnabled1() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- Mockito.when(mockLogger.isInfoEnabled()).thenReturn(false).thenReturn(true);
- assertFalse(PolicyLogger.isInfoEnabled1());
- assertTrue(PolicyLogger.isInfoEnabled1());
- }
-
- @Test
- void testIsAuditEnabled() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- Mockito.when(mockLogger.isInfoEnabled()).thenReturn(false).thenReturn(true);
- assertFalse(PolicyLogger.isAuditEnabled());
- assertTrue(PolicyLogger.isAuditEnabled());
- }
-
- @Test
- void testIsInfoEnabled() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- Mockito.when(mockLogger.isInfoEnabled()).thenReturn(false).thenReturn(true);
- assertFalse(PolicyLogger.isInfoEnabled());
- assertTrue(PolicyLogger.isInfoEnabled());
- }
-
- @Test
- void testTraceStringString() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.trace("str1", "str2");
- Mockito.verify(mockLogger).trace(MessageCodes.GENERAL_INFO, "str2");
- }
-
- @Test
- void testTraceObject() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- PolicyLogger.trace(1);
- Mockito.verify(mockLogger).trace("{}", 1);
- }
-
- @Test
- void testRecordAuditEventStartAndEnd() {
- PolicyLogger.recordAuditEventStart("eventId");
- assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get("eventId"));
-
- PolicyLogger.recordAuditEventEnd("eventId", "rule");
- assertNull(PolicyLogger.getEventTracker().getEventInfo().get("eventId"));
- }
-
- @Test
- void testRecordAuditEventStartAndEndUuid() {
- UUID uuid = UUID.randomUUID();
- PolicyLogger.recordAuditEventStart(uuid);;
- assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get(uuid.toString()));
-
- PolicyLogger.recordAuditEventEnd(uuid, "rule");
- assertNull(PolicyLogger.getEventTracker().getEventInfo().get(uuid.toString()));
- }
-
-
- @Test
- void testRecordAuditEventEndStringStringString() {
- PolicyLogger.recordAuditEventStart("eventId");
- assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get("eventId"));
-
- PolicyLogger.recordAuditEventEnd("eventId", "rule", "policyVersion");
- assertNull(PolicyLogger.getEventTracker().getEventInfo().get("eventId"));
- }
-
- @Test
- void testRecordAuditEventEndUuidStringString() {
- UUID uuid = UUID.randomUUID();
- PolicyLogger.recordAuditEventStart(uuid);;
- assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get(uuid.toString()));
-
- PolicyLogger.recordAuditEventEnd(uuid, "rule", "policyVersion");
- assertNull(PolicyLogger.getEventTracker().getEventInfo().get(uuid.toString()));
- }
-
-
- @Test
- void testCreatAuditEventTrackingRecordStringStringString() {
- PolicyLogger.recordAuditEventStart("eventId");
- assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get("eventId"));
-
- PolicyLogger.creatAuditEventTrackingRecord("eventId", "rule", "policyVersion");
- assertNull(PolicyLogger.getEventTracker().getEventInfo().get("eventId"));
- }
-
- @Test
- void testCreatAuditEventTrackingRecordUuidString() {
- UUID uuid = UUID.randomUUID();
- PolicyLogger.recordAuditEventStart(uuid);;
- assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get(uuid.toString()));
-
- PolicyLogger.creatAuditEventTrackingRecord(uuid, "rule");
- assertNull(PolicyLogger.getEventTracker().getEventInfo().get(uuid.toString()));
- }
-
- @Test
- void testRecordAuditEventStartToEnd() {
- PolicyLogger.recordAuditEventStartToEnd("eventId", "rule", Instant.now(), Instant.now(), "policyVersion");
- assertEquals("eventId", MDC.get(MDC_KEY_REQUEST_ID));
- }
-
- @Test
- void testRecordMetricEventStringString() {
- PolicyLogger.recordMetricEvent("eventId", "str1");
- assertEquals("eventId", MDC.get(MDC_KEY_REQUEST_ID));
- }
-
- @Test
- void testRecordMetricEventStringStringString() {
- PolicyLogger.recordMetricEvent("eventId", "PolicyLoggerTest", "str1");
- assertEquals("eventId", MDC.get(MDC_KEY_REQUEST_ID));
- }
-
- @Test
- void testRecordMetricEventUuidString() {
- UUID uuid = UUID.randomUUID();
- PolicyLogger.recordMetricEvent(uuid, "str1");
- assertEquals(uuid.toString(), MDC.get(MDC_KEY_REQUEST_ID));
- }
-
- @Test
- void testRecordMetricEventString() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "metricsLogger", mockLogger);
- PolicyLogger.recordMetricEvent("eventId");
- Mockito.verify(mockLogger).info(Mockito.eq(MessageCodes.RULE_METRICS_INFO), Mockito.anyString(),
- Mockito.eq("eventId"));
- }
-
- @Test
- void testMetricsString() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "metricsLogger", mockLogger);
- PolicyLogger.metrics("str1");
- Mockito.verify(mockLogger).info(Mockito.eq(MessageCodes.RULE_METRICS_INFO), Mockito.anyString(),
- Mockito.eq("str1"));
- }
-
- @Test
- void testMetricsStringObject() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "metricsLogger", mockLogger);
- PolicyLogger.metrics("PolicyLoggerTest", 1);
- Mockito.verify(mockLogger, never()).info(Mockito.anyString(), Mockito.anyString());
- Mockito.when(mockLogger.isInfoEnabled()).thenReturn(true);
- PolicyLogger.metrics("PolicyLoggerTest", 1);
- Mockito.verify(mockLogger).info(Mockito.eq(MessageCodes.RULE_METRICS_INFO), Mockito.anyString(),
- Mockito.eq("1"));
- }
-
- @Test
- void testMetricsObject() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "metricsLogger", mockLogger);
- PolicyLogger.metrics(1);
- Mockito.verify(mockLogger).info(Mockito.eq(MessageCodes.RULE_METRICS_INFO), Mockito.anyString(),
- Mockito.eq("1"));
- }
-
- @Test
- void testMetricsPrintln() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "metricsLogger", mockLogger);
- PolicyLogger.metricsPrintln("str1");
- Mockito.verify(mockLogger).info("str1");
- }
-
- @Test
- void testInitNullProperties() {
- assertThatCode(() -> PolicyLogger.init(null)).doesNotThrowAnyException();
- }
-
- @Test
- void testInit() {
- Properties properties = new Properties();
- properties.setProperty("override.logback.level.setup", "true");
- properties.setProperty("metricsLogger.level", "OFF");
- properties.setProperty("error.level", "OFF");
- properties.setProperty("audit.level", "OFF");
- properties.setProperty("timer.delay.time", "0");
- properties.setProperty("check.interval", "0");
- properties.setProperty("event.expired.time", "0");
- properties.setProperty("concurrentHashMap.limit", "0");
- properties.setProperty("stop.check.point", "0");
- properties.setProperty("logger.property", "LOG4J");
-
- assertThatCode(() -> PolicyLogger.init(properties)).doesNotThrowAnyException();
- }
-
- @Test
- void testSetDebugLevelString() {
- PolicyLogger.setOverrideLogbackLevel(true);
- PolicyLogger.setDebugLevel("TRACE");
- assertEquals(Level.TRACE, PolicyLogger.getDebugLevel());
- }
-
- @Test
- void testSetErrorLevelStringOff() {
- PolicyLogger.setOverrideLogbackLevel(true);
- PolicyLogger.setErrorLevel("OFF");
- assertEquals(Level.OFF, PolicyLogger.getErrorLevel());
- }
-
- @Test
- void testSetErrorLevelStringOther() {
- PolicyLogger.setOverrideLogbackLevel(true);
- PolicyLogger.setErrorLevel("INFO");
- assertEquals(Level.ERROR, PolicyLogger.getErrorLevel());
- }
-
- @Test
- void testSetMetricsLevelStringOff() {
- PolicyLogger.setOverrideLogbackLevel(true);
- PolicyLogger.setMetricsLevel("OFF");
- assertEquals(Level.OFF, PolicyLogger.getMetricsLevel());
- }
-
- @Test
- void testSetMetricsLevelStringOther() {
- PolicyLogger.setOverrideLogbackLevel(true);
- PolicyLogger.setMetricsLevel("ERROR");
- assertEquals(Level.INFO, PolicyLogger.getMetricsLevel());
- }
-
- @Test
- void testSetAuditLevelStringOff() {
- PolicyLogger.setOverrideLogbackLevel(true);
- PolicyLogger.setAuditLevel("OFF");
- assertEquals(Level.OFF, PolicyLogger.getAuditLevel());
- }
-
- @Test
- void testSetAuditLevelStringOther() {
- PolicyLogger.setOverrideLogbackLevel(true);
- PolicyLogger.setAuditLevel("ERROR");
- assertEquals(Level.INFO, PolicyLogger.getAuditLevel());
- }
-
- @Test
- void testSetAndIsOverrideLogbackLevel() {
- PolicyLogger.setOverrideLogbackLevel(false);
- assertFalse(PolicyLogger.isOverrideLogbackLevel());
- PolicyLogger.setOverrideLogbackLevel(true);
- assertTrue(PolicyLogger.isOverrideLogbackLevel());
- }
-
- @Test
- void testSetServerInfo() {
- PolicyLogger.setServerInfo("serverHost", "serverPort");
- assertEquals("serverHost:serverPort", MDC.get(SERVER_NAME));
- }
-
-}
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/EelfLoggerTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/EelfLoggerTest.java
deleted file mode 100644
index 66b48e07..00000000
--- a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/EelfLoggerTest.java
+++ /dev/null
@@ -1,390 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.flexlogger;
-
-import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.Mockito.never;
-
-import com.att.eelf.configuration.EELFLogger;
-import java.util.UUID;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-import org.onap.policy.common.logging.eelf.MessageCodes;
-import org.onap.policy.common.logging.eelf.PolicyLogger;
-import org.slf4j.MDC;
-import org.springframework.test.util.ReflectionTestUtils;
-
-class EelfLoggerTest {
-
- EelfLogger eelfLogger = new EelfLogger("EelfLoggerTest", "transactionId");
-
- @Test
- void testEelfLoggerClassOfQ() {
- new EelfLogger(this.getClass());
- assertNotNull(PolicyLogger.getTransId());
- assertFalse(PolicyLogger.getTransId().isEmpty());
- }
-
- @Test
- void testEelfLoggerString() {
- new EelfLogger("EelfLoggerTest");
- assertNotNull(PolicyLogger.getTransId());
- assertFalse(PolicyLogger.getTransId().isEmpty());
- }
-
- @Test
- void testEelfLoggerClassOfQBoolean() {
- new EelfLogger(this.getClass(), true);
- assertNotNull(PolicyLogger.getTransId());
- assertFalse(PolicyLogger.getTransId().isEmpty());
- }
-
- @Test
- void testEelfLoggerStringBoolean() {
- new EelfLogger("EelfLoggerTest", true);
- assertNotNull(PolicyLogger.getTransId());
- assertFalse(PolicyLogger.getTransId().isEmpty());
- }
-
- @Test
- void testEelfLoggerClassOfQString() {
- new EelfLogger(this.getClass(), "transactionId");
- assertEquals("transactionId", PolicyLogger.getTransId());
- }
-
- @Test
- void testEelfLoggerStringString() {
- new EelfLogger("EelfLoggerTest", "transactionId");
- assertEquals("transactionId", PolicyLogger.getTransId());
- }
-
- @Test
- void testSetAndGetTransId() {
- assertEquals("transactionId", eelfLogger.getTransId());
- eelfLogger.setTransId("transactionId2");
- assertEquals("transactionId2", eelfLogger.getTransId());
- }
-
- @Test
- void testDebugObject() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- eelfLogger.debug("message");
- Mockito.verify(mockLogger, never()).info(Mockito.anyString(), Mockito.anyString());
- Mockito.when(mockLogger.isDebugEnabled()).thenReturn(true);
- eelfLogger.debug("message");
- Mockito.verify(mockLogger).debug(MessageCodes.GENERAL_INFO, "message");
- }
-
- @Test
- void testErrorObject() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "errorLogger", mockLogger);
- eelfLogger.error("message");
- Mockito.verify(mockLogger, never()).info(Mockito.anyString(), Mockito.anyString());
- Mockito.when(mockLogger.isErrorEnabled()).thenReturn(true);
- eelfLogger.error("message");
- Mockito.verify(mockLogger).error(MessageCodes.GENERAL_ERROR, "message");
- }
-
- @Test
- void testInfoObject() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- eelfLogger.info("message");
- Mockito.verify(mockLogger, never()).info(Mockito.anyString(), Mockito.anyString());
- Mockito.when(mockLogger.isInfoEnabled()).thenReturn(true);
- eelfLogger.info("message");
- Mockito.verify(mockLogger).info(MessageCodes.GENERAL_INFO, "message");
- }
-
- @Test
- void testWarnObject() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- eelfLogger.warn("message");
- Mockito.verify(mockLogger, never()).info(Mockito.anyString(), Mockito.anyString());
- Mockito.when(mockLogger.isWarnEnabled()).thenReturn(true);
- eelfLogger.warn("message");
- Mockito.verify(mockLogger).warn(MessageCodes.GENERAL_INFO, "message");
- }
-
- @Test
- void testTraceObject() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- eelfLogger.trace("message");
- Mockito.verify(mockLogger).trace(MessageCodes.GENERAL_INFO, "message");
- }
-
- @Test
- void testIsDebugEnabled() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- Mockito.when(mockLogger.isDebugEnabled()).thenReturn(false).thenReturn(true);
- assertFalse(eelfLogger.isDebugEnabled());
- assertTrue(eelfLogger.isDebugEnabled());
-
- }
-
- @Test
- void testIsInfoEnabled() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- Mockito.when(mockLogger.isInfoEnabled()).thenReturn(false).thenReturn(true);
- assertFalse(eelfLogger.isInfoEnabled());
- assertTrue(eelfLogger.isInfoEnabled());
- }
-
- @Test
- void testIsWarnEnabled() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- Mockito.when(mockLogger.isWarnEnabled()).thenReturn(false).thenReturn(true);
- assertFalse(eelfLogger.isWarnEnabled());
- assertTrue(eelfLogger.isWarnEnabled());
- }
-
- @Test
- void testIsErrorEnabled() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "errorLogger", mockLogger);
- Mockito.when(mockLogger.isErrorEnabled()).thenReturn(false).thenReturn(true);
- assertFalse(eelfLogger.isErrorEnabled());
- assertTrue(eelfLogger.isErrorEnabled());
- }
-
- @Test
- void testIsMetricsEnabled() {
- PolicyLogger.setOverrideLogbackLevel(true);
- PolicyLogger.setMetricsLevel("ERROR");
- assertTrue(eelfLogger.isMetricsEnabled());
- }
-
- @Test
- void testIsTraceEnabled() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- Mockito.when(mockLogger.isDebugEnabled()).thenReturn(false).thenReturn(true);
- assertFalse(eelfLogger.isTraceEnabled());
- assertTrue(eelfLogger.isTraceEnabled());
- }
-
- @Test
- void testAuditObject() {
- PolicyLogger.setOverrideLogbackLevel(true);
- PolicyLogger.setAuditLevel("ERROR");
- assertTrue(eelfLogger.isAuditEnabled());
- }
-
- @Test
- void testDebugObjectThrowable() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- eelfLogger.debug("message", new NullPointerException());
- Mockito.verify(mockLogger).debug((MessageCodes) Mockito.any(),
- Mockito.startsWith("message:java.lang.NullPointerException"));
- }
-
- @Test
- void testErrorObjectThrowable() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "errorLogger", mockLogger);
- eelfLogger.error("message", new NullPointerException());
- Mockito.verify(mockLogger).error((MessageCodes) Mockito.any(),
- Mockito.startsWith("message:java.lang.NullPointerException"));
- eelfLogger.error("message", new NullPointerException());
- }
-
- @Test
- void testInfoObjectThrowable() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- eelfLogger.info("message", new NullPointerException());
- Mockito.verify(mockLogger, never()).info(Mockito.anyString(), Mockito.anyString());
- Mockito.when(mockLogger.isInfoEnabled()).thenReturn(true);
- Mockito.verify(mockLogger).info((MessageCodes) Mockito.any(),
- Mockito.startsWith("message:java.lang.NullPointerException"));
- }
-
- @Test
- void testWarnObjectThrowable() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- eelfLogger.warn("message", new NullPointerException());
- Mockito.verify(mockLogger).warn((MessageCodes) Mockito.any(),
- Mockito.startsWith("message:java.lang.NullPointerException"));
- }
-
- @Test
- void testTraceObjectThrowable() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- eelfLogger.trace("message", new NullPointerException());
- Mockito.verify(mockLogger).trace("{}", "message");
- }
-
- @Test
- void testAuditObjectThrowable() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "auditLogger", mockLogger);
- eelfLogger.audit("message", new NullPointerException());
- Mockito.verify(mockLogger).info("{}", "message");
- }
-
- @Test
- void testRecordAuditEventStartString() {
- eelfLogger.recordAuditEventStart("eventId");
- assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get("eventId"));
- }
-
- @Test
- void testRecordAuditEventStartUuid() {
- UUID uuid = UUID.randomUUID();
- eelfLogger.recordAuditEventStart(uuid);
- assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get(uuid.toString()));
- }
-
- @Test
- void testRecordAuditEventEndStringStringString() {
- eelfLogger.recordAuditEventStart("eventId");
- assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get("eventId"));
-
- eelfLogger.recordAuditEventEnd("eventId", "rule", "policyVersion");
- assertNull(PolicyLogger.getEventTracker().getEventInfo().get("eventId"));
- }
-
- @Test
- void testRecordAuditEventEndUuidStringString() {
- UUID uuid = UUID.randomUUID();
- eelfLogger.recordAuditEventStart(uuid);;
- assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get(uuid.toString()));
-
- eelfLogger.recordAuditEventEnd(uuid, "rule", "policyVersion");
- assertNull(PolicyLogger.getEventTracker().getEventInfo().get(uuid.toString()));
- }
-
- @Test
- void testRecordAuditEventEndStringString() {
- eelfLogger.recordAuditEventStart("eventId");
- assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get("eventId"));
-
- eelfLogger.recordAuditEventEnd("eventId", "rule");
- assertNull(PolicyLogger.getEventTracker().getEventInfo().get("eventId"));
- }
-
- @Test
- void testRecordAuditEventEndUuidString() {
- UUID uuid = UUID.randomUUID();
- eelfLogger.recordAuditEventStart(uuid);;
- assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get(uuid.toString()));
-
- eelfLogger.recordAuditEventEnd(uuid, "rule");
- assertNull(PolicyLogger.getEventTracker().getEventInfo().get(uuid.toString()));
- }
-
- @Test
- void testRecordMetricEventStringString() {
- eelfLogger.recordMetricEvent("eventId", "str1");
- assertEquals("eventId", MDC.get(MDC_KEY_REQUEST_ID));
- }
-
- @Test
- void testRecordMetricEventUuidString() {
- UUID uuid = UUID.randomUUID();
- eelfLogger.recordMetricEvent(uuid, "str2");
- assertEquals(uuid.toString(), MDC.get(MDC_KEY_REQUEST_ID));
- }
-
- @Test
- void testMetrics() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "metricsLogger", mockLogger);
- eelfLogger.metrics(1);
- Mockito.verify(mockLogger, never()).info(Mockito.anyString(), Mockito.anyString());
- Mockito.when(mockLogger.isInfoEnabled()).thenReturn(true);
- eelfLogger.metrics(1);
- Mockito.verify(mockLogger).info(Mockito.eq(MessageCodes.RULE_METRICS_INFO), Mockito.anyString(),
- Mockito.eq("1"));
- }
-
- @Test
- void testErrorMessageCodesThrowableStringArray() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "errorLogger", mockLogger);
- eelfLogger.error(MessageCodes.GENERAL_ERROR, new NullPointerException(), "str1", "str2");
- Mockito.verify(mockLogger).error((MessageCodes) Mockito.any(),
- Mockito.startsWith("str1:str2:java.lang.NullPointerException"));
- }
-
- @Test
- void testErrorMessageCodesStringArray() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "errorLogger", mockLogger);
- eelfLogger.error(MessageCodes.GENERAL_ERROR, "str1", "str2");
- Mockito.verify(mockLogger).error(MessageCodes.GENERAL_ERROR, "str1", "str2");
-
- }
-
- @Test
- void testPostMdcInfoForEventString() {
- eelfLogger.postMdcInfoForEvent("transactionId");
- assertEquals("transactionId", MDC.get(MDC_KEY_REQUEST_ID));
- }
-
- @Test
- void testWarnMessageCodesStringArray() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- eelfLogger.warn(MessageCodes.GENERAL_ERROR, "str1", "str2");
- Mockito.verify(mockLogger).warn(MessageCodes.GENERAL_ERROR, "str1", "str2");
- }
-
- @Test
- void testWarnMessageCodesThrowableStringArray() {
- EELFLogger mockLogger = Mockito.mock(EELFLogger.class);
- ReflectionTestUtils.setField(PolicyLogger.class, "debugLogger", mockLogger);
- eelfLogger.warn(MessageCodes.GENERAL_ERROR, new NullPointerException(), "str1", "str2");
- Mockito.verify(mockLogger).warn((MessageCodes) Mockito.any(),
- Mockito.startsWith("str1:str2:java.lang.NullPointerException"));
-
- }
-
- @Test
- void testPostMdcInfoForTriggeredRule() {
- eelfLogger.postMdcInfoForTriggeredRule("transactionId");
- assertEquals("transactionId", MDC.get(MDC_KEY_REQUEST_ID));
- }
-
- @Test
- void testPostMDdcInfoForEventObject() {
- eelfLogger.postMdcInfoForEvent(1);
- assertEquals("1", MDC.get(MDC_KEY_REQUEST_ID));
- }
-
-}
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/FlexLoggerTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/FlexLoggerTest.java
deleted file mode 100644
index 3c78785b..00000000
--- a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/FlexLoggerTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.flexlogger;
-
-import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertSame;
-
-import java.util.HashSet;
-import java.util.Set;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.common.logging.flexlogger.FlexLogger.PropertiesCallBack;
-import org.springframework.test.util.ReflectionTestUtils;
-
-class FlexLoggerTest {
-
- @Test
- void testGetLoggerClassOfQEelf() {
- ReflectionTestUtils.setField(FlexLogger.class, "loggerType", LoggerType.EELF);
- Logger logger = FlexLogger.getLogger((Class>) null);
- assertSame(logger, FlexLogger.getLogger((Class>) null));
- assertNotEquals(logger, FlexLogger.getLogger(String.class));
- }
-
- @Test
- void testGetLoggerClassOfQSystemOut() {
- ReflectionTestUtils.setField(FlexLogger.class, "loggerType", LoggerType.SYSTEMOUT);
- Logger logger = FlexLogger.getLogger(this.getClass());
- assertSame(logger, FlexLogger.getLogger(this.getClass()));
- }
-
- @Test
- void testGetLoggerStringEelf() {
- ReflectionTestUtils.setField(FlexLogger.class, "loggerType", LoggerType.EELF);
- Logger logger = FlexLogger.getLogger();
- assertSame(logger, FlexLogger.getLogger());
- }
-
- @Test
- void testGetLoggerStringSystemOut() {
- ReflectionTestUtils.setField(FlexLogger.class, "loggerType", LoggerType.SYSTEMOUT);
- Logger logger = FlexLogger.getLogger();
- assertSame(logger, FlexLogger.getLogger());
- }
-
- @Test
- void testGetLoggerClassOfQBooleanEelf() {
- ReflectionTestUtils.setField(FlexLogger.class, "loggerType", LoggerType.EELF);
- Logger logger = FlexLogger.getLogger(this.getClass(), true);
- assertSame(logger, FlexLogger.getLogger(this.getClass(), true));
- }
-
- @Test
- void testGetLoggerClassOfQBooleanSystemOut() {
- ReflectionTestUtils.setField(FlexLogger.class, "loggerType", LoggerType.SYSTEMOUT);
- Logger logger = FlexLogger.getLogger(this.getClass(), true);
- assertSame(logger, FlexLogger.getLogger(this.getClass(), true));
- }
-
- @Test
- void testGetLoggerStringBooleanEelf() {
- ReflectionTestUtils.setField(FlexLogger.class, "loggerType", LoggerType.EELF);
- Logger logger = FlexLogger.getLogger(true);
- assertSame(logger, FlexLogger.getLogger(true));
- }
-
- @Test
- void testGetLoggerStringBooleanSystemOut() {
- ReflectionTestUtils.setField(FlexLogger.class, "loggerType", LoggerType.SYSTEMOUT);
- Logger logger = FlexLogger.getLogger(true);
- assertSame(logger, FlexLogger.getLogger(true));
- }
-
- @Test
- void testGetClassName() {
- assertNotEquals("FlexLogger", new FlexLogger().getClassName());
- }
-
- @Test
- void testPropertiesCallBack() {
- Set changedKeys = new HashSet<>();
- changedKeys.add("debugLogger.level");
- changedKeys.add("metricsLogger.level");
- changedKeys.add("error.level");
- changedKeys.add("audit.level");
- PropertiesCallBack propertiesCallBack = new PropertiesCallBack("name");
- assertThatCode(() -> propertiesCallBack
- .propertiesChanged(PropertyUtil.getProperties("config/policyLogger.properties"), changedKeys))
- .doesNotThrowAnyException();
- }
-
-}
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/PropertyUtilTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/PropertyUtilTest.java
deleted file mode 100644
index 75c512b2..00000000
--- a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/PropertyUtilTest.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2018-2020 Ericsson, AT&T. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.flexlogger;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyLong;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.mock;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.common.logging.flexlogger.PropertyUtil.Listener;
-import org.springframework.test.util.ReflectionTestUtils;
-
-class PropertyUtilTest {
-
- private static final String TIMER_FIELD = "timer";
- private static final File FILE = new File("target/test.properties");
- private static Timer saveTimer;
-
- private TimerTask task;
- private Timer timer;
- private TestListener testListener;
-
- @BeforeAll
- public static void setUpBeforeClass() {
- saveTimer = (Timer) ReflectionTestUtils.getField(PropertyUtil.LazyHolder.class, TIMER_FIELD);
-
- }
-
- @AfterAll
- public static void tearDownAfterClass() {
- ReflectionTestUtils.setField(PropertyUtil.LazyHolder.class, TIMER_FIELD, saveTimer);
-
- }
-
- /**
- * Perform test case set up.
- */
- @BeforeEach
- void setUp() throws IOException {
- task = null;
- timer = mock(Timer.class);
- ReflectionTestUtils.setField(PropertyUtil.LazyHolder.class, TIMER_FIELD, timer);
-
- doAnswer(args -> {
- task = args.getArgument(0, TimerTask.class);
- return null;
- }).when(timer).schedule(any(TimerTask.class), anyLong(), anyLong());
-
- testListener = new TestListener();
-
- FileOutputStream fileOutputStream = new FileOutputStream(FILE);
- Properties properties = new Properties();
- properties.put("testProperty", "testValue");
- properties.store(fileOutputStream, "");
- fileOutputStream.close();
- }
-
- @AfterEach
- void tearDown() throws IOException {
- PropertyUtil.stopListening(FILE, testListener);
- FILE.delete();
- }
-
- @Test
- void testTimer() {
- assertNotNull(saveTimer);
- }
-
- @Test
- void testGetProperties() throws IOException {
- FileOutputStream fileOutputStream = new FileOutputStream(FILE);
- Properties properties = new Properties();
- properties.put("testProperty", "testValue");
- properties.store(fileOutputStream, "");
- fileOutputStream.close();
-
- Properties readProperties = PropertyUtil.getProperties(FILE, testListener);
- assertEquals("testValue", readProperties.getProperty("testProperty"));
- }
-
- @Test
- void testPropertiesChanged() throws IOException, InterruptedException {
- PropertyUtil.getProperties(FILE, testListener);
-
- FileOutputStream fileOutputStream = new FileOutputStream(FILE);
- Properties newProperties = new Properties();
- newProperties.put("testProperty", "testValueNew");
- newProperties.store(fileOutputStream, "");
-
- // fire task and verify that it notifies the listener
- task.run();
- assertTrue(testListener.isPropertiesChangedInvoked());
-
- }
-
- @Test
- void testStopListening() throws IOException {
- FileOutputStream fileOutputStream = new FileOutputStream(FILE);
- Properties properties = new Properties();
- properties.put("testProperty", "testValue");
- properties.store(fileOutputStream, "");
-
- Properties readProperties = PropertyUtil.getProperties(FILE, testListener);
- assertEquals("testValue", readProperties.getProperty("testProperty"));
-
- PropertyUtil.stopListening(FILE, testListener);
-
- properties.put("testProperty", "testValueNew");
- properties.store(fileOutputStream, "");
- fileOutputStream.close();
- readProperties = PropertyUtil.getProperties(FILE, testListener);
- // If stopListening did not remove the listener, the properties file will not be re-read
- // until poll expires and
- // hence "testValue" will be returned here instead of "testNewValue"
- assertEquals("testValueNew", readProperties.getProperty("testProperty"));
- }
-
- /**
- * The {@link #propertiesChanged(Properties, Set)} method is invoked via a background
- * thread, thus we have to use a latch to wait for it to be invoked.
- */
- private class TestListener implements Listener {
-
- private CountDownLatch latch = new CountDownLatch(1);
-
- @Override
- public void propertiesChanged(Properties properties, Set changedKeys) {
- latch.countDown();
- }
-
- public boolean isPropertiesChangedInvoked() throws InterruptedException {
- return latch.await(5, TimeUnit.SECONDS);
- }
- }
-
-}
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/SystemOutLoggerTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/SystemOutLoggerTest.java
deleted file mode 100644
index 343eea9c..00000000
--- a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/SystemOutLoggerTest.java
+++ /dev/null
@@ -1,558 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-Logging
- * ================================================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.logging.flexlogger;
-
-import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import com.att.eelf.configuration.EELFLogger.Level;
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.util.UUID;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.common.logging.eelf.MessageCodes;
-import org.onap.policy.common.logging.eelf.PolicyLogger;
-
-class SystemOutLoggerTest {
-
- SystemOutLogger systemOutLogger = new SystemOutLogger("SystemOutLoggerTest");
-
- @Test
- void testSystemOutLoggerClassOfQ() {
- assertThatCode(() -> new SystemOutLogger(SystemOutLoggerTest.class)).doesNotThrowAnyException();
- }
-
- @Test
- void testSetAndGetTransId() {
- systemOutLogger.setTransId("transactionId");
- assertEquals("transactionId", systemOutLogger.getTransId());
- }
-
- @Test
- void testDebugObject() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- systemOutLogger.setTransId("transactionId");
- System.setOut(ps);
- systemOutLogger.debug("message");
- assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : message"));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testErrorObject() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- systemOutLogger.setTransId("transactionId");
- System.setOut(ps);
- systemOutLogger.error("message");
- assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : message"));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testInfoObject() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- systemOutLogger.setTransId("transactionId");
- System.setOut(ps);
- systemOutLogger.info("message");
- assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : message"));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testWarnObject() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- systemOutLogger.setTransId("transactionId");
- System.setOut(ps);
- systemOutLogger.warn("message");
- assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : message"));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testTraceObject() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- systemOutLogger.setTransId("transactionId");
- System.setOut(ps);
- systemOutLogger.trace("message");
- assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : message"));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testIsDebugEnabled() {
- PolicyLogger.setDebugLevel(Level.DEBUG);
- systemOutLogger = new SystemOutLogger("SystemOutLoggerTest");
- assertTrue(systemOutLogger.isDebugEnabled());
- PolicyLogger.setDebugLevel(Level.INFO);
- systemOutLogger = new SystemOutLogger("SystemOutLoggerTest");
- assertFalse(systemOutLogger.isDebugEnabled());
- }
-
- @Test
- void testIsWarnEnabled() {
- PolicyLogger.setDebugLevel(Level.WARN);
- systemOutLogger = new SystemOutLogger("SystemOutLoggerTest");
- assertTrue(systemOutLogger.isWarnEnabled());
- PolicyLogger.setDebugLevel(Level.OFF);
- systemOutLogger = new SystemOutLogger("SystemOutLoggerTest");
- assertFalse(systemOutLogger.isWarnEnabled());
- }
-
- @Test
- void testIsInfoEnabled() {
- PolicyLogger.setDebugLevel(Level.INFO);
- systemOutLogger = new SystemOutLogger("SystemOutLoggerTest");
- assertTrue(systemOutLogger.isInfoEnabled());
- PolicyLogger.setDebugLevel(Level.OFF);
- systemOutLogger = new SystemOutLogger("SystemOutLoggerTest");
- assertFalse(systemOutLogger.isInfoEnabled());
- }
-
- @Test
- void testIsErrorEnabled() {
- PolicyLogger.setErrorLevel(Level.ERROR);
- systemOutLogger = new SystemOutLogger("SystemOutLoggerTest");
- assertTrue(systemOutLogger.isErrorEnabled());
- PolicyLogger.setErrorLevel(Level.OFF);
- systemOutLogger = new SystemOutLogger("SystemOutLoggerTest");
- assertFalse(systemOutLogger.isErrorEnabled());
- }
-
- @Test
- void testIsAuditEnabled() {
- PolicyLogger.setAuditLevel(Level.INFO);
- systemOutLogger = new SystemOutLogger("SystemOutLoggerTest");
- assertTrue(systemOutLogger.isAuditEnabled());
- PolicyLogger.setAuditLevel(Level.OFF);
- systemOutLogger = new SystemOutLogger("SystemOutLoggerTest");
- assertFalse(systemOutLogger.isAuditEnabled());
- }
-
- @Test
- void testIsMetricsEnabled() {
- PolicyLogger.setMetricsLevel(Level.INFO);
- systemOutLogger = new SystemOutLogger("SystemOutLoggerTest");
- assertTrue(systemOutLogger.isMetricsEnabled());
- PolicyLogger.setMetricsLevel(Level.OFF);
- systemOutLogger = new SystemOutLogger("SystemOutLoggerTest");
- assertFalse(systemOutLogger.isMetricsEnabled());
- }
-
- @Test
- void testAuditObject() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- systemOutLogger.setTransId("transactionId");
- System.setOut(ps);
- systemOutLogger.audit("message");
- assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : message"));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testRecordAuditEventStartString() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- systemOutLogger.setTransId("transactionId");
- System.setOut(ps);
- systemOutLogger.recordAuditEventStart("eventId");
- assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : eventId"));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testRecordAuditEventStartUuid() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- UUID uuid = UUID.randomUUID();
- System.setOut(ps);
- systemOutLogger.recordAuditEventStart(uuid);
- assertTrue(baos.toString().contains(uuid.toString()));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testRecordAuditEventEndStringStringString() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- System.setOut(ps);
- systemOutLogger.recordAuditEventEnd("eventId", "rule", "policyVersion");
- assertTrue(baos.toString().contains("SystemOutLoggerTest : eventId:rule:policyVersion"));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testRecordAuditEventEndUuidStringString() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- UUID uuid = UUID.randomUUID();
- System.setOut(ps);
- systemOutLogger.recordAuditEventEnd(uuid, "rule", "policyVersion");
- assertTrue(baos.toString().contains("SystemOutLoggerTest : " + uuid + ":rule:policyVersion"));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testRecordAuditEventEndStringString() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- System.setOut(ps);
- systemOutLogger.recordAuditEventEnd("eventId", "rule");
- assertTrue(baos.toString().contains("SystemOutLoggerTest : eventId:rule"));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testRecordAuditEventEndUuidString() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- UUID uuid = UUID.randomUUID();
- System.setOut(ps);
- systemOutLogger.recordAuditEventEnd(uuid, "rule");
- assertTrue(baos.toString().contains("SystemOutLoggerTest : " + uuid + ":rule"));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testRecordMetricEventStringString() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- System.setOut(ps);
- systemOutLogger.recordMetricEvent("eventId", "rule");
- assertTrue(baos.toString().contains("SystemOutLoggerTest : eventId:eventIdmessage:rule"), baos.toString());
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testRecordMetricEventUuidString() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- UUID uuid = UUID.randomUUID();
- System.setOut(ps);
- systemOutLogger.recordMetricEvent(uuid, "str1");
- assertTrue(baos.toString().contains("SystemOutLoggerTest : " + uuid + ":str1"));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testMetrics() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- System.setOut(ps);
- systemOutLogger.metrics("message");
- assertTrue(baos.toString().contains("SystemOutLoggerTest : message"));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testErrorMessageCodesThrowableStringArray() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- System.setOut(ps);
- systemOutLogger.error(MessageCodes.ERROR_DATA_ISSUE, new NullPointerException(), "str1", "str2");
- assertTrue(baos.toString()
- .contains("SystemOutLoggerTest : MessageCodes :" + MessageCodes.ERROR_DATA_ISSUE + "[str1, str2]"));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testErrorMessageCodesStringArray() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- System.setOut(ps);
- systemOutLogger.setTransId("transactionId");
- systemOutLogger.error(MessageCodes.ERROR_DATA_ISSUE, "str1", "str2");
- assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : MessageCode:"
- + MessageCodes.ERROR_DATA_ISSUE + "[str1, str2]"));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testPostMdcInfoForEventString() {
- assertEquals("transactionId", systemOutLogger.postMdcInfoForEvent("transactionId"));
- }
-
- @Test
- void testWarnMessageCodesStringArray() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- System.setOut(ps);
- systemOutLogger.setTransId("transactionId");
- systemOutLogger.warn(MessageCodes.ERROR_DATA_ISSUE, "str1", "str2");
- assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : MessageCodes:"
- + MessageCodes.ERROR_DATA_ISSUE + "[str1, str2]"));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testWarnMessageCodesThrowableStringArray() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- System.setOut(ps);
- systemOutLogger.setTransId("transactionId");
- systemOutLogger.warn(MessageCodes.ERROR_DATA_ISSUE, new NullPointerException(), "str1", "str2");
- assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : MessageCodes:"
- + MessageCodes.ERROR_DATA_ISSUE + "[str1, str2]"));
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testDebugObjectThrowable() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- System.setOut(ps);
- systemOutLogger.setTransId("transactionId");
- systemOutLogger.debug("1", new NullPointerException());
- assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException"),
- baos.toString());
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testErrorObjectThrowable() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- System.setOut(ps);
- systemOutLogger.setTransId("transactionId");
- systemOutLogger.error("1", new NullPointerException());
- assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException"),
- baos.toString());
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testInfoObjectThrowable() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- System.setOut(ps);
- systemOutLogger.setTransId("transactionId");
- systemOutLogger.info("1", new NullPointerException());
- assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException"),
- baos.toString());
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testWarnObjectThrowable() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- System.setOut(ps);
- systemOutLogger.setTransId("transactionId");
- systemOutLogger.warn("1", new NullPointerException());
- assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException"),
- baos.toString());
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testTraceObjectThrowable() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- System.setOut(ps);
- systemOutLogger.setTransId("transactionId");
- systemOutLogger.trace(1, new NullPointerException());
- assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException"),
- baos.toString());
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testAuditObjectThrowable() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- System.setOut(ps);
- systemOutLogger.setTransId("transactionId");
- systemOutLogger.audit("1", new NullPointerException());
- assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException"),
- baos.toString());
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testIsTraceEnabled() {
- assertFalse(systemOutLogger.isTraceEnabled());
- }
-
- @Test
- void testPostMdcInfoForTriggeredRule() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- System.setOut(ps);
- systemOutLogger.postMdcInfoForTriggeredRule("transactionId");
- assertTrue(baos.toString().contains("transactionId"), baos.toString());
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
- @Test
- void testPostMdcInfoForEventObject() {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- PrintStream old = System.out;
- try {
- System.setOut(ps);
- systemOutLogger.postMdcInfoForEvent(1);
- assertTrue(baos.toString().contains("1"), baos.toString());
- } finally {
- System.out.flush();
- System.setOut(old);
- }
- }
-
-}
diff --git a/integrity-audit/config/policyLogger.properties b/integrity-audit/config/policyLogger.properties
deleted file mode 100644
index 1e7187f2..00000000
--- a/integrity-audit/config/policyLogger.properties
+++ /dev/null
@@ -1,44 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# Integrity Audit
-# ================================================================================
-# Copyright (C) 2017 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.
-# 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END=========================================================
-###
-
-################################### Set concurrentHashMap and timer info #######################
-#Timer initial delay and the delay between in milliseconds before task is to be execute.
-timer.delay.time=1000
-#Timer scheduleAtFixedRate period - time in milliseconds between successive task executions.
-check.interval= 30000
-#Longest time an event info can be stored in the concurrentHashMap for logging - in seconds.
-event.expired.time=86400
-#Size of the concurrentHashMap which stores the event starting time, etc - when its size reaches this limit, the Timer gets executed
-#to remove all expired records from this concurrentHashMap.
-concurrentHashMap.limit=5000
-#Size of the concurrentHashMap - when its size drops to this point, stop the Timer
-stop.check.point=2500
-################################### Set logging format #############################################
-# set EELF for EELF logging format, set LOG4J for using log4j, set SYSTEMOUT for using system.out.println
-logger.type=EELF
-#################################### Set level for EELF or SYSTEMOUT logging ##################################
-# Set level for debug file. Set DEBUG to enable .info, .warn and .debug; set INFO for enable .info and .warn; set OFF to disable all
-debugLogger.level=INFO
-# Set level for metrics file. Set OFF to disable; set ON to enable
-metricsLogger.level=ON
-# Set level for error file. Set OFF to disable; set ON to enable
-error.level=ON
-# Set level for audit file. Set OFF to disable; set ON to enable
-audit.level=ON
diff --git a/integrity-audit/policyLogger.properties b/integrity-audit/policyLogger.properties
deleted file mode 100644
index 1e7187f2..00000000
--- a/integrity-audit/policyLogger.properties
+++ /dev/null
@@ -1,44 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# Integrity Audit
-# ================================================================================
-# Copyright (C) 2017 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.
-# 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.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END=========================================================
-###
-
-################################### Set concurrentHashMap and timer info #######################
-#Timer initial delay and the delay between in milliseconds before task is to be execute.
-timer.delay.time=1000
-#Timer scheduleAtFixedRate period - time in milliseconds between successive task executions.
-check.interval= 30000
-#Longest time an event info can be stored in the concurrentHashMap for logging - in seconds.
-event.expired.time=86400
-#Size of the concurrentHashMap which stores the event starting time, etc - when its size reaches this limit, the Timer gets executed
-#to remove all expired records from this concurrentHashMap.
-concurrentHashMap.limit=5000
-#Size of the concurrentHashMap - when its size drops to this point, stop the Timer
-stop.check.point=2500
-################################### Set logging format #############################################
-# set EELF for EELF logging format, set LOG4J for using log4j, set SYSTEMOUT for using system.out.println
-logger.type=EELF
-#################################### Set level for EELF or SYSTEMOUT logging ##################################
-# Set level for debug file. Set DEBUG to enable .info, .warn and .debug; set INFO for enable .info and .warn; set OFF to disable all
-debugLogger.level=INFO
-# Set level for metrics file. Set OFF to disable; set ON to enable
-metricsLogger.level=ON
-# Set level for error file. Set OFF to disable; set ON to enable
-error.level=ON
-# Set level for audit file. Set OFF to disable; set ON to enable
-audit.level=ON
diff --git a/integrity-audit/pom.xml b/integrity-audit/pom.xml
deleted file mode 100644
index f2cd6f0e..00000000
--- a/integrity-audit/pom.xml
+++ /dev/null
@@ -1,95 +0,0 @@
-
-
-
-
- 4.0.0
-
- integrity-audit
-
- jar
-
-
- org.onap.policy.common
- common-modules
- 3.0.1-SNAPSHOT
-
-
- Integrity Audit
-
-
-
- org.onap.policy.common
- utils
- ${project.version}
-
-
- org.onap.policy.common
- utils-test
- ${project.version}
- test
-
-
- org.onap.policy.common
- ONAP-Logging
- ${project.version}
-
-
- org.projectlombok
- lombok
-
-
- org.hibernate.orm
- hibernate-core
- provided
-
-
- org.hibernate.validator
- hibernate-validator
- provided
-
-
- ch.qos.logback
- logback-core
- test
-
-
- org.slf4j
- slf4j-ext
- test
-
-
- org.assertj
- assertj-core
- test
-
-
- org.springframework
- spring-test
- test
-
-
- com.h2database
- h2
- test
-
-
-
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java
deleted file mode 100644
index 03fbdb57..00000000
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java
+++ /dev/null
@@ -1,771 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Integrity Audit
- * ================================================================================
- * Copyright (C) 2017-2021 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.ia;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Properties;
-import org.onap.policy.common.ia.jpa.IntegrityAuditEntity;
-import org.onap.policy.common.logging.eelf.MessageCodes;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
-
-/**
- * AuditThread is the main thread for the IntegrityAudit.
- *
- */
-public class AuditThread extends Thread {
-
- private static final Logger logger = FlexLogger.getLogger(AuditThread.class);
-
- /*
- * Number of milliseconds that must elapse for audit to be considered complete. It's public for
- * access by JUnit test logic.
- */
- public static final long AUDIT_COMPLETION_INTERVAL = 30000L;
-
- /**
- * Number of audit cycles before the completion flag is reset.
- */
- public static final int AUDIT_RESET_CYCLES = 2;
-
- /*
- * Unless audit has already been run on this entity, number of milliseconds to sleep between
- * audit thread iterations. If audit has already been run, we sleep integrityAuditPeriodMillis.
- * May be modified by JUnit tests.
- */
- private static final long AUDIT_THREAD_SLEEP_INTERVAL_MS = 5000L;
-
- /*
- * String constants.
- */
- private static final String AUDIT_THREAD_MESSAGE = "AuditThread.run: resourceName=";
- private static final String ENTITY_INDEX_MESSAGE = ", entityIndex=";
- private static final String LAST_UPDATED_MESSAGE = ", lastUpdated=";
- private static final String PERSISTENCE_MESSAGE = ", persistenceUnit=";
-
- /*
- * DB access class.
- */
- private DbDao dbDao;
-
- /*
- * E.g. pdp_xacml
- */
- private String nodeType;
-
- /*
- * Persistence unit for which this audit is being run.
- */
- private String persistenceUnit;
-
- /*
- * Name of this resource
- */
- private String resourceName;
-
- /*
- * E.g. DB_DRIVER, SITE_NAME, NODE_TYPE
- */
- private Properties properties;
-
- /*
- * See IntegrityAudit class for usage.
- */
- private int integrityAuditPeriodSeconds;
-
- /*
- * The containing IntegrityAudit instance
- */
- private IntegrityAudit integrityAudit;
-
- /*
- * Used to create a list that is sorted lexicographically by resourceName.
- */
- Comparator comparator = (r1, r2) -> r1.getResourceName().compareTo(r2.getResourceName());
-
- /**
- * AuditThread constructor.
- *
- * @param resourceName the resource name
- * @param persistenceUnit the persistence unit
- * @param properties the properties
- * @param integrityAuditPeriodSeconds the integrity audit period in seconds
- * @param integrityAudit the integrity audit
- * @throws IntegrityAuditException if an error occurs
- */
- public AuditThread(String resourceName, String persistenceUnit, Properties properties,
- int integrityAuditPeriodSeconds, IntegrityAudit integrityAudit) throws IntegrityAuditException {
-
- this.resourceName = resourceName;
- this.persistenceUnit = persistenceUnit;
- this.properties = properties;
- this.integrityAuditPeriodSeconds = integrityAuditPeriodSeconds;
- this.integrityAudit = integrityAudit;
-
- /*
- * The DbDao Constructor registers this node in the IntegrityAuditEntity table. Each
- * resource (node) inserts its own name, persistenceUnit, DB access properties and other
- * pertinent properties in the table. This allows the audit on each node to compare its own
- * version of the entities for the persistenceUnit in question with the versions from all
- * other nodes of similar type.
- */
- dbDao = new DbDao(this.resourceName, this.persistenceUnit, this.properties);
- this.nodeType = properties.getProperty(IntegrityAuditProperties.NODE_TYPE).toLowerCase();
-
- }
-
- @Override
- public void run() {
-
- logger.info("AuditThread.run: Entering");
-
- try {
- // for junit testing
- runStarted();
-
- /*
- * Triggers change in designation, unless no other viable candidate.
- */
- runUntilInterrupted();
-
- } catch (InterruptedException e) {
- handleAuditLoopException(e);
- Thread.currentThread().interrupt();
-
- } catch (Exception e) {
- handleAuditLoopException(e);
- }
-
- dbDao.destroy();
-
- logger.info("AuditThread.run: Exiting");
- }
-
- private void handleAuditLoopException(Exception exception) {
- String msg = "AuditThread.run: Could not start audit loop. Exception thrown; message=" + exception.getMessage();
- logger.error(MessageCodes.EXCEPTION_ERROR, exception, msg);
- integrityAudit.setThreadInitialized(false);
- }
-
- private void runUntilInterrupted() throws InterruptedException {
- var auditCompleted = false;
-
- var dbAudit = new DbAudit(dbDao);
-
- IntegrityAuditEntity entityCurrentlyDesignated;
- IntegrityAuditEntity thisEntity;
- integrityAudit.setThreadInitialized(true); // An exception will set it to false
-
- var interrupted = false;
-
- while (!interrupted) {
- try {
- /*
- * It may have been awhile since we last cycled through this loop, so refresh
- * the list of IntegrityAuditEntities.
- */
- List integrityAuditEntityList = getIntegrityAuditEntityList();
-
- /*
- * We could've set entityCurrentlyDesignated as a side effect of
- * getIntegrityAuditEntityList(), but then we would've had to make
- * entityCurrentlyDesignated a class level attribute. Using this approach, we
- * can keep it local to the run() method.
- */
- entityCurrentlyDesignated = getEntityCurrentlyDesignated(integrityAuditEntityList);
-
- /*
- * Need to refresh thisEntity each time through loop, because we need a fresh
- * version of lastUpdated.
- */
- thisEntity = getThisEntity(integrityAuditEntityList);
-
- /*
- * If we haven't done the audit yet, note that we're current and see if we're
- * designated.
- */
- auditCompleted = doAudit(auditCompleted, dbAudit, entityCurrentlyDesignated, thisEntity,
- integrityAuditEntityList);
-
- /*
- * If we've just run audit, sleep per the integrity_audit_period_seconds
- * property, otherwise just sleep the normal interval.
- */
- sleepAfterAudit(auditCompleted);
-
- } catch (Exception e) {
- if (isInterruptedException(e)) {
- String msg = "AuditThread.run loop - Exception thrown: " + e.getMessage() + "; Stopping.";
- logger.error(MessageCodes.EXCEPTION_ERROR, e, msg);
- Thread.currentThread().interrupt();
- interrupted = true;
-
- } else {
- String msg = "AuditThread.run loop - Exception thrown: " + e.getMessage()
- + "; Will try audit again in " + integrityAuditPeriodSeconds + " seconds";
- logger.error(MessageCodes.EXCEPTION_ERROR, e, msg);
- // Sleep and try again later
- AuditorTime.getInstance().sleep(integrityAuditPeriodSeconds * 1000L);
- }
- }
- }
- }
-
- private boolean doAudit(boolean auditCompleted, DbAudit dbAudit, IntegrityAuditEntity entityCurrentlyDesignated,
- IntegrityAuditEntity thisEntity, List integrityAuditEntityList)
- throws IntegrityAuditException {
-
- if (!auditCompleted) {
- dbDao.setLastUpdated();
-
- /*
- * If no current designation or currently designated node is stale, see if
- * we're the next node to be designated.
- */
- if (entityCurrentlyDesignated == null || isStale(entityCurrentlyDesignated)) {
- IntegrityAuditEntity designationCandidate =
- getDesignationCandidate(integrityAuditEntityList);
-
- /*
- * If we're the next node to be designated, run the audit.
- */
- if (designationCandidate.getResourceName().equals(this.resourceName)) {
- runAudit(dbAudit);
- auditCompleted = true;
- } else if (logger.isDebugEnabled()) {
- logger.debug("AuditThread.run: designationCandidate, " + designationCandidate.getResourceName()
- + ", not this entity, " + thisEntity.getResourceName());
- }
-
- /*
- * Application may have been stopped and restarted, in which case we
- * might be designated but auditCompleted will have been reset to false,
- * so account for this.
- */
- } else if (thisEntity.getResourceName().equals(entityCurrentlyDesignated.getResourceName())) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("AuditThread.run: Re-running audit for " + thisEntity.getResourceName());
- }
- runAudit(dbAudit);
- auditCompleted = true;
-
- } else if (logger.isDebugEnabled()) {
- logger.debug("AuditThread.run: Currently designated node, "
- + entityCurrentlyDesignated.getResourceName() + ", not yet stale and not this node");
- }
-
-
- /*
- * Audit already completed on this node, so allow the node to go stale until
- * twice the AUDIT_COMPLETION_PERIOD has elapsed. This should give plenty of
- * time for another node (if another node is out there) to pick up
- * designation.
- */
- } else {
-
- auditCompleted = resetAuditCompleted(auditCompleted, thisEntity);
-
- }
- return auditCompleted;
- }
-
- private void sleepAfterAudit(boolean auditCompleted) throws InterruptedException {
- if (auditCompleted) {
- // for junit testing: indicate that an audit has completed
- auditCompleted();
-
- if (logger.isDebugEnabled()) {
- logger.debug("AuditThread.run: Audit completed; resourceName=" + this.resourceName
- + " sleeping " + integrityAuditPeriodSeconds + "s");
- }
- AuditorTime.getInstance().sleep(integrityAuditPeriodSeconds * 1000L);
- if (logger.isDebugEnabled()) {
- logger.debug(AUDIT_THREAD_MESSAGE + this.resourceName + " awaking from "
- + integrityAuditPeriodSeconds + "s sleep");
- }
-
- } else {
-
- if (logger.isDebugEnabled()) {
- logger.debug(AUDIT_THREAD_MESSAGE + this.resourceName + ": Sleeping "
- + AuditThread.AUDIT_THREAD_SLEEP_INTERVAL_MS + "ms");
- }
- AuditorTime.getInstance().sleep(AuditThread.AUDIT_THREAD_SLEEP_INTERVAL_MS);
- if (logger.isDebugEnabled()) {
- logger.debug(AUDIT_THREAD_MESSAGE + this.resourceName + ": Awaking from "
- + AuditThread.AUDIT_THREAD_SLEEP_INTERVAL_MS + "ms sleep");
- }
-
- }
- }
-
- /**
- * Determines if an exception is an InterruptedException or was caused by an
- * InterruptedException.
- *
- * @param ex exception to be examined
- * @return {@code true} if it's an InterruptedException, {@code false} otherwise
- */
- private boolean isInterruptedException(Throwable ex) {
- while (ex != null) {
- if (ex instanceof InterruptedException) {
- return true;
- }
-
- ex = ex.getCause();
- }
-
- return false;
- }
-
- /**
- * getDesignationCandidate() Using round robin algorithm, gets next candidate to be designated.
- * Assumes list is sorted lexicographically by resourceName.
- */
- private IntegrityAuditEntity getDesignationCandidate(List integrityAuditEntityList) {
-
- // Note: assumes integrityAuditEntityList is already lexicographically sorted by
- // resourceName
-
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: Entering, integrityAuditEntityList.size()="
- + integrityAuditEntityList.size());
- }
-
- IntegrityAuditEntity thisEntity = null;
-
- var designatedEntityIndex = -1;
- var entityIndex = 0;
- var priorCandidateIndex = -1;
- var subsequentCandidateIndex = -1;
-
- for (IntegrityAuditEntity integrityAuditEntity : integrityAuditEntityList) {
-
- if (logger.isDebugEnabled()) {
- logIntegrityAuditEntity(integrityAuditEntity);
- }
-
- thisEntity = detmEntity(integrityAuditEntity, thisEntity);
-
- if (integrityAuditEntity.isDesignated()) {
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: Currently designated entity resourceName="
- + integrityAuditEntity.getResourceName() + PERSISTENCE_MESSAGE
- + integrityAuditEntity.getPersistenceUnit() + LAST_UPDATED_MESSAGE
- + integrityAuditEntity.getLastUpdated() + ENTITY_INDEX_MESSAGE + entityIndex);
- }
- designatedEntityIndex = entityIndex;
-
- /*
- * Entity not currently designated
- */
- } else if (isStale(integrityAuditEntity)) {
- /*
- * Non-designated entity is stale.
- */
-
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: Entity is stale; resourceName="
- + integrityAuditEntity.getResourceName() + PERSISTENCE_MESSAGE
- + integrityAuditEntity.getPersistenceUnit() + LAST_UPDATED_MESSAGE
- + integrityAuditEntity.getLastUpdated() + ENTITY_INDEX_MESSAGE + entityIndex);
- }
-
- /*
- * Entity is current.
- */
- } else if (designatedEntityIndex == -1) {
- priorCandidateIndex = detmPriorCandidate(entityIndex, integrityAuditEntity, priorCandidateIndex);
-
- } else {
- subsequentCandidateIndex =
- detmSubsequentCandidate(entityIndex, integrityAuditEntity, subsequentCandidateIndex);
- }
-
- entityIndex++;
-
- } // end for loop
-
- return detmDesignationCandidate(integrityAuditEntityList, thisEntity, priorCandidateIndex,
- subsequentCandidateIndex);
- }
-
- private IntegrityAuditEntity detmEntity(IntegrityAuditEntity integrityAuditEntity,
- IntegrityAuditEntity thisEntity) {
- if (integrityAuditEntity.getResourceName().equals(this.resourceName)) {
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: thisEntity=" + integrityAuditEntity.getResourceName());
- }
- thisEntity = integrityAuditEntity;
- }
- return thisEntity;
- }
-
- private int detmPriorCandidate(int entityIndex, IntegrityAuditEntity integrityAuditEntity,
- int priorCandidateIndex) {
- if (priorCandidateIndex == -1) {
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: Prior candidate found, resourceName="
- + integrityAuditEntity.getResourceName() + PERSISTENCE_MESSAGE
- + integrityAuditEntity.getPersistenceUnit() + LAST_UPDATED_MESSAGE
- + integrityAuditEntity.getLastUpdated() + ENTITY_INDEX_MESSAGE + entityIndex);
- }
- priorCandidateIndex = entityIndex;
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug(
- "getDesignationCandidate: Prior entity current but prior candidate already "
- + "found; resourceName=" + integrityAuditEntity.getResourceName()
- + PERSISTENCE_MESSAGE + integrityAuditEntity.getPersistenceUnit()
- + LAST_UPDATED_MESSAGE + integrityAuditEntity.getLastUpdated()
- + ENTITY_INDEX_MESSAGE + entityIndex);
- }
- }
- return priorCandidateIndex;
- }
-
- private int detmSubsequentCandidate(int entityIndex, IntegrityAuditEntity integrityAuditEntity,
- int subsequentCandidateIndex) {
- if (subsequentCandidateIndex == -1) {
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: Subsequent candidate found, resourceName="
- + integrityAuditEntity.getResourceName() + PERSISTENCE_MESSAGE
- + integrityAuditEntity.getPersistenceUnit() + LAST_UPDATED_MESSAGE
- + integrityAuditEntity.getLastUpdated() + ENTITY_INDEX_MESSAGE + entityIndex);
- }
- subsequentCandidateIndex = entityIndex;
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug(
- "getDesignationCandidate: Subsequent entity current but subsequent candidate "
- + "already found; resourceName="
- + integrityAuditEntity.getResourceName() + PERSISTENCE_MESSAGE
- + integrityAuditEntity.getPersistenceUnit() + LAST_UPDATED_MESSAGE
- + integrityAuditEntity.getLastUpdated() + ENTITY_INDEX_MESSAGE
- + entityIndex);
- }
- }
- return subsequentCandidateIndex;
- }
-
- private IntegrityAuditEntity detmDesignationCandidate(List integrityAuditEntityList,
- IntegrityAuditEntity thisEntity, int priorCandidateIndex, int subsequentCandidateIndex) {
- IntegrityAuditEntity designationCandidate;
- /*
- * Per round robin algorithm, if a current entity is found that is lexicographically after
- * the currently designated entity, this entity becomes the designation candidate. If no
- * current entity is found that is lexicographically after currently designated entity, we
- * cycle back to beginning of list and pick the first current entity as the designation
- * candidate.
- */
- if (subsequentCandidateIndex != -1) {
- designationCandidate = integrityAuditEntityList.get(subsequentCandidateIndex);
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: Exiting and returning subsequent designationCandidate="
- + designationCandidate.getResourceName());
- }
- } else {
- if (priorCandidateIndex != -1) {
- designationCandidate = integrityAuditEntityList.get(priorCandidateIndex);
- if (logger.isDebugEnabled()) {
- logger.debug("getDesignationCandidate: Exiting and returning prior designationCandidate="
- + designationCandidate.getResourceName());
- }
- } else if (thisEntity != null) {
- logger.debug("getDesignationCandidate: No subsequent or prior candidate found; designating thisEntity, "
- + "resourceName=" + thisEntity.getResourceName());
- designationCandidate = thisEntity;
- } else {
- // this shouldn't happen, but adding it to make sonar happy
- logger.debug("getDesignationCandidate: No entities available");
- designationCandidate = null;
- }
- }
-
- return designationCandidate;
- }
-
- /**
- * getEntityCurrentlyDesignated() Returns entity that is currently designated.
- *
- * @param integrityAuditEntityList the integrity audit entity list
- * @return the currently designated integrity audit entity
- */
- private IntegrityAuditEntity getEntityCurrentlyDesignated(List integrityAuditEntityList) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("getEntityCurrentlyDesignated: Entering, integrityAuditEntityList.size="
- + integrityAuditEntityList.size());
- }
-
- IntegrityAuditEntity entityCurrentlyDesignated = null;
-
- for (IntegrityAuditEntity integrityAuditEntity : integrityAuditEntityList) {
-
- if (integrityAuditEntity.isDesignated()) {
- if (logger.isDebugEnabled()) {
- logger.debug("getEntityCurrentlyDesignated: Currently designated entity resourceName="
- + integrityAuditEntity.getResourceName() + PERSISTENCE_MESSAGE
- + integrityAuditEntity.getPersistenceUnit() + LAST_UPDATED_MESSAGE
- + integrityAuditEntity.getLastUpdated());
- }
- entityCurrentlyDesignated = integrityAuditEntity;
- }
-
- } // end for loop
-
- if (logger.isDebugEnabled()) {
- if (entityCurrentlyDesignated != null) {
- logger.debug("getEntityCurrentlyDesignated: Exiting and returning entityCurrentlyDesignated="
- + entityCurrentlyDesignated.getResourceName());
- } else {
- logger.debug("getEntityCurrentlyDesignated: Exiting and returning entityCurrentlyDesignated="
- + entityCurrentlyDesignated);
- }
- }
- return entityCurrentlyDesignated;
-
- }
-
- /**
- * getIntegrityAuditEnityList gets the list of IntegrityAuditEntity.
- *
- * @return the list of IntegrityAuditEntity
- * @throws DbDaoTransactionException if an error occurs getting the list of IntegrityAuditEntity
- */
- private List getIntegrityAuditEntityList() throws DbDaoTransactionException {
-
- if (logger.isDebugEnabled()) {
- logger.debug("getIntegrityAuditEntityList: Entering");
- }
-
- /*
- * Get all records for this nodeType and persistenceUnit and then sort them
- * lexicographically by resourceName. Get index of designated entity, if any.
- */
- /*
- * Sorted list of entities for a particular nodeType and persistenceUnit.
- */
- List integrityAuditEntityList =
- dbDao.getIntegrityAuditEntities(this.persistenceUnit, this.nodeType);
- var listSize = integrityAuditEntityList.size();
- if (logger.isDebugEnabled()) {
- logger.debug("getIntegrityAuditEntityList: Got " + listSize + " IntegrityAuditEntity records");
- }
- Collections.sort(integrityAuditEntityList, comparator);
-
- if (logger.isDebugEnabled()) {
- logger.debug(
- "getIntegrityAuditEntityList: Exiting and returning integrityAuditEntityList, size=" + listSize);
- }
- return integrityAuditEntityList;
-
- }
-
-
- /**
- * Returns the IntegrityAuditEntity for this entity.
- *
- * @param integrityAuditEntityList the list of IntegrityAuditEntity
- * @return the IntegrityAuditEntity for this entity
- */
- private IntegrityAuditEntity getThisEntity(List integrityAuditEntityList) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("getThisEntity: Entering, integrityAuditEntityList.size=" + integrityAuditEntityList.size());
- }
-
- IntegrityAuditEntity thisEntity = null;
-
- for (IntegrityAuditEntity integrityAuditEntity : integrityAuditEntityList) {
-
- if (integrityAuditEntity.getResourceName().equals(this.resourceName)) {
- if (logger.isDebugEnabled()) {
- logger.debug(
- "getThisEntity: For this entity, resourceName=" + integrityAuditEntity.getResourceName()
- + PERSISTENCE_MESSAGE + integrityAuditEntity.getPersistenceUnit()
- + LAST_UPDATED_MESSAGE + integrityAuditEntity.getLastUpdated());
- }
- thisEntity = integrityAuditEntity;
- }
-
- } // end for loop
-
- if (logger.isDebugEnabled()) {
- if (thisEntity != null) {
- logger.debug("getThisEntity: Exiting and returning thisEntity=" + thisEntity.getResourceName());
- } else {
- logger.debug("getThisEntity: Exiting and returning thisEntity=" + thisEntity);
- }
- }
- return thisEntity;
-
- }
-
-
- /**
- * Returns false if the lastUpdated time for the record in question is more than
- * auditCompletionIntervalMillis seconds ago. During an audit, lastUpdated is updated every five
- * seconds or so, but when an audit finishes, the node doing the audit stops updating
- * lastUpdated.
- *
- * @param integrityAuditEntity the integrityAuditEntity
- * @return false if the lastUpdated time for the record in question is more than
- * auditCompletionIntervalMillis seconds ago
- */
- private boolean isStale(IntegrityAuditEntity integrityAuditEntity) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("isStale: Entering, resourceName=" + integrityAuditEntity.getResourceName()
- + PERSISTENCE_MESSAGE + integrityAuditEntity.getPersistenceUnit() + LAST_UPDATED_MESSAGE
- + integrityAuditEntity.getLastUpdated());
- }
-
- var stale = false;
-
- var currentTime = AuditorTime.getInstance().getDate();
- var lastUpdated = integrityAuditEntity.getLastUpdated();
-
- /*
- * If lastUpdated is null, we assume that the audit never ran for that node.
- */
- long lastUpdatedTime = 0;
- if (lastUpdated != null) {
- lastUpdatedTime = lastUpdated.getTime();
- }
- long timeDifference = currentTime.getTime() - lastUpdatedTime;
- if (timeDifference > AUDIT_COMPLETION_INTERVAL) {
- stale = true;
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("isStale: Exiting and returning stale=" + stale + ", timeDifference=" + timeDifference);
- }
-
- return stale;
- }
-
- private void logIntegrityAuditEntity(IntegrityAuditEntity integrityAuditEntity) {
-
- logger.debug("logIntegrityAuditEntity: id=" + integrityAuditEntity.getId() + ", jdbcDriver="
- + integrityAuditEntity.getJdbcDriver() + ", jdbcPassword=" + integrityAuditEntity.getJdbcPassword()
- + ", jdbcUrl=" + integrityAuditEntity.getJdbcUrl() + ", jdbcUser=" + integrityAuditEntity.getJdbcUser()
- + ", nodeType=" + integrityAuditEntity.getNodeType() + PERSISTENCE_MESSAGE
- + integrityAuditEntity.getPersistenceUnit() + ", resourceName=" + integrityAuditEntity.getResourceName()
- + ", site=" + integrityAuditEntity.getSite() + ", createdDate=" + integrityAuditEntity.getCreatedDate()
- + LAST_UPDATED_MESSAGE + integrityAuditEntity.getLastUpdated() + ", designated="
- + integrityAuditEntity.isDesignated());
- }
-
- /*
- * If more than (auditCompletionIntervalMillis * 2) milliseconds have elapsed since we last ran
- * the audit, reset auditCompleted, so
- *
- * 1) we'll eventually re-run the audit, if no other node picks up the designation.
- *
- * or
- *
- * 2) We'll run the audit when the round robin comes back to us.
- */
- private boolean resetAuditCompleted(boolean auditCompleted, IntegrityAuditEntity thisEntity) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("resetAuditCompleted: auditCompleted=" + auditCompleted + "; for thisEntity, resourceName="
- + thisEntity.getResourceName() + PERSISTENCE_MESSAGE + thisEntity.getPersistenceUnit()
- + LAST_UPDATED_MESSAGE + thisEntity.getLastUpdated());
- }
-
- long timeDifference;
-
- var currentTime = AuditorTime.getInstance().getDate();
- var lastUpdated = thisEntity.getLastUpdated();
-
- long lastUpdatedTime = lastUpdated.getTime();
- timeDifference = currentTime.getTime() - lastUpdatedTime;
-
- if (timeDifference > (AUDIT_COMPLETION_INTERVAL * AUDIT_RESET_CYCLES)) {
- if (logger.isDebugEnabled()) {
- logger.debug("resetAuditCompleted: Resetting auditCompleted for resourceName=" + this.resourceName);
- }
- auditCompleted = false;
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug(
- "resetAuditCompleted: For resourceName=" + resourceName + ", time since last update is only "
- + timeDifference + "; retaining current value for auditCompleted");
- }
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("resetAuditCompleted: Exiting and returning auditCompleted=" + auditCompleted
- + ", timeDifference=" + timeDifference);
- }
- return auditCompleted;
- }
-
- private void runAudit(DbAudit dbAudit) throws IntegrityAuditException {
-
- if (logger.isDebugEnabled()) {
- logger.debug("runAudit: Entering, dbAudit=" + dbAudit + "; notifying other resources that resourceName="
- + this.resourceName + " is current");
- }
-
- /*
- * changeDesignated marks all other nodes as non-designated and this node as designated.
- */
- dbDao.changeDesignated(this.resourceName, this.persistenceUnit, this.nodeType);
-
- if (logger.isDebugEnabled()) {
- logger.debug("runAudit: Running audit for persistenceUnit=" + this.persistenceUnit + " on resourceName="
- + this.resourceName);
- }
-
- dbAudit.dbAudit(this.resourceName, this.persistenceUnit, this.nodeType);
-
- if (logger.isDebugEnabled()) {
- logger.debug("runAudit: Exiting");
- }
-
- }
-
- /**
- * Indicates that the {@link #run()} method has started. This method simply returns,
- * and may overridden by junit tests.
- *
- * @throws InterruptedException can be interrupted
- */
- public void runStarted() throws InterruptedException {
- // does nothing
- }
-
- /**
- * Indicates that an audit has completed. This method simply returns, and may
- * overridden by junit tests.
- *
- * @throws InterruptedException can be interrupted
- */
- public void auditCompleted() throws InterruptedException {
- // does nothing
- }
-}
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditorTime.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditorTime.java
deleted file mode 100644
index 5bfedaac..00000000
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditorTime.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Integrity Audit
- * ================================================================================
- * Copyright (C) 2018, 2021 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.ia;
-
-import java.util.function.Supplier;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.onap.policy.common.utils.time.CurrentTime;
-
-/**
- * "Current" time used by IntegrityMonitor classes.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public class AuditorTime {
-
- /**
- * Instance to be used.
- */
- private static final CurrentTime currentTime = new CurrentTime();
-
- /**
- * Supplies the instance to be used for accessing the current time. This may be
- * overridden by junit tests to provide a different time instance for each thread when
- * multiple threads are run in parallel.
- */
- private static Supplier supplier = () -> currentTime;
-
- /**
- * Get instance.
- *
- * @return the CurrentTime singleton
- */
- public static CurrentTime getInstance() {
- return supplier.get();
- }
-}
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java
deleted file mode 100644
index 22ffa08e..00000000
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java
+++ /dev/null
@@ -1,503 +0,0 @@
-/*--
- * ============LICENSE_START=======================================================
- * Integrity Audit
- * ================================================================================
- * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.ia;
-
-import jakarta.persistence.Table;
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.Set;
-import org.apache.commons.lang3.SerializationUtils;
-import org.apache.commons.lang3.builder.RecursiveToStringStyle;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-import org.onap.policy.common.ia.jpa.IntegrityAuditEntity;
-import org.onap.policy.common.logging.eelf.MessageCodes;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
-
-/**
- * class DbAudit does actual auditing of DB tables.
- */
-public class DbAudit {
-
- private static final Logger logger = FlexLogger.getLogger(DbAudit.class);
-
- private static final String COMMA_RESOURCE_NAME = ", resourceName=";
-
- private static final long DB_AUDIT_UPDATE_MS = 5000L;
- private static final long DB_AUDIT_SLEEP_MS = 2000L;
-
- DbDao dbDao = null;
-
- /**
- * Construct an instance with the given DbDao.
- *
- * @param dbDao the DbDao
- */
- public DbAudit(DbDao dbDao) {
-
- logger.debug("Constructor: Entering");
-
- this.dbDao = dbDao;
-
- logger.debug("Constructor: Exiting");
- }
-
- /**
- * dbAudit actually does the audit.
- *
- * @param resourceName the resource name
- * @param persistenceUnit the persistence unit
- * @param nodeType the node type
- * @throws IntegrityAuditException if an error occurs
- */
- public void dbAudit(String resourceName, String persistenceUnit, String nodeType) throws IntegrityAuditException {
-
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Entering, resourceName=" + resourceName + ", persistenceUnit=" + persistenceUnit
- + ", nodeType=" + nodeType);
- }
-
- // Get all IntegrityAudit entries so we can get the DB access info
- List iaeList = dbDao.getIntegrityAuditEntities(persistenceUnit, nodeType);
- if (iaeList == null || iaeList.isEmpty()) {
-
- String msg = "DbAudit: for node " + resourceName + " Found no IntegrityAuditEntity entries";
- logger.error(MessageCodes.ERROR_AUDIT, msg);
- throw new DbAuditException(msg);
-
- } else if (iaeList.size() == 1) {
-
- Long iaeId = null;
- String iaeRn = null;
- String iaeNt = null;
- String iaeS = null;
- for (IntegrityAuditEntity iae : iaeList) {
- iaeId = iae.getId();
- iaeRn = iae.getResourceName();
- iaeNt = iae.getNodeType();
- iaeS = iae.getSite();
- }
- String msg = "DbAudit: Found only one IntegrityAuditEntity entry:" + " ID = " + iaeId + " ResourceName = "
- + iaeRn + " NodeType = " + iaeNt + " Site = " + iaeS;
- logger.warn(msg);
- return;
- }
-
- // Obtain all persistence class names for the PU we are auditing
- Set classNameSet = dbDao.getPersistenceClassNames();
- if (classNameSet == null || classNameSet.isEmpty()) {
-
- String msg = "DbAudit: For node " + resourceName + " Found no persistence class names";
- logger.error(MessageCodes.ERROR_AUDIT, msg);
- throw new DbAuditException(msg);
-
- }
-
- /*
- * Retrieve myIae. We are going to compare the local class entries against all other DB
- * nodes. Since the audit is run in a round-robin, every instance will be compared against
- * every other instance.
- */
- var myIae = dbDao.getMyIntegrityAuditEntity();
-
- if (myIae == null) {
-
- String msg = "DbAudit: Found no IntegrityAuditEntity entry for resourceName: " + resourceName
- + " persistenceUnit: " + persistenceUnit;
- logger.error(MessageCodes.ERROR_AUDIT, msg);
- throw new DbAuditException(msg);
-
- }
- /*
- * This is the map of mismatched entries indexed by className. For each class name there is
- * a list of mismatched entries
- */
- Map> misMatchedMap = new HashMap<>();
-
- compareList(persistenceUnit, iaeList, myIae, classNameSet, misMatchedMap);
-
- // If misMatchedMap is not empty, retrieve the entries in each misMatched list and compare
- // again
- recompareList(resourceName, persistenceUnit, iaeList, myIae, misMatchedMap);
-
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Exiting");
- }
- }
-
- private void compareList(String persistenceUnit, List iaeList, IntegrityAuditEntity myIae,
- Set classNameSet, Map> misMatchedMap)
- throws IntegrityAuditException {
-
- // We need to keep track of how long the audit is taking
- long startTime = AuditorTime.getInstance().getMillis();
-
- // Retrieve all instances of the class for each node
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: Traversing classNameSet, size=" + classNameSet.size());
- }
- for (String clazzName : classNameSet) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("dbAudit: clazzName=" + clazzName);
- }
-
- // all instances of the class for myIae
- Map