Package edu.wisc.library.ocfl.core.db
Class BaseObjectDetailsDatabase
- java.lang.Object
-
- edu.wisc.library.ocfl.core.db.BaseObjectDetailsDatabase
-
- All Implemented Interfaces:
ObjectDetailsDatabase
- Direct Known Subclasses:
H2ObjectDetailsDatabase,PostgresObjectDetailsDatabase
public abstract class BaseObjectDetailsDatabase extends Object implements ObjectDetailsDatabase
-
-
Constructor Summary
Constructors Constructor Description BaseObjectDetailsDatabase(DataSource dataSource, boolean storeInventory, long waitTime, TimeUnit timeUnit, String lockFailCode, String duplicateKeyCode)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddObjectDetails(Inventory inventory, String inventoryDigest, byte[] inventoryBytes)Adds ObjectDetails to the database.voiddeleteObjectDetails(String objectId)Removes ObjectDetails from the database.OcflObjectDetailsretrieveObjectDetails(String objectId)Retrieves ObjectDetails from the database.protected abstract voidsetLockWaitTimeout(Connection connection, long waitMillis)Sets the amount of time to wait for a row lock before timing out.voidupdateObjectDetails(Inventory inventory, String inventoryDigest, Path inventoryFile, Runnable runnable)Updates existing ObjectDetails in the database.
-
-
-
Constructor Detail
-
BaseObjectDetailsDatabase
public BaseObjectDetailsDatabase(DataSource dataSource, boolean storeInventory, long waitTime, TimeUnit timeUnit, String lockFailCode, String duplicateKeyCode)
-
-
Method Detail
-
setLockWaitTimeout
protected abstract void setLockWaitTimeout(Connection connection, long waitMillis) throws SQLException
Sets the amount of time to wait for a row lock before timing out.- Parameters:
connection- db connectionwaitMillis- time to wait for the lock in millis- Throws:
SQLException- on sql error
-
retrieveObjectDetails
public OcflObjectDetails retrieveObjectDetails(String objectId)
Retrieves ObjectDetails from the database. If no details can be found, null is returned.- Specified by:
retrieveObjectDetailsin interfaceObjectDetailsDatabase- Parameters:
objectId- the OCFL object id- Returns:
- ObjectDetails or null
-
addObjectDetails
public void addObjectDetails(Inventory inventory, String inventoryDigest, byte[] inventoryBytes)
Adds ObjectDetails to the database. In the case of a concurrent update, this operation will only fail if the inventory digests are different.- Specified by:
addObjectDetailsin interfaceObjectDetailsDatabase- Parameters:
inventory- the object's inventoryinventoryDigest- the digest of the inventoryinventoryBytes- the serialized inventory bytes
-
updateObjectDetails
public void updateObjectDetails(Inventory inventory, String inventoryDigest, Path inventoryFile, Runnable runnable)
Updates existing ObjectDetails in the database. The update is executed within a transaction. Before the transaction is committed, the supplied runnable is executed. The transaction is only committed if the runnable completes without exception.- Specified by:
updateObjectDetailsin interfaceObjectDetailsDatabase- Parameters:
inventory- the object's inventoryinventoryDigest- the digest of the inventoryinventoryFile- the path to the inventory on diskrunnable- the code to execute within the update transaction
-
deleteObjectDetails
public void deleteObjectDetails(String objectId)
Removes ObjectDetails from the database.- Specified by:
deleteObjectDetailsin interfaceObjectDetailsDatabase- Parameters:
objectId- the OCFL object id
-
-