Class PostgresUtils

java.lang.Object
org.dspace.storage.rdbms.PostgresUtils

public class PostgresUtils extends Object
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 Details

    • PGCRYPTO

      public static final String PGCRYPTO
      See Also:
    • PGCRYPTO_VERSION

      public static final Double PGCRYPTO_VERSION
    • POSTGRES_VERSION

      public static final Double POSTGRES_VERSION
  • Method Details

    • getPgcryptoAvailableVersion

      protected static Double getPgcryptoAvailableVersion(Connection connection)
      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

      protected static Double getPgcryptoInstalledVersion(Connection connection)
      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

      public static boolean isPgcryptoInSchema(String schema)
      Check if the pgcrypto extension is installed into a particular schema

      This 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

      protected static boolean checkCleanPermissions(Connection connection)
      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