cmu.jspsurveymanager.data
Class DatabaseObjectStorage

java.lang.Object
  extended by cmu.jspsurveymanager.data.DatabaseObjectStorage

public class DatabaseObjectStorage
extends java.lang.Object


Field Summary
static short PERMISSION_ALL
           
 
Constructor Summary
DatabaseObjectStorage()
          You must call connect() after this to connect before doing anything.
 
Method Summary
 void close()
          Closes the database connection to free resources.
 boolean connect(WebappConfiguration webappConfiguration)
           
 boolean createDatabase(java.lang.String databaseName)
           
 void createDatabaseUser(java.lang.String username, java.lang.String password)
           
 boolean deleteDatabase(java.lang.String databaseName)
           
 void deleteDatabaseUser(java.lang.String username)
           
 boolean doesDatabaseExist(java.lang.String databaseName)
           
 java.util.List getActiveUsers(java.lang.String db)
          Returns the list of users currently wokring with the given database, db.
 AdminStorage getAdminStorage()
           
 HasKeyValues getConnectionKeyValues(java.lang.String serverDomainName, java.lang.String databaseName, java.lang.String username, java.lang.String password)
           
 java.lang.String getConnectionString(java.lang.String serverDomainName, java.lang.String databaseName, java.lang.String user, java.lang.String password)
           
 java.lang.String getDatabaseProgramName()
          Returns the name of this database program.
 java.lang.String getHelpURL()
          Returns a URL with help about installing, starting, and stopping this database program.
 java.lang.String getSurveysDir()
          Directory that new surveys should be copied into, ending with a slash.
 SurveyStorage getSurveyStorage()
           
 java.lang.String getSystemLoginMessage()
          Announcement messages for the login page.
 java.lang.String getSystemMOTD()
          Announcement messages for the home page.
 java.lang.String getTomcatDirectory()
           
 TomcatManagerConnection getTomcatManagerConnection(java.lang.String possibleTomcatPath)
           
 boolean initializeSurveyDatabase(java.lang.String databaseName)
           
 java.lang.String isLabelValid(java.lang.String labelString)
          If it's a valid string for a name of a database, it returns null.
 void renameDatabaseUser(java.lang.String username, java.lang.String newUsername)
           
 boolean revokeDatabasePermissions(java.lang.String title, java.lang.String user, short permLevel)
          Revoke database-level permissions (if applicable) for a user.
 boolean setDatabasePermissions(java.lang.String title, java.lang.String user, short permLevel)
          Sets database-level permissions (if applicable) for a user.
 void setTomcatDirectory(java.lang.String newTomcatDirectory)
           
 void updateDatabaseUser(java.lang.String username, java.lang.String password)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PERMISSION_ALL

public static final short PERMISSION_ALL
See Also:
Constant Field Values
Constructor Detail

DatabaseObjectStorage

public DatabaseObjectStorage()
You must call connect() after this to connect before doing anything. Note: uses org.browsecode.helpers.Translator for sending error messages, so you need to make sure your application creates and registers one before using it.

Method Detail

connect

public boolean connect(WebappConfiguration webappConfiguration)

close

public void close()
Closes the database connection to free resources.


getDatabaseProgramName

public java.lang.String getDatabaseProgramName()
Returns the name of this database program.

Returns:

getHelpURL

public java.lang.String getHelpURL()
Returns a URL with help about installing, starting, and stopping this database program.

Returns:

getSystemLoginMessage

public java.lang.String getSystemLoginMessage()
Announcement messages for the login page.

Returns:

getSystemMOTD

public java.lang.String getSystemMOTD()
Announcement messages for the home page.

Returns:

getSurveysDir

public java.lang.String getSurveysDir()
Directory that new surveys should be copied into, ending with a slash. (e.g. "../", which is the default).

Returns:

getTomcatDirectory

public java.lang.String getTomcatDirectory()

setTomcatDirectory

public void setTomcatDirectory(java.lang.String newTomcatDirectory)

getTomcatManagerConnection

public TomcatManagerConnection getTomcatManagerConnection(java.lang.String possibleTomcatPath)
                                                   throws java.lang.Exception
Throws:
java.lang.Exception

doesDatabaseExist

public boolean doesDatabaseExist(java.lang.String databaseName)

createDatabase

public boolean createDatabase(java.lang.String databaseName)

deleteDatabase

public boolean deleteDatabase(java.lang.String databaseName)

getConnectionString

public java.lang.String getConnectionString(java.lang.String serverDomainName,
                                            java.lang.String databaseName,
                                            java.lang.String user,
                                            java.lang.String password)

getConnectionKeyValues

public HasKeyValues getConnectionKeyValues(java.lang.String serverDomainName,
                                           java.lang.String databaseName,
                                           java.lang.String username,
                                           java.lang.String password)

initializeSurveyDatabase

public boolean initializeSurveyDatabase(java.lang.String databaseName)

isLabelValid

public java.lang.String isLabelValid(java.lang.String labelString)
If it's a valid string for a name of a database, it returns null. If it's invalid, it returns the reason why it's not valid as a String. Call this before createDatabase().

Parameters:
labelString -
Returns:

getAdminStorage

public AdminStorage getAdminStorage()

getSurveyStorage

public SurveyStorage getSurveyStorage()

setDatabasePermissions

public boolean setDatabasePermissions(java.lang.String title,
                                      java.lang.String user,
                                      short permLevel)
                               throws java.lang.IllegalArgumentException
Sets database-level permissions (if applicable) for a user.

Parameters:
title - The name of the database.
you - The Admin to configure permissions for.
permLevel - The permission level to provide (see constants).
Throws:
java.lang.IllegalArgumentException

revokeDatabasePermissions

public boolean revokeDatabasePermissions(java.lang.String title,
                                         java.lang.String user,
                                         short permLevel)
                                  throws java.lang.IllegalArgumentException
Revoke database-level permissions (if applicable) for a user.

Parameters:
title - The name of the database.
you - The Admin to configure permissions for.
permLevel - The permission level to revoke (see constants).
Throws:
java.lang.IllegalArgumentException

createDatabaseUser

public void createDatabaseUser(java.lang.String username,
                               java.lang.String password)
Parameters:
username -
password -

updateDatabaseUser

public void updateDatabaseUser(java.lang.String username,
                               java.lang.String password)
Parameters:
username -
password -

renameDatabaseUser

public void renameDatabaseUser(java.lang.String username,
                               java.lang.String newUsername)

deleteDatabaseUser

public void deleteDatabaseUser(java.lang.String username)
Parameters:
username -

getActiveUsers

public java.util.List getActiveUsers(java.lang.String db)
Returns the list of users currently wokring with the given database, db. If db is null, returns all users.

Parameters:
the - database in question, or null