public class DBAdmin extends MetacatAdmin
Modifier and Type | Field and Description |
---|---|
static int |
DB_DOES_NOT_EXIST |
static int |
TABLES_DO_NOT_EXIST |
static int |
TABLES_EXIST |
static int |
VERSION_ACTIVE |
static int |
VERSION_INACTIVE |
Modifier and Type | Method and Description |
---|---|
void |
configureDatabase(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Handle configuration of the database the first time that Metacat starts
or when it is explicitly called.
|
int |
getDBStatus()
Performs a status check on the database.
|
DBVersion |
getDBVersion()
Get the version of the database as a string
|
static DBAdmin |
getInstance()
Get the single instance of DBAdmin.
|
DBVersion |
getUnRegisteredDBVersion()
Finds the version of the database for a database that does not have a
dbVersion table yet.
|
java.util.Vector<java.lang.String> |
getUpdateClasses() |
java.util.Vector<java.lang.String> |
getUpdateScripts()
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).
|
java.util.Vector<java.lang.String> |
loadSQLFromFile(java.lang.String sqlFileName)
Very basic utility to read sql from a file and return a vector of the
individual sql statements.
|
void |
runSQLFile(java.lang.String sqlFileName)
Runs the commands in a sql script.
|
void |
updateDBVersion()
Updates the version of the database.
|
void |
upgradeDatabase()
Iterates through the list of scripts that need to be run to upgrade
the database and calls runSQLFile on each.
|
java.lang.String |
validateDBConnectivity(java.lang.String dbDriver,
java.lang.String connection,
java.lang.String user,
java.lang.String password)
Validate connectivity to the database.
|
protected java.util.Vector<java.lang.String> |
validateOptions(javax.servlet.http.HttpServletRequest request)
Validate the most important configuration options submitted by the user.
|
public static final int DB_DOES_NOT_EXIST
public static final int TABLES_DO_NOT_EXIST
public static final int TABLES_EXIST
public static final int VERSION_INACTIVE
public static final int VERSION_ACTIVE
public static DBAdmin getInstance() throws AdminException
AdminException
public void configureDatabase(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws AdminException
request
- the http request informationresponse
- the http response to be sent back to the clientAdminException
public int getDBStatus() throws java.sql.SQLException, edu.ucsb.nceas.utilities.PropertyNotFoundException
java.sql.SQLException
edu.ucsb.nceas.utilities.PropertyNotFoundException
public DBVersion getDBVersion() throws AdminException
AdminException
public DBVersion getUnRegisteredDBVersion() throws AdminException, java.sql.SQLException
AdminException
java.sql.SQLException
public void updateDBVersion() throws java.sql.SQLException
java.sql.SQLException
public java.lang.String validateDBConnectivity(java.lang.String dbDriver, java.lang.String connection, java.lang.String user, java.lang.String password)
dbDriver
- the database driverconnection
- the jdbc connection stringuser
- the user namepassword
- the login passwordpublic java.util.Vector<java.lang.String> getUpdateScripts() throws AdminException
AdminException
public java.util.Vector<java.lang.String> getUpdateClasses() throws AdminException
AdminException
public void upgradeDatabase() throws AdminException
AdminException
public void runSQLFile(java.lang.String sqlFileName) throws AdminException, java.sql.SQLException
sqlFileName
- the name of the file holding the sql statements that need to
get run.AdminException
java.sql.SQLException
public java.util.Vector<java.lang.String> loadSQLFromFile(java.lang.String sqlFileName) throws java.io.IOException
sqlFileName
- the name of the file to read.java.io.IOException
protected java.util.Vector<java.lang.String> validateOptions(javax.servlet.http.HttpServletRequest request)
validateOptions
in class MetacatAdmin
Copyright © 2020 Regents of the University of California. All Rights Reserved.