Class DBAdmin

java.lang.Object
edu.ucsb.nceas.metacat.admin.MetacatAdmin
edu.ucsb.nceas.metacat.admin.DBAdmin

public class DBAdmin extends MetacatAdmin
Control the display of the database configuration page and the processing of the configuration values.
  • Field Details

  • Method Details

    • getInstance

      public static DBAdmin getInstance() throws AdminException
      Get the single instance of DBAdmin.
      Returns:
      the single instance of DBAdmin
      Throws:
      AdminException
    • configureDatabase

      public void configureDatabase(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws AdminException
      Handle configuration of the database the first time that Metacat starts or when it is explicitly called. Collect necessary update information from the administrator.
      Parameters:
      request - the http request information
      response - the http response to be sent back to the client
      Throws:
      AdminException
    • getDBStatus

      public static int getDBStatus() throws SQLException, edu.ucsb.nceas.utilities.PropertyNotFoundException
      Performs a status check on the database.
      Throws:
      SQLException
      edu.ucsb.nceas.utilities.PropertyNotFoundException
    • getDBVersion

      public DBVersion getDBVersion() throws AdminException
      Get the version of the database as a string
      Throws:
      AdminException
    • getUnRegisteredDBVersion

      public DBVersion getUnRegisteredDBVersion() throws AdminException, SQLException
      Finds the version of the database for a database that does not have a dbVersion table yet. Work backwards with various clues found in update scripts to find the version.
      Throws:
      AdminException
      SQLException
    • validateDBConnectivity

      public String validateDBConnectivity(String dbDriver, String connection, String user, String password)
      Validate connectivity to the database. Validation methods return a string error message if there is an issue. This allows the calling code to run several validations and compile the errors into a list that can be displayed on a web page if desired.
      Parameters:
      dbDriver - the database driver
      connection - the jdbc connection string
      user - the user name
      password - the login password
      Returns:
      a string holding error message if validation fails.
    • getUpdateScripts

      public Vector<String> getUpdateScripts() throws AdminException
      Creates a list of database update script names by looking at the database version and the metacat version and then getting any script that is inbetween the two (inclusive of metacat version).
      Throws:
      AdminException
    • getUpdateClasses

      public Vector<String> getUpdateClasses() throws AdminException
      Get the list of the Java and Solr update class files which will run in the upgrade process
      Returns:
      the list of Java class files
      Throws:
      AdminException
    • upgradeDatabase

      public void upgradeDatabase() throws AdminException
      Iterates through the list of scripts that need to be run to upgrade the database and calls runSQLFile on each.
      Throws:
      AdminException
    • runSQLFile

      public void runSQLFile(String sqlFileName) throws AdminException, SQLException
      Runs the commands in a sql script. Individual commands are loaded into a string vector and run one at a time.
      Parameters:
      sqlFileName - the name of the file holding the sql statements that need to get run.
      Throws:
      AdminException
      SQLException
    • loadSQLFromFile

      public Vector<String> loadSQLFromFile(String sqlFileName) throws IOException
      Very basic utility to read sql from a file and return a vector of the individual sql statements. This ignores any line that starts with /* or *. It strips anything following --. Sql is parsed by looking for lines that start with one of the following identifiers: INSERT, UPDATE, ALTER, CREATE, DROP, BEGIN and COMMIT. It then assumes that everything until the line that ends with ; is part of the sql, excluding comments.
      Parameters:
      sqlFileName - the name of the file to read.
      Returns:
      a vector holding the individual sql statements.
      Throws:
      IOException
    • validateOptions

      protected Vector<String> validateOptions(javax.servlet.http.HttpServletRequest request)
      Validate the most important configuration options submitted by the user.
      Specified by:
      validateOptions in class MetacatAdmin
      Returns:
      a vector holding error message for any fields that fail validation.