Package org.dspace.storage.rdbms
Class PostgresUtils
java.lang.Object
org.dspace.storage.rdbms.PostgresUtils
Database utility class specific to Postgres.
This class contains tools and methods which are useful in determining
the status of a PostgreSQL database backend. It's a companion class
to DatabaseUtils, but PostgreSQL specific.
- Author:
- Tim Donohue
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionprotected static booleancheckCleanPermissions(Connection connection) Check if the current user has permissions to run a clean on existing database.protected static DoublegetPgcryptoAvailableVersion(Connection connection) Get version of pgcrypto extension available.protected static DoublegetPgcryptoInstalledVersion(Connection connection) Get version of pgcrypto extension installed in the DSpace database.static booleanisPgcryptoInSchema(String schema) Check if the pgcrypto extension is installed into a particular schemastatic booleanCheck if the pgcrypto extension is BOTH installed AND up-to-date.
-
Field Details
-
PGCRYPTO
- See Also:
-
PGCRYPTO_VERSION
-
POSTGRES_VERSION
-
-
Method Details
-
getPgcryptoAvailableVersion
Get version of pgcrypto extension available. The extension is "available" if it's been installed via operating system tools/packages. It also MUST be installed in the DSpace database (see getPgcryptoInstalled()).The pgcrypto extension is required for Postgres databases
- Parameters:
connection- database connection- Returns:
- version number or null if not available
-
getPgcryptoInstalledVersion
Get version of pgcrypto extension installed in the DSpace database.The pgcrypto extension is required for Postgres databases to support UUIDs.
- Parameters:
connection- database connection- Returns:
- version number or null if not installed
-
isPgcryptoUpToDate
public static boolean isPgcryptoUpToDate()Check if the pgcrypto extension is BOTH installed AND up-to-date.This requirement is only needed for PostgreSQL databases. It doesn't matter what schema pgcrypto is installed in, as long as it exists.
- Returns:
- true if everything is installed and up-to-date. False otherwise.
-
isPgcryptoInSchema
Check if the pgcrypto extension is installed into a particular schemaThis allows us to check if pgcrypto needs to be REMOVED prior to running a 'clean' on this database. If pgcrypto is in the same schema as the dspace database, a 'clean' will require removing pgcrypto FIRST.
- Parameters:
schema- name of schema- Returns:
- true if pgcrypto is in this schema. False otherwise.
-
checkCleanPermissions
Check if the current user has permissions to run a clean on existing database.Mostly this just checks if you need to remove pgcrypto, and if so, whether you have permissions to do so.
- Parameters:
connection- database connection- Returns:
- true if permissions valid, false otherwise
-