Skip to content

Commit

Permalink
Introduce major refactor of openidm-repo-jdbc module
Browse files Browse the repository at this point in the history
This commit adds new implementation of many openidm-repo-jdbc
components. Most components ertr written from scratch with only
a few pieces directly taken from the original code. The overall
module logic stays the same and the overall comoponent structure
as well.

To make sure the DB integration works and the refactor does not
introduce any inconsistency a testcontainer integration tests
are added. These tests can be run on the legacy components as well
as the new components. This commit intentionally leaves both
implementations so that it is possible to return to this state and
recheck legacy behavior.
  • Loading branch information
pavelhoral committed Feb 2, 2024
1 parent c84d0e5 commit 456fdbd
Show file tree
Hide file tree
Showing 87 changed files with 6,462 additions and 377 deletions.
114 changes: 109 additions & 5 deletions openidm-repo-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<openidm.osgi.import.before.defaults>
!org.testng.annotations,!sun.misc,!org.w3c.dom,javax.inject;resolution:=optional
</openidm.osgi.import.before.defaults>
<testcontainers.version>1.19.3</testcontainers.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -106,9 +107,9 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>14.0.1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
Expand All @@ -123,6 +124,81 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>db2</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>jcc</artifactId>
<version>11.5.9.0</version>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mssqlserver</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>12.4.2.jre11</version>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>oracle-xe</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11</artifactId>
<version>21.9.0.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.3.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
Expand All @@ -138,14 +214,14 @@
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.2.9</version>
<version>2.7.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version>
<groupId>org.hsqldb</groupId>
<artifactId>sqltool</artifactId>
<version>2.7.2</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -216,6 +292,34 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>run-its</id>

<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>

<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,39 @@
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2016 ForgeRock AS.
* Portions Copyright 2024 Wren Security.
*/

package org.forgerock.openidm.repo.jdbc;

/**
*
* JDBC Repository Service Constants
* JDBC Repository Service constants.
*/
public class Constants {

/**
* Raw Object Rev
*
* The DB Table column representing the Object revision
* DB Table column representing the Object revision.
*/
public static final String RAW_OBJECT_REV = "rev";

/**
* Raw Id
*
* The ID of the row representing the Object within the DB Table
* ID of the row representing the Object within the DB Table.
*/
public static final String RAW_ID = "id";

/**
* Raw Object Type Id
*
* The ObjectTypes ID of the Object within the DB Table
*/
* ObjectTypes ID of the Object within the DB Table.
*/
public static final String RAW_OBJECTTYPES_ID = "objecttypes_id";

/**
* The Object Id
*
* The ID of the Mapped Object
*/
* ID of the Mapped Object.
*/
public static final String OBJECT_ID = "_id";

/**
* The Object Revision
*
* The Revision of the Mapped Object
*/
* Revision of the Mapped Object
*/
public static final String OBJECT_REV = "_rev";


}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
package org.forgerock.openidm.repo.jdbc;

/**
* @version $Revision$ $Date$
* Supported database types.
*/
public enum DatabaseType {
SQLSERVER, MYSQL, POSTGRESQL, ORACLE, DB2, H2, ANSI_SQL99, ODBC;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
package org.forgerock.openidm.repo.jdbc;

/**
* Portable error type identifiers
* Portable error type identifiers.
*/
public enum ErrorType {
CONNECTION_FAILURE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright © 2011 ForgeRock AS. All rights reserved.
* Portions Copyright 2024 Wren Security.
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
Expand All @@ -27,27 +28,29 @@
import java.sql.SQLException;

/**
* Interface to help handle SQLExceptions across different DB implementations
*
* Interface to help handle SQLExceptions across different DB implementations.
*/
public interface SQLExceptionHandler {

/**
* Query if a given exception signifies a well known error type
*
* Query if a given exception signifies a well known error type.
*
* <p>
* Allows table handlers to abstract database specific differences in reporting errors.
*
* @param ex The exception thrown by the database
*
* @param exception the exception thrown by the database
* @param errorType the error type to test against
* @return true if the exception matches the error type passed
*/
boolean isErrorType(SQLException ex, ErrorType errorType);
boolean isErrorType(SQLException exception, ErrorType errorType);

/**
* As whether a given exception should be retried
* @param ex the exception thrown by the database
* As whether a given exception should be retried.
*
* @param exception the exception thrown by the database
* @param connection where the failure occured, used for additional context
* @return true if the expectation is that transaction should be retried by the application
*/
boolean isRetryable(SQLException ex, Connection connection);
boolean isRetryable(SQLException exception, Connection connection);

}
Loading

0 comments on commit 456fdbd

Please sign in to comment.