aboutsummaryrefslogtreecommitdiffstats
path: root/integrity-audit
diff options
context:
space:
mode:
Diffstat (limited to 'integrity-audit')
-rw-r--r--integrity-audit/pom.xml138
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java44
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/AuditorTime.java18
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java29
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java395
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java36
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java20
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java157
-rw-r--r--integrity-audit/src/main/resources/META-INF/persistence.xml51
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java13
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/DbDaoTest.java15
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java27
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java27
13 files changed, 401 insertions, 569 deletions
diff --git a/integrity-audit/pom.xml b/integrity-audit/pom.xml
index f7a170ad..c6f1611e 100644
--- a/integrity-audit/pom.xml
+++ b/integrity-audit/pom.xml
@@ -2,7 +2,8 @@
============LICENSE_START=======================================================
ONAP Policy Engine - Common Modules
================================================================================
- Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ 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.
@@ -18,10 +19,7 @@
============LICENSE_END=========================================================
-->
-<project
- xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -32,48 +30,50 @@
<parent>
<groupId>org.onap.policy.common</groupId>
<artifactId>common-modules</artifactId>
- <version>1.7.1-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<name>Integrity Audit</name>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>utils</artifactId>
+ <version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito2</artifactId>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>utils-test</artifactId>
+ <version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-ext</artifactId>
- <scope>test</scope>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>ONAP-Logging</artifactId>
+ <version>${project.version}</version>
</dependency>
<dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
</dependency>
<dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>javax.persistence</artifactId>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core-jakarta</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>eclipselink</artifactId>
+ <groupId>org.hibernate.validator</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.onap.policy.common</groupId>
- <artifactId>utils</artifactId>
- <version>${project.version}</version>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
- <groupId>org.onap.policy.common</groupId>
- <artifactId>utils-test</artifactId>
- <version>${project.version}</version>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-ext</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -82,88 +82,14 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.onap.policy.common</groupId>
- <artifactId>ONAP-Logging</artifactId>
- <version>${project.version}</version>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <executions>
- <execution>
- <id>onap-java-style</id>
- <goals>
- <goal>check</goal>
- </goals>
- <phase>process-sources</phase>
- <configuration>
- <!-- Use Google Java Style Guide:
- https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
- with minor changes -->
- <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
- <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
- <sourceDirectories>${project.build.sourceDirectory}</sourceDirectories>
- <includeResources>true</includeResources>
- <includeTestSourceDirectory>true</includeTestSourceDirectory>
- <includeTestResources>true</includeTestResources>
- <excludes>
- </excludes>
- <consoleOutput>true</consoleOutput>
- <failsOnViolation>true</failsOnViolation>
- <violationSeverity>warning</violationSeverity>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.onap.oparent</groupId>
- <artifactId>checkstyle</artifactId>
- <version>${oparent.version}</version>
- <scope>compile</scope>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- <pluginManagement>
- <plugins>
- <!--This plugin's configuration is used to store Eclipse m2e settings
- only. It has no influence on the Maven build itself. -->
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <version>1.0.0</version>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>org.jacoco</groupId>
- <artifactId>
- jacoco-maven-plugin
- </artifactId>
- <versionRange>
- [0.7.1.201405082137,)
- </versionRange>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore />
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
</project>
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
index 32246c86..03fbdb57 100644
--- 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -22,7 +22,6 @@ package org.onap.policy.common.ia;
import java.util.Collections;
import java.util.Comparator;
-import java.util.Date;
import java.util.List;
import java.util.Properties;
import org.onap.policy.common.ia.jpa.IntegrityAuditEntity;
@@ -149,10 +148,12 @@ public class AuditThread extends Thread {
*/
runUntilInterrupted();
+ } catch (InterruptedException e) {
+ handleAuditLoopException(e);
+ Thread.currentThread().interrupt();
+
} catch (Exception e) {
- String msg = "AuditThread.run: Could not start audit loop. Exception thrown; message=" + e.getMessage();
- logger.error(MessageCodes.EXCEPTION_ERROR, e, msg);
- integrityAudit.setThreadInitialized(false);
+ handleAuditLoopException(e);
}
dbDao.destroy();
@@ -160,16 +161,22 @@ public class AuditThread extends Thread {
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 {
- boolean auditCompleted = false;
+ var auditCompleted = false;
- DbAudit dbAudit = new DbAudit(dbDao);
+ var dbAudit = new DbAudit(dbDao);
IntegrityAuditEntity entityCurrentlyDesignated;
IntegrityAuditEntity thisEntity;
integrityAudit.setThreadInitialized(true); // An exception will set it to false
- boolean interrupted = false;
+ var interrupted = false;
while (!interrupted) {
try {
@@ -210,6 +217,7 @@ public class AuditThread extends Thread {
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 {
@@ -347,10 +355,10 @@ public class AuditThread extends Thread {
IntegrityAuditEntity thisEntity = null;
- int designatedEntityIndex = -1;
- int entityIndex = 0;
- int priorCandidateIndex = -1;
- int subsequentCandidateIndex = -1;
+ var designatedEntityIndex = -1;
+ var entityIndex = 0;
+ var priorCandidateIndex = -1;
+ var subsequentCandidateIndex = -1;
for (IntegrityAuditEntity integrityAuditEntity : integrityAuditEntityList) {
@@ -561,7 +569,7 @@ public class AuditThread extends Thread {
*/
List<IntegrityAuditEntity> integrityAuditEntityList =
dbDao.getIntegrityAuditEntities(this.persistenceUnit, this.nodeType);
- int listSize = integrityAuditEntityList.size();
+ var listSize = integrityAuditEntityList.size();
if (logger.isDebugEnabled()) {
logger.debug("getIntegrityAuditEntityList: Got " + listSize + " IntegrityAuditEntity records");
}
@@ -634,10 +642,10 @@ public class AuditThread extends Thread {
+ integrityAuditEntity.getLastUpdated());
}
- boolean stale = false;
+ var stale = false;
- Date currentTime = AuditorTime.getInstance().getDate();
- Date lastUpdated = integrityAuditEntity.getLastUpdated();
+ var currentTime = AuditorTime.getInstance().getDate();
+ var lastUpdated = integrityAuditEntity.getLastUpdated();
/*
* If lastUpdated is null, we assume that the audit never ran for that node.
@@ -690,8 +698,8 @@ public class AuditThread extends Thread {
long timeDifference;
- Date currentTime = AuditorTime.getInstance().getDate();
- Date lastUpdated = thisEntity.getLastUpdated();
+ var currentTime = AuditorTime.getInstance().getDate();
+ var lastUpdated = thisEntity.getLastUpdated();
long lastUpdatedTime = lastUpdated.getTime();
timeDifference = currentTime.getTime() - lastUpdatedTime;
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
index 95eecbc3..5bfedaac 100644
--- 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
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -21,11 +21,14 @@
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 {
/**
@@ -41,15 +44,8 @@ public class AuditorTime {
private static Supplier<CurrentTime> supplier = () -> currentTime;
/**
- * Constructor.
- */
- private AuditorTime() {
- super();
- }
-
- /**
* Get instance.
- *
+ *
* @return the CurrentTime singleton
*/
public static CurrentTime getInstance() {
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
index f69173f8..22ffa08e 100644
--- 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
@@ -2,7 +2,8 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -20,6 +21,7 @@
package org.onap.policy.common.ia;
+import jakarta.persistence.Table;
import java.io.Serializable;
import java.util.Arrays;
import java.util.HashMap;
@@ -29,7 +31,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
-import javax.persistence.Table;
import org.apache.commons.lang3.SerializationUtils;
import org.apache.commons.lang3.builder.RecursiveToStringStyle;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
@@ -123,7 +124,7 @@ public class DbAudit {
* nodes. Since the audit is run in a round-robin, every instance will be compared against
* every other instance.
*/
- IntegrityAuditEntity myIae = dbDao.getMyIntegrityAuditEntity();
+ var myIae = dbDao.getMyIntegrityAuditEntity();
if (myIae == null) {
@@ -267,7 +268,7 @@ public class DbAudit {
* @return DAO properties for the given DB node
*/
private Properties getTheirDaoProperties(IntegrityAuditEntity iae) {
- Properties theirProperties = new Properties();
+ var theirProperties = new Properties();
theirProperties.put(IntegrityAuditProperties.DB_DRIVER, iae.getJdbcDriver());
theirProperties.put(IntegrityAuditProperties.DB_URL, iae.getJdbcUrl());
@@ -294,7 +295,7 @@ public class DbAudit {
logger.debug("dbAudit: Second comparison; traversing classNameSet, size=" + classNameSet.size());
}
- int errorCount = 0;
+ var errorCount = 0;
for (String clazzName : classNameSet) {
@@ -316,7 +317,7 @@ public class DbAudit {
startTime = timeCheck("Second", startTime);
}
- if (errorCount != 0) {
+ if (errorCount > 0) {
String msg = " DB Audit: " + errorCount
+ " errors found. A large number of errors may indicate DB replication has stopped";
logger.error(MessageCodes.ERROR_AUDIT, msg);
@@ -327,7 +328,7 @@ public class DbAudit {
IntegrityAuditEntity myIae, String clazzName, Set<Object> keySet, Map<Object, Object> myEntries)
throws IntegrityAuditException {
- int errorCount = 0;
+ var errorCount = 0;
for (IntegrityAuditEntity iae : iaeList) {
if (iae.getId() == myIae.getId()) {
if (logger.isDebugEnabled()) {
@@ -363,7 +364,7 @@ public class DbAudit {
return 0;
}
- StringBuilder keyBuilder = new StringBuilder();
+ var keyBuilder = new StringBuilder();
for (Object key : misMatchedKeySet) {
keyBuilder.append(key.toString());
keyBuilder.append(", ");
@@ -459,13 +460,17 @@ public class DbAudit {
String tableName = entityClass.getAnnotation(Table.class).name();
String msg = "\nDB Audit Error: " + "\n Table Name: " + tableName
+ "\n Entry 1 (short prefix style): " + resourceName1 + ": "
- + new ReflectionToStringBuilder(entry1, ToStringStyle.SHORT_PREFIX_STYLE).toString()
+ + new ReflectionToStringBuilder(entry1, ToStringStyle.SHORT_PREFIX_STYLE)
+ "\n Entry 2 (short prefix style): " + resourceName2 + ": "
- + new ReflectionToStringBuilder(entry2, ToStringStyle.SHORT_PREFIX_STYLE).toString()
+ + (entry2 != null
+ ? new ReflectionToStringBuilder(entry2, ToStringStyle.SHORT_PREFIX_STYLE).toString()
+ : "null")
+ "\n Entry 1 (recursive style): " + resourceName1 + ": "
- + new ReflectionToStringBuilder(entry1, new RecursiveToStringStyle()).toString()
+ + new ReflectionToStringBuilder(entry1, new RecursiveToStringStyle())
+ "\n Entry 2 (recursive style): " + resourceName2 + ": "
- + new ReflectionToStringBuilder(entry2, new RecursiveToStringStyle()).toString();
+ + (entry2 != null
+ ? new ReflectionToStringBuilder(entry2, new RecursiveToStringStyle()).toString()
+ : "null");
logger.debug(msg);
} catch (ClassNotFoundException e) {
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java
index ff4d2976..ad96432d 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java
@@ -2,7 +2,8 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -20,6 +21,15 @@
package org.onap.policy.common.ia;
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.EntityManagerFactory;
+import jakarta.persistence.EntityTransaction;
+import jakarta.persistence.Persistence;
+import jakarta.persistence.Query;
+import jakarta.persistence.TypedQuery;
+import jakarta.persistence.criteria.CriteriaQuery;
+import jakarta.persistence.criteria.Root;
+import jakarta.persistence.metamodel.ManagedType;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -27,25 +37,12 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.function.BiConsumer;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.EntityTransaction;
-import javax.persistence.Persistence;
-import javax.persistence.PersistenceUnitUtil;
-import javax.persistence.Query;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Root;
-import javax.persistence.metamodel.ManagedType;
-import javax.persistence.metamodel.Metamodel;
import org.onap.policy.common.ia.jpa.IntegrityAuditEntity;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
/**
* class DbDao provides the inteface to the DBs for the purpose of audits.
- *
*/
public class DbDao {
private static final Logger logger = FlexLogger.getLogger();
@@ -59,7 +56,7 @@ public class DbDao {
private String nodeType;
private Properties properties = null;
- private EntityManagerFactory emf;
+ private final EntityManagerFactory emf;
/*
* Supports designation serialization.
@@ -78,14 +75,14 @@ public class DbDao {
* DB SELECT String.
*/
private static final String SELECT_STRING = "Select i from IntegrityAuditEntity i "
- + "where i.resourceName=:rn and i.persistenceUnit=:pu";
+ + "where i.resourceName=:rn and i.persistenceUnit=:pu";
/**
* DbDao Constructor.
*
- * @param resourceName the resource name
+ * @param resourceName the resource name
* @param persistenceUnit the persistence unit
- * @param properties the properties
+ * @param properties the properties
* @throws IntegrityAuditException if an error occurs
*/
public DbDao(String resourceName, String persistenceUnit, Properties properties) throws IntegrityAuditException {
@@ -95,15 +92,14 @@ public class DbDao {
/**
* DbDao Constructor.
*
- * @param resourceName the resource name
+ * @param resourceName the resource name
* @param persistenceUnit the persistence unit
- * @param properties the properties
- * @param lastUpdateDate may be {@code null}
- * @param altDbUrl may be {@code null}
+ * @param properties the properties
+ * @param altDbUrl may be {@code null}
* @throws IntegrityAuditException if an error occurs
*/
protected DbDao(String resourceName, String persistenceUnit, Properties properties, String altDbUrl)
- throws IntegrityAuditException {
+ throws IntegrityAuditException {
logger.debug("DbDao contructor: enter");
validateProperties(resourceName, persistenceUnit, properties);
@@ -125,14 +121,14 @@ public class DbDao {
/**
* validateProperties will validate the properties.
*
- * @param resourceName the rseource name
+ * @param resourceName the rseource name
* @param persistenceUnit the persistence unit
- * @param properties the properties
+ * @param properties the properties
* @throws IntegrityAuditPropertiesException if an error occurs
*/
private void validateProperties(String resourceName, String persistenceUnit, Properties properties)
- throws IntegrityAuditPropertiesException {
- StringBuilder badparams = new StringBuilder();
+ throws IntegrityAuditPropertiesException {
+ var badparams = new StringBuilder();
if (IntegrityAudit.parmsAreBad(resourceName, persistenceUnit, properties, badparams)) {
String msg = "DbDao: Bad parameters: badparams" + badparams;
throw new IntegrityAuditPropertiesException(msg);
@@ -146,7 +142,7 @@ public class DbDao {
this.nodeType = properties.getProperty(IntegrityAuditProperties.NODE_TYPE).trim().toLowerCase();
this.properties = properties;
logger.debug("DbDao.assignProperties: exit:" + "\nresourceName: " + this.resourceName + "\npersistenceUnit: "
- + this.persistenceUnit + "\nproperties: " + this.properties);
+ + this.persistenceUnit + "\nproperties: " + this.properties);
}
/**
@@ -158,21 +154,9 @@ public class DbDao {
public Map<Object, Object> getAllMyEntries(String className) {
logger.debug("getAllMyEntries: Entering, className=" + className);
HashMap<Object, Object> resultMap = new HashMap<>();
- EntityManager em = emf.createEntityManager();
+ var em = emf.createEntityManager();
try {
- CriteriaBuilder cb = em.getCriteriaBuilder();
- CriteriaQuery<Object> cq = cb.createQuery();
- Root<?> rootEntry = cq.from(Class.forName(className));
- CriteriaQuery<Object> all = cq.select(rootEntry);
- TypedQuery<Object> allQuery = em.createQuery(all);
- List<Object> objectList = allQuery.getResultList();
- // Now create the map
-
- PersistenceUnitUtil util = emf.getPersistenceUnitUtil();
- for (Object o : objectList) {
- Object key = util.getIdentifier(o);
- resultMap.put(key, o);
- }
+ getObjectsFromCriteriaBuilder(className, emf, em, resultMap);
} catch (Exception e) {
logger.error("getAllEntries encountered exception: ", e);
}
@@ -185,14 +169,14 @@ public class DbDao {
* getAllMyEntries gets all entries for a class.
*
* @param className the name of the class
- * @param keySet the keys to get the entries for
+ * @param keySet the keys to get the entries for
* @return the map of requested entries
*/
public Map<Object, Object> getAllMyEntries(String className, Set<Object> keySet) {
logger.debug("getAllMyEntries: Entering, className=" + className + ",\n keySet=" + keySet);
HashMap<Object, Object> resultMap = new HashMap<>();
- EntityManager em = emf.createEntityManager();
+ var em = emf.createEntityManager();
try {
Class<?> clazz = Class.forName(className);
for (Object key : keySet) {
@@ -209,11 +193,11 @@ public class DbDao {
}
/**
- * getAllEntries gets all entriesfor a particular persistence unit adn className.
+ * getAllEntries gets all entries for a particular persistence unit adn className.
*
* @param persistenceUnit the persistence unit
- * @param properties the properties
- * @param className the class name
+ * @param properties the properties
+ * @param className the class name
* @return the map of entries
*/
public Map<Object, Object> getAllEntries(String persistenceUnit, Properties properties, String className) {
@@ -221,21 +205,11 @@ public class DbDao {
logger.debug("getAllEntries: Entering, persistenceUnit=" + persistenceUnit + ",\n className=" + className);
HashMap<Object, Object> resultMap = new HashMap<>();
- EntityManagerFactory theEmf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
- EntityManager em = theEmf.createEntityManager();
+ var theEmf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ var em = theEmf.createEntityManager();
+
try {
- CriteriaBuilder cb = em.getCriteriaBuilder();
- CriteriaQuery<Object> cq = cb.createQuery();
- Root<?> rootEntry = cq.from(Class.forName(className));
- CriteriaQuery<Object> all = cq.select(rootEntry);
- TypedQuery<Object> allQuery = em.createQuery(all);
- List<Object> objectList = allQuery.getResultList();
-
- PersistenceUnitUtil util = theEmf.getPersistenceUnitUtil();
- for (Object o : objectList) {
- Object key = util.getIdentifier(o);
- resultMap.put(key, o);
- }
+ getObjectsFromCriteriaBuilder(className, theEmf, em, resultMap);
} catch (Exception e) {
logger.error("getAllEntries encountered exception:", e);
}
@@ -252,18 +226,18 @@ public class DbDao {
* getAllEntries gets all entries for a persistence unit.
*
* @param persistenceUnit the persistence unit
- * @param properties the properties
- * @param className the class name
- * @param keySet the keys
+ * @param properties the properties
+ * @param className the class name
+ * @param keySet the keys
* @return the map of entries
*/
public Map<Object, Object> getAllEntries(String persistenceUnit, Properties properties, String className,
- Set<Object> keySet) {
+ Set<Object> keySet) {
logger.debug("getAllEntries: Entering, persistenceUnit=" + persistenceUnit + ",\n properties= " + properties
- + ",\n className=" + className + ",\n keySet= " + keySet);
- EntityManagerFactory theEmf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
- EntityManager em = theEmf.createEntityManager();
+ + ",\n className=" + className + ",\n keySet= " + keySet);
+ var theEmf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
+ var em = theEmf.createEntityManager();
HashMap<Object, Object> resultMap = new HashMap<>();
try {
Class<?> clazz = Class.forName(className);
@@ -286,34 +260,35 @@ public class DbDao {
* unit and node type.
*
* @param persistenceUnit the persistence unit
- * @param nodeType the node type
+ * @param nodeType the node type
* @return the list of IntegrityAuditEntity
* @throws DbDaoTransactionException if an error occurs
*/
@SuppressWarnings("unchecked")
public List<IntegrityAuditEntity> getIntegrityAuditEntities(String persistenceUnit, String nodeType)
- throws DbDaoTransactionException {
+ throws DbDaoTransactionException {
logger.debug("getIntegrityAuditEntities: Entering, persistenceUnit=" + persistenceUnit + ",\n nodeType= "
- + nodeType);
+ + nodeType);
try {
- EntityManager em = emf.createEntityManager();
- // Start a transaction
- EntityTransaction et = em.getTransaction();
+ List<IntegrityAuditEntity> iaeList;
+ try (var em = emf.createEntityManager()) {
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
- et.begin();
+ et.begin();
- // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not
- // found, create a new entry
- Query iaequery = em
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not
+ // found, create a new entry
+ var iaequery = em
.createQuery("Select i from IntegrityAuditEntity i where i.persistenceUnit=:pu and i.nodeType=:nt");
- iaequery.setParameter("pu", persistenceUnit);
- iaequery.setParameter("nt", nodeType);
+ iaequery.setParameter("pu", persistenceUnit);
+ iaequery.setParameter("nt", nodeType);
- List<IntegrityAuditEntity> iaeList = iaequery.getResultList();
+ iaeList = iaequery.getResultList();
- // commit transaction
- et.commit();
- em.close();
+ // commit transaction
+ et.commit();
+ }
logger.debug("getIntegrityAuditEntities: Exit, iaeList=" + iaeList);
return iaeList;
} catch (Exception e) {
@@ -338,11 +313,11 @@ public class DbDao {
// refresh the object from DB in case cached data was returned
em.refresh(iae);
logger.info(RESOURCE_MESSAGE + this.resourceName + WITH_PERSISTENCE_MESSAGE + this.persistenceUnit
- + " exists");
+ + " exists");
} else {
// If it does not exist, log an error
logger.error("Attempting to setLastUpdated" + " on an entry that does not exist: resource "
- + this.resourceName + WITH_PERSISTENCE_MESSAGE + this.persistenceUnit);
+ + this.resourceName + WITH_PERSISTENCE_MESSAGE + this.persistenceUnit);
}
});
}
@@ -357,17 +332,18 @@ public class DbDao {
*/
public IntegrityAuditEntity getIntegrityAuditEntity(long id) throws DbDaoTransactionException {
try {
- EntityManager em = emf.createEntityManager();
+ IntegrityAuditEntity iae;
+ try (var em = emf.createEntityManager()) {
- // Start a transaction
- EntityTransaction et = em.getTransaction();
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
- et.begin();
+ et.begin();
- IntegrityAuditEntity iae = em.find(IntegrityAuditEntity.class, id);
+ iae = em.find(IntegrityAuditEntity.class, id);
- et.commit();
- em.close();
+ et.commit();
+ }
return iae;
} catch (Exception e) {
@@ -385,7 +361,7 @@ public class DbDao {
public Set<String> getPersistenceClassNames() {
logger.debug("DbDao: getPersistenceClassNames() entry");
HashSet<String> returnList = new HashSet<>();
- final Metamodel mm = emf.getMetamodel();
+ final var mm = emf.getMetamodel();
logger.debug("\n" + persistenceUnit + " persistence unit classes:");
for (final ManagedType<?> managedType : mm.getManagedTypes()) {
Class<?> clazz = managedType.getJavaType();
@@ -400,7 +376,7 @@ public class DbDao {
* Register the IntegrityAudit instance.
*
* @param altDbUrl alternate DB URL to be placed into the record, or {@code null} to use the
- * default
+ * default
*/
private void register(String altDbUrl) throws DbDaoTransactionException {
@@ -412,12 +388,12 @@ public class DbDao {
// refresh the object from DB in case cached data was returned
em.refresh(iae2);
logger.info(RESOURCE_MESSAGE + this.resourceName + WITH_PERSISTENCE_MESSAGE + this.persistenceUnit
- + " exists and entry be updated");
+ + " exists and entry be updated");
} else {
// If it does not exist, we also must add teh resourceName, persistenceUnit and
// designated values
logger.info("Adding resource " + resourceName + WITH_PERSISTENCE_MESSAGE + this.persistenceUnit
- + " to IntegrityAuditEntity table");
+ + " to IntegrityAuditEntity table");
iae2 = new IntegrityAuditEntity();
iae2.setResourceName(this.resourceName);
iae2.setPersistenceUnit(this.persistenceUnit);
@@ -450,15 +426,15 @@ public class DbDao {
/**
* Set designated.
*
- * @param resourceName the resource name
+ * @param resourceName the resource name
* @param persistenceUnit the persistence unit
- * @param desig true if is designated
+ * @param desig true if is designated
* @throws DbDaoTransactionException if an error occurs
*/
public void setDesignated(String resourceName, String persistenceUnit, boolean desig)
- throws DbDaoTransactionException {
+ throws DbDaoTransactionException {
logger.debug("setDesignated: enter, resourceName: " + resourceName + ", persistenceUnit: " + persistenceUnit
- + ", designated: " + desig);
+ + ", designated: " + desig);
updateIae("setDesignated", resourceName, persistenceUnit, (em, iae) -> {
@@ -466,7 +442,7 @@ public class DbDao {
// refresh the object from DB in case cached data was returned
em.refresh(iae);
logger.info(RESOURCE_MESSAGE + resourceName + WITH_PERSISTENCE_MESSAGE + persistenceUnit
- + " exists and designated be updated");
+ + " exists and designated be updated");
iae.setDesignated(desig);
em.persist(iae);
@@ -475,7 +451,7 @@ public class DbDao {
} else {
// If it does not exist, log an error
logger.error("Attempting to setDesignated(" + desig + ") on an entry that does not exist:"
- + " resource " + resourceName + WITH_PERSISTENCE_MESSAGE + persistenceUnit);
+ + " resource " + resourceName + WITH_PERSISTENCE_MESSAGE + persistenceUnit);
}
});
@@ -484,49 +460,49 @@ public class DbDao {
/**
* Queries for an audit entity and then updates it using an "updater" function.
*
- * @param methodName name of the method that invoked this
- * @param resourceName the resource name
+ * @param methodName name of the method that invoked this
+ * @param resourceName the resource name
* @param persistenceUnit the persistence unit
- * @param updater function to update the entity; the argument will be the entity to be
- * updated, or {@code null} if the entity is not found
+ * @param updater function to update the entity; the argument will be the entity to be
+ * updated, or {@code null} if the entity is not found
* @return the entity that was found, or {@code null} if the entity is not found
* @throws DbDaoTransactionException if an error occurs
*/
private IntegrityAuditEntity updateIae(String methodName, String resourceName, String persistenceUnit,
- BiConsumer<EntityManager, IntegrityAuditEntity> updater) throws DbDaoTransactionException {
+ BiConsumer<EntityManager, IntegrityAuditEntity> updater)
+ throws DbDaoTransactionException {
try {
- EntityManager em = emf.createEntityManager();
+ IntegrityAuditEntity iae;
+ try (var em = emf.createEntityManager()) {
- // Start a transaction
- EntityTransaction et = em.getTransaction();
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
- et.begin();
+ et.begin();
- // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not
- // found, create a new entry
- TypedQuery<IntegrityAuditEntity> iaequery = em.createQuery(SELECT_STRING, IntegrityAuditEntity.class);
- iaequery.setParameter("rn", resourceName);
- iaequery.setParameter("pu", persistenceUnit);
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not
+ // found, create a new entry
+ TypedQuery<IntegrityAuditEntity> iaequery = em.createQuery(SELECT_STRING, IntegrityAuditEntity.class);
+ iaequery.setParameter("rn", resourceName);
+ iaequery.setParameter("pu", persistenceUnit);
- List<IntegrityAuditEntity> iaeList = iaequery.getResultList();
- IntegrityAuditEntity iae;
+ List<IntegrityAuditEntity> iaeList = iaequery.getResultList();
- if (!iaeList.isEmpty()) {
- // ignores multiple results
- iae = iaeList.get(0);
+ if (!iaeList.isEmpty()) {
+ // ignores multiple results
+ iae = iaeList.get(0);
- } else {
- // If it does not exist
- iae = null;
- }
+ } else {
+ // If it does not exist
+ iae = null;
+ }
- updater.accept(em, iae);
+ updater.accept(em, iae);
- // close the transaction
- et.commit();
- // close the EntityManager
- em.close();
+ // close the transaction
+ et.commit();
+ }
return iae;
@@ -545,7 +521,7 @@ public class DbDao {
*/
public void setLastUpdated() throws DbDaoTransactionException {
logger.debug("setLastUpdated: enter, resourceName: " + this.resourceName + ", persistenceUnit: "
- + this.persistenceUnit);
+ + this.persistenceUnit);
updateIae("setLastUpdated", this.resourceName, this.persistenceUnit, (em, iae) -> {
@@ -553,7 +529,7 @@ public class DbDao {
// refresh the object from DB in case cached data was returned
em.refresh(iae);
logger.info(RESOURCE_MESSAGE + this.resourceName + WITH_PERSISTENCE_MESSAGE + this.persistenceUnit
- + " exists and lastUpdated be updated");
+ + " exists and lastUpdated be updated");
iae.setLastUpdated(AuditorTime.getInstance().getDate());
em.persist(iae);
@@ -562,7 +538,7 @@ public class DbDao {
} else {
// If it does not exist, log an error
logger.error("Attempting to setLastUpdated" + " on an entry that does not exist:" + " resource "
- + this.resourceName + WITH_PERSISTENCE_MESSAGE + this.persistenceUnit);
+ + this.resourceName + WITH_PERSISTENCE_MESSAGE + this.persistenceUnit);
}
});
}
@@ -577,26 +553,27 @@ public class DbDao {
if (!IntegrityAudit.isUnitTesting()) {
String msg = DBDAO_MESSAGE + "deleteAllIntegrityAuditEntities() "
- + "should only be invoked during JUnit testing";
+ + "should only be invoked during JUnit testing";
logger.error(msg);
throw new DbDaoTransactionException(msg);
}
- EntityManager em = emf.createEntityManager();
- // Start a transaction
- EntityTransaction et = em.getTransaction();
+ int returnCode;
+ try (var em = emf.createEntityManager()) {
+ // Start a transaction
+ EntityTransaction et = em.getTransaction();
- et.begin();
+ et.begin();
- // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not
- // found, create a new entry
- Query iaequery = em.createQuery("Delete from IntegrityAuditEntity");
+ // if IntegrityAuditEntity entry exists for resourceName and PU, update it. If not
+ // found, create a new entry
+ var iaequery = em.createQuery("Delete from IntegrityAuditEntity");
- int returnCode = iaequery.executeUpdate();
+ returnCode = iaequery.executeUpdate();
- // commit transaction
- et.commit();
- em.close();
+ // commit transaction
+ et.commit();
+ }
logger.info("deleteAllIntegrityAuditEntities: returnCode=" + returnCode);
@@ -622,69 +599,65 @@ public class DbDao {
* designations from interleaved changeDesignated() invocations from different resources
* (entities), because it prevents "dirty" and "non-repeatable" reads.
*
- * <p>See http://www.objectdb.com/api/java/jpa/LockModeType
+ * <p>See www.objectdb.com/api/java/jpa/LockModeType
*
* <p>and
*
- * <p>http://stackoverflow.com/questions/2120248/how-to-synchronize-a-static-
+ * <p>stackoverflow.com/questions/2120248/how-to-synchronize-a-static-
* variable-among-threads-running-different-instances-o
*/
public void changeDesignated(String resourceName, String persistenceUnit, String nodeType)
- throws DbDaoTransactionException {
+ throws DbDaoTransactionException {
if (logger.isDebugEnabled()) {
logger.debug("changeDesignated: Entering, resourceName=" + resourceName + ", persistenceUnit="
- + persistenceUnit + ", nodeType=" + nodeType);
+ + persistenceUnit + ", nodeType=" + nodeType);
}
long startTime = AuditorTime.getInstance().getMillis();
synchronized (lock) {
-
- EntityManager em = null;
- try {
-
- em = emf.createEntityManager();
- em.getTransaction().begin();
-
- /*
- * Define query
- */
- Query query = em.createQuery(
+ try (var em = emf.createEntityManager()) {
+ try {
+ em.getTransaction().begin();
+
+ /*
+ * Define query
+ */
+ var query = em.createQuery(
"Select i from IntegrityAuditEntity i where i.persistenceUnit=:pu and i.nodeType=:nt");
- query.setParameter("pu", persistenceUnit);
- query.setParameter("nt", nodeType);
-
- /*
- * Execute query using pessimistic write lock. This ensures that if anyone else is
- * currently reading the records we'll throw a LockTimeoutException.
- */
- setDesignatedEntity(resourceName, query);
-
- if (logger.isDebugEnabled()) {
- logger.debug("changeDesignated: Committing designation to resourceName=" + resourceName);
- }
- em.getTransaction().commit();
-
- /*
- * If we get a LockTimeoutException, no harm done really. We'll probably be
- * successful on the next attempt. The odds of another DbDao instance on this entity
- * or another entity attempting a simultaneous IntegrityAuditEntity table
- * read/update are pretty slim (we're only in this method for two or three
- * milliseconds)
- */
- } catch (Exception e) {
- if (em != null) {
- em.getTransaction().rollback();
-
- String msg = "DbDao: changeDesignated() caught Exception, message=" + e.getMessage();
- logger.error(msg + e);
- throw new DbDaoTransactionException(msg, e);
- } else {
- String msg = "DbDao: changeDesignated() caught Exception, message="
+ query.setParameter("pu", persistenceUnit);
+ query.setParameter("nt", nodeType);
+
+ /*
+ * Execute query using pessimistic write lock. This ensures that if anyone else is
+ * currently reading the records we'll throw a LockTimeoutException.
+ */
+ setDesignatedEntity(resourceName, query);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("changeDesignated: Committing designation to resourceName=" + resourceName);
+ }
+ em.getTransaction().commit();
+
+ /*
+ * If we get a LockTimeoutException, no harm done really. We'll probably be
+ * successful on the next attempt. The odds of another DbDao instance on this entity
+ * or another entity attempting a simultaneous IntegrityAuditEntity table
+ * read/update are pretty slim (we're only in this method for two or three
+ * milliseconds)
+ */
+ } catch (Exception e) {
+ String errorMsg;
+ try {
+ em.getTransaction().rollback();
+ errorMsg = "DbDao: changeDesignated() caught Exception, message=" + e.getMessage();
+ } catch (Exception rollbackException) {
+ errorMsg = "DbDao: changeDesignated() caught Exception, message="
+ e.getMessage() + ". Error rolling back transaction.";
- logger.error(msg + e);
- throw new DbDaoTransactionException(msg, e);
+ }
+ logger.error(errorMsg + e);
+ throw new DbDaoTransactionException(errorMsg, e);
}
}
@@ -692,32 +665,58 @@ public class DbDao {
if (logger.isDebugEnabled()) {
logger.debug("changeDesignated: Exiting; time expended="
- + (AuditorTime.getInstance().getMillis() - startTime) + "ms");
+ + (AuditorTime.getInstance().getMillis() - startTime) + "ms");
}
}
private void setDesignatedEntity(String resourceName, Query query) {
for (Object o : query.getResultList()) {
- if (!(o instanceof IntegrityAuditEntity)) {
+ if (!(o instanceof IntegrityAuditEntity integrityAuditEntity)) {
continue;
}
- IntegrityAuditEntity integrityAuditEntity = (IntegrityAuditEntity) o;
if (integrityAuditEntity.getResourceName().equals(resourceName)) {
if (logger.isDebugEnabled()) {
logger.debug("changeDesignated: Designating resourceName="
- + integrityAuditEntity.getResourceName());
+ + integrityAuditEntity.getResourceName());
}
integrityAuditEntity.setDesignated(true);
} else {
if (logger.isDebugEnabled()) {
logger.debug("changeDesignated: Removing designation from resourceName="
- + integrityAuditEntity.getResourceName());
+ + integrityAuditEntity.getResourceName());
}
integrityAuditEntity.setDesignated(false);
}
}
}
+ /**
+ * Collects all objects from a criteria builder based on className.
+ *
+ * @param className type of objects for resultMap
+ * @param emf the entity manager factory to be used
+ * @param em entity manager to be used
+ * @param resultMap the result map for objects queried
+ * @throws ClassNotFoundException if class for criteria builder doesn't exist
+ */
+ private void getObjectsFromCriteriaBuilder(String className, EntityManagerFactory emf, EntityManager em,
+ HashMap<Object, Object> resultMap)
+ throws ClassNotFoundException {
+ var cb = em.getCriteriaBuilder();
+ CriteriaQuery<Object> cq = cb.createQuery();
+ Root<?> rootEntry = cq.from(Class.forName(className));
+ CriteriaQuery<Object> all = cq.select(rootEntry);
+ TypedQuery<Object> allQuery = em.createQuery(all);
+ List<Object> objectList = allQuery.getResultList();
+ // Now create the map
+
+ var util = emf.getPersistenceUnitUtil();
+ for (Object o : objectList) {
+ Object key = util.getIdentifier(o);
+ resultMap.put(key, o);
+ }
+ }
+
}
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java
index 41aea118..66ab307c 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -21,6 +21,8 @@
package org.onap.policy.common.ia;
import java.util.Properties;
+import lombok.Getter;
+import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.onap.policy.common.ia.IntegrityAuditProperties.NodeTypeEnum;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
@@ -34,8 +36,12 @@ public class IntegrityAudit {
private static final Logger logger = FlexLogger.getLogger(IntegrityAudit.class);
- private static boolean isUnitTesting;
- private boolean isThreadInitialized = false;
+ @Getter
+ @Setter
+ private static boolean unitTesting;
+
+ @Getter
+ private boolean threadInitialized = false;
AuditThread auditThread = null;
@@ -54,6 +60,7 @@ public class IntegrityAudit {
* indicated period
*
*/
+ @Getter
private int integrityAuditPeriodSeconds;
/**
@@ -68,7 +75,7 @@ public class IntegrityAudit {
throws IntegrityAuditException {
logger.info("Constructor: Entering and checking for nulls");
- StringBuilder parmList = new StringBuilder();
+ var parmList = new StringBuilder();
if (parmsAreBad(resourceName, persistenceUnit, properties, parmList)) {
logger.error("Constructor: Parms contain nulls; cannot run audit for resourceName=" + resourceName
+ ", persistenceUnit=" + persistenceUnit + ", bad parameters: " + parmList);
@@ -94,13 +101,6 @@ public class IntegrityAudit {
}
/**
- * Used during JUnit testing by AuditPeriodTest.java
- */
- public int getIntegrityAuditPeriodSeconds() {
- return integrityAuditPeriodSeconds;
- }
-
- /**
* Determine if the nodeType conforms to the required node types.
*/
public static boolean isNodeTypeEnum(String nt) {
@@ -237,21 +237,9 @@ public class IntegrityAudit {
logger.info("stopAuditThread: Exiting");
}
- public boolean isThreadInitialized() {
- return isThreadInitialized;
- }
-
public void setThreadInitialized(boolean isThreadInitialized) {
logger.info("setThreadInitialized: Setting isThreadInitialized=" + isThreadInitialized);
- this.isThreadInitialized = isThreadInitialized;
- }
-
- public static boolean isUnitTesting() {
- return isUnitTesting;
- }
-
- public static void setUnitTesting(boolean isUnitTesting) {
- IntegrityAudit.isUnitTesting = isUnitTesting;
+ this.threadInitialized = isThreadInitialized;
}
/**
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java
index 365afd25..cd80f56f 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java
@@ -2,7 +2,8 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -20,14 +21,18 @@
package org.onap.policy.common.ia;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class IntegrityAuditProperties {
public static final int DEFAULT_AUDIT_PERIOD_SECONDS = -1; // Audit does not run
- public static final String DB_DRIVER = "javax.persistence.jdbc.driver";
- public static final String DB_URL = "javax.persistence.jdbc.url";
- public static final String DB_USER = "javax.persistence.jdbc.user";
- public static final String DB_PWD = "javax.persistence.jdbc.password"; //NOSONAR
+ public static final String DB_DRIVER = "jakarta.persistence.jdbc.driver";
+ public static final String DB_URL = "jakarta.persistence.jdbc.url";
+ public static final String DB_USER = "jakarta.persistence.jdbc.user";
+ public static final String DB_PWD = "jakarta.persistence.jdbc.password"; //NOSONAR
public static final String AUDIT_PERIOD_SECONDS = "integrity_audit_period_seconds";
@@ -38,9 +43,4 @@ public class IntegrityAuditProperties {
PDP_XACML, PDP_DROOLS, PAP, PAP_ADMIN, LOGPARSER, BRMS_GATEWAY, ASTRA_GATEWAY, ELK_SERVER, PYPDP
}
-
- private IntegrityAuditProperties() {
-
- }
-
}
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java
index 2b2b806a..64ec7fd0 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java
@@ -2,7 +2,8 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018, 2020-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.
@@ -20,41 +21,48 @@
package org.onap.policy.common.ia.jpa;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.GenerationType;
+import jakarta.persistence.Id;
+import jakarta.persistence.NamedQuery;
+import jakarta.persistence.PrePersist;
+import jakarta.persistence.PreUpdate;
+import jakarta.persistence.Table;
+import jakarta.persistence.Temporal;
+import jakarta.persistence.TemporalType;
import java.io.IOException;
import java.io.ObjectOutputStream;
+import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.PrePersist;
-import javax.persistence.PreUpdate;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-/*
- * The Entity class to for management of IntegrityAudits
- */
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import org.onap.policy.common.ia.AuditorTime;
@Entity
@Table(name = "IntegrityAuditEntity")
-@NamedQueries({@NamedQuery(name = " IntegrityAuditEntity.findAll", query = "SELECT e FROM IntegrityAuditEntity e "),
- @NamedQuery(name = "IntegrityAuditEntity.deleteAll",
- query = "DELETE FROM IntegrityAuditEntity WHERE 1=1")})
-
+@NamedQuery(name = " IntegrityAuditEntity.findAll", query = "SELECT e FROM IntegrityAuditEntity e ")
+@NamedQuery(name = "IntegrityAuditEntity.deleteAll", query = "DELETE FROM IntegrityAuditEntity WHERE 1=1")
+@NoArgsConstructor
+@Getter
+@Setter
public class IntegrityAuditEntity implements Serializable {
+
+ @Serial
private static final long serialVersionUID = 1L;
- private static boolean isUnitTesting;
+ @Getter
+ @Setter
+ private static boolean unitTesting;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
+ @Setter(AccessLevel.PRIVATE)
private long id;
@Column(name = "persistenceUnit", nullable = false)
@@ -92,17 +100,12 @@ public class IntegrityAuditEntity implements Serializable {
@Column(name = "lastUpdated")
private Date lastUpdated;
-
- public IntegrityAuditEntity() {
- // Empty constructor
- }
-
/**
* Pre persist.
*/
@PrePersist
public void prePersist() {
- Date date = AuditorTime.getInstance().getDate();
+ var date = AuditorTime.getInstance().getDate();
this.createdDate = date;
this.lastUpdated = date;
}
@@ -112,106 +115,6 @@ public class IntegrityAuditEntity implements Serializable {
this.lastUpdated = AuditorTime.getInstance().getDate();
}
- public long getId() {
- return id;
- }
-
- public String getPersistenceUnit() {
- return persistenceUnit;
- }
-
- public void setPersistenceUnit(String persistenceUnit) {
- this.persistenceUnit = persistenceUnit;
- }
-
- public String getSite() {
- return site;
- }
-
- public void setSite(String site) {
- this.site = site;
- }
-
- public String getNodeType() {
- return nodeType;
- }
-
- public void setNodeType(String nodeType) {
- this.nodeType = nodeType;
- }
-
- public String getResourceName() {
- return resourceName;
- }
-
- public void setResourceName(String resourceName) {
- this.resourceName = resourceName;
- }
-
- public boolean isDesignated() {
- return designated;
- }
-
- public void setDesignated(boolean designated) {
- this.designated = designated;
- }
-
- public String getJdbcDriver() {
- return jdbcDriver;
- }
-
- public void setJdbcDriver(String jdbcDriver) {
- this.jdbcDriver = jdbcDriver;
- }
-
- public String getJdbcUrl() {
- return jdbcUrl;
- }
-
- public void setJdbcUrl(String jdbcUrl) {
- this.jdbcUrl = jdbcUrl;
- }
-
- public String getJdbcUser() {
- return jdbcUser;
- }
-
- public void setJdbcUser(String jdbcUser) {
- this.jdbcUser = jdbcUser;
- }
-
- public String getJdbcPassword() {
- return jdbcPassword;
- }
-
- public void setJdbcPassword(String jdbcPassword) {
- this.jdbcPassword = jdbcPassword;
- }
-
- public Date getLastUpdated() {
- return lastUpdated;
- }
-
- public void setLastUpdated(Date lastUpdated) {
- this.lastUpdated = lastUpdated;
- }
-
- public Date getCreatedDate() {
- return createdDate;
- }
-
- public void setCreatedDate(Date created) {
- this.createdDate = created;
- }
-
- public static boolean isUnitTesting() {
- return isUnitTesting;
- }
-
- public static void setUnitTesting(boolean isUnitTesting) {
- IntegrityAuditEntity.isUnitTesting = isUnitTesting;
- }
-
private void writeObject(ObjectOutputStream out) throws IOException {
if (isUnitTesting()) {
/*
diff --git a/integrity-audit/src/main/resources/META-INF/persistence.xml b/integrity-audit/src/main/resources/META-INF/persistence.xml
index 33c701b1..63fea7b1 100644
--- a/integrity-audit/src/main/resources/META-INF/persistence.xml
+++ b/integrity-audit/src/main/resources/META-INF/persistence.xml
@@ -4,13 +4,14 @@
Integrity Audit
================================================================================
Copyright (C) 2017 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.
@@ -19,28 +20,28 @@
============LICENSE_END=========================================================
-->
-<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
- <persistence-unit name="testPU" transaction-type="RESOURCE_LOCAL">
- <!-- Limited use for generating the DB and schema files for iatest DB -
- uses eclipselink -->
- <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
- <class>org.onap.policy.common.ia.jpa.IntegrityAuditEntity</class>
- <class>org.onap.policy.common.ia.jpa.IaTestEntity</class>
- <shared-cache-mode>NONE</shared-cache-mode>
- <properties>
- <property name="javax.persistence.schema-generation.database.action"
- value="drop-and-create" />
- </properties>
- </persistence-unit>
+<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
+ <persistence-unit name="testPU" transaction-type="RESOURCE_LOCAL">
+ <!-- Limited use for generating the DB and schema files for iatest DB - uses hibernate -->
+ <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+ <class>org.onap.policy.common.ia.jpa.IntegrityAuditEntity</class>
+ <class>org.onap.policy.common.ia.jpa.IaTestEntity</class>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ <properties>
+ <property name="jakarta.persistence.schema-generation.database.action" value="create" />
+ <property name="hibernate.show_sql" value="false" />
+ </properties>
+ </persistence-unit>
- <persistence-unit name="integrityAuditPU"
- transaction-type="RESOURCE_LOCAL">
- <!-- For operational use -->
- <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
- <class>org.onap.policy.common.ia.jpa.IntegrityAuditEntity</class>
- <shared-cache-mode>NONE</shared-cache-mode>
- <properties>
- <!-- none -->
- </properties>
- </persistence-unit>
+ <persistence-unit name="integrityAuditPU" transaction-type="RESOURCE_LOCAL">
+ <!-- For operational use -->
+ <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+ <class>org.onap.policy.common.ia.jpa.IntegrityAuditEntity</class>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ <properties>
+ <property name="hibernate.show_sql" value="false" />
+ </properties>
+ </persistence-unit>
</persistence>
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java
index 4728fe84..c48ec0e3 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java
@@ -2,7 +2,8 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -24,11 +25,12 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import com.google.re2j.Pattern;
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.EntityManagerFactory;
+import jakarta.persistence.Persistence;
import java.util.List;
import java.util.Properties;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -51,6 +53,7 @@ public class DbAuditTest extends IntegrityAuditTestBase {
private static Logger logger = FlexLogger.getLogger(DbAuditTest.class);
+ private static final Pattern COMMA_PAT = Pattern.compile(",");
private static final String RESOURCE_NAME = "pdp1";
private EntityManagerFactory emf2;
@@ -238,7 +241,7 @@ public class DbAuditTest extends IntegrityAuditTestBase {
assertFalse(dbglog.getExtracted().isEmpty());
String mismatchIndex = dbglog.getExtracted().get(dbglog.getExtracted().size() - 1);
- int mismatchEntries = mismatchIndex.trim().split(",").length;
+ int mismatchEntries = COMMA_PAT.split(mismatchIndex.trim()).length;
logger.info("mismatchTest: mismatchIndex found: '" + mismatchIndex + "'" + " mismatachEntries = "
+ mismatchEntries);
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDaoTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDaoTest.java
index 79dfeb18..9f2103d7 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDaoTest.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDaoTest.java
@@ -3,6 +3,7 @@
* Integrity Audit
* ================================================================================
* Copyright (C) 2017-2020 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.
@@ -25,18 +26,18 @@ import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import jakarta.persistence.PersistenceUnitUtil;
+import jakarta.persistence.Query;
+import jakarta.persistence.TypedQuery;
+import jakarta.persistence.criteria.CriteriaBuilder;
+import jakarta.persistence.criteria.CriteriaQuery;
+import jakarta.persistence.criteria.Root;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import javax.persistence.PersistenceUnitUtil;
-import javax.persistence.Query;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Root;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -57,7 +58,7 @@ public class DbDaoTest extends IntegrityAuditTestBase {
private static final String SITE_B = "SiteB";
private static final String ENTITY_CLASS_NAME = "org.onap.policy.common.ia.jpa.IntegrityAuditEntity";
- private static String resourceName = "pdp0";
+ private static final String resourceName = "pdp0";
private DbDao dbDao;
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java
index 1866bba0..f5a32777 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java
@@ -2,7 +2,8 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019, 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.
@@ -25,6 +26,10 @@ import static org.junit.Assert.fail;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.EntityManagerFactory;
+import jakarta.persistence.EntityTransaction;
+import jakarta.persistence.Persistence;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
@@ -36,18 +41,14 @@ import java.util.Properties;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.EntityTransaction;
-import javax.persistence.Persistence;
import org.onap.policy.common.utils.jpa.EntityMgrCloser;
import org.onap.policy.common.utils.jpa.EntityMgrFactoryCloser;
import org.onap.policy.common.utils.jpa.EntityTransCloser;
import org.onap.policy.common.utils.test.log.logback.ExtractAppender;
import org.onap.policy.common.utils.time.CurrentTime;
import org.onap.policy.common.utils.time.TestTime;
-import org.powermock.reflect.Whitebox;
import org.slf4j.LoggerFactory;
+import org.springframework.test.util.ReflectionTestUtils;
/**
* All JUnits are designed to run in the local development environment where they have write
@@ -177,6 +178,7 @@ public class IntegrityAuditTestBase {
* @param dbUrl the URL to the DB
* @throws IOException if an IO error occurs
*/
+ @SuppressWarnings("unchecked")
protected static void setUpBeforeClass(String dbUrl) throws IOException {
// truncate the logs
@@ -188,7 +190,7 @@ public class IntegrityAuditTestBase {
IntegrityAuditTestBase.dbUrl = dbUrl;
// save data that we have to restore at the end of the test
- savedTime = Whitebox.getInternalState(AuditorTime.class, TIME_SUPPLY_FIELD);
+ savedTime = (Supplier<CurrentTime>) ReflectionTestUtils.getField(AuditorTime.class, TIME_SUPPLY_FIELD);
savedDebugLevel = debugLogger.getLevel();
savedErrorLevel = errorLogger.getLevel();
@@ -208,7 +210,7 @@ public class IntegrityAuditTestBase {
// done
em = emf.createEntityManager();
- Whitebox.setInternalState(AuditorTime.class, TIME_SUPPLY_FIELD, timeSupplier);
+ ReflectionTestUtils.setField(AuditorTime.class, TIME_SUPPLY_FIELD, timeSupplier);
debugLogger.setLevel(Level.DEBUG);
errorLogger.setLevel(Level.ERROR);
}
@@ -220,7 +222,7 @@ public class IntegrityAuditTestBase {
IntegrityAudit.setUnitTesting(false);
- Whitebox.setInternalState(AuditorTime.class, TIME_SUPPLY_FIELD, savedTime);
+ ReflectionTestUtils.setField(AuditorTime.class, TIME_SUPPLY_FIELD, savedTime);
debugLogger.setLevel(savedDebugLevel);
errorLogger.setLevel(savedErrorLevel);
@@ -243,7 +245,7 @@ public class IntegrityAuditTestBase {
// Clean up the DB
try (EntityTransCloser etc = new EntityTransCloser(em.getTransaction())) {
- EntityTransaction et = etc.getTransation();
+ EntityTransaction et = etc.getTransaction();
em.createQuery("Delete from IntegrityAuditEntity").executeUpdate();
@@ -290,7 +292,7 @@ public class IntegrityAuditTestBase {
EntityTransCloser etc = new EntityTransCloser(emc.getManager().getTransaction())) {
EntityManager entmgr = emc.getManager();
- EntityTransaction entrans = etc.getTransation();
+ EntityTransaction entrans = etc.getTransaction();
// Clean up the DB
entmgr.createQuery("Delete from " + tableName).executeUpdate();
@@ -304,8 +306,7 @@ public class IntegrityAuditTestBase {
* Verifies that items appear within the log, in order. A given item may appear more than once.
* In addition, the log may contain extra items; those are ignored.
*
- * @param textre regular expression used to extract an item from a line in the log. The first
- * "capture" group of the regular expression is assumed to contain the extracted item
+ * @param app where data has been logged
* @param items items that should be matched by the items extracted from the log, in order
* @throws IOException if an IO error occurs
* @throws AssertionError if the desired items were not all found
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java
index 2ca83050..8a34909a 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java
@@ -3,6 +3,7 @@
* Integrity Audit
* ================================================================================
* Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021, 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.
@@ -20,25 +21,25 @@
package org.onap.policy.common.ia.jpa;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.GenerationType;
+import jakarta.persistence.Id;
+import jakarta.persistence.NamedQueries;
+import jakarta.persistence.NamedQuery;
+import jakarta.persistence.PrePersist;
+import jakarta.persistence.PreUpdate;
+import jakarta.persistence.Table;
+import jakarta.persistence.Temporal;
+import jakarta.persistence.TemporalType;
import java.io.Serializable;
import java.util.Date;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.PrePersist;
-import javax.persistence.PreUpdate;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
@Entity
@Table(name = "IaTestEntity")
@NamedQueries({@NamedQuery(name = " IaTestEntity.findAll", query = "SELECT e FROM IaTestEntity e "),
- @NamedQuery(name = "IaTestEntity.deleteAll", query = "DELETE FROM IaTestEntity WHERE 1=1")})
+ @NamedQuery(name = "IaTestEntity.deleteAll", query = "DELETE FROM IaTestEntity WHERE 1=1")})
public class IaTestEntity implements Serializable {
private static final long serialVersionUID = 1L;