com.sun.slamd.db
Class SLAMDDB

java.lang.Object
  extended bycom.sun.slamd.db.SLAMDDB

public class SLAMDDB
extends java.lang.Object

This class provides the main interface to the SLAMD database used for storing user accounts, configuration information, and job data.


Constructor Summary
SLAMDDB(java.lang.String dbDirectory, boolean readOnly, boolean createIfNecessary)
          Initializes the SLAMD database and opens the environment, creating a new one if necessary.
 
Method Summary
 void closeDatabases(boolean abortTransactions)
          Closes all databases in the environment.
 void closeEnvironment()
          Closes the database environment.
 java.lang.String getConfigParameter(java.lang.String parameterName)
          Retrieves the value of the specified configuration parameter from the configuration database.
 boolean getConfigParameter(java.lang.String parameterName, boolean defaultValue)
          Retrieves the value of the specified configuration parameter from the configuration database.
 int getConfigParameter(java.lang.String parameterName, int defaultValue)
          Retrieves the value of the specified configuration parameter from the configuration database.
 java.lang.String getConfigParameter(java.lang.String parameterName, java.lang.String defaultValue)
          Retrieves the value of the specified configuration parameter from the configuration database.
 JobFolder getFolder(java.lang.String folderName)
          Retrieves the specified folder from the configuration database.
 JobFolder[] getFolders()
          Retrieves a list of all job folders defined in the configuration database.
 Job getJob(SLAMDServer slamdServer, java.lang.String jobID)
          Retrieves the specified job from the configuration database.
 Job[] getJobs(SLAMDServer slamdServer, java.lang.String folderName)
          Retrieves the set of jobs contained in the specified folder of the configuration database.
 OptimizingJob getOptimizingJob(SLAMDServer slamdServer, java.lang.String optimizingJobID)
          Retrieves the specified optimizing job from the configuration database.
 OptimizingJob[] getOptimizingJobs(SLAMDServer slamdServer, java.lang.String folderName)
          Retrieves the set of optimizing jobs contained in the specified folder of the configuration database.
 Job getSummaryJob(SLAMDServer slamdServer, java.lang.String jobID)
          Retrieves summary information for the specified job from the configuration database.
 Job[] getSummaryJobs(SLAMDServer slamdServer, java.lang.String folderName)
          Retrieves summary information for the set of jobs contained in the specified folder of the configuration database.
 OptimizingJob getSummaryOptimizingJob(SLAMDServer slamdServer, java.lang.String optimizingJobID)
          Retrieves summary information for the specified optimizing job from the configuration database.
 OptimizingJob[] getSummaryOptimizingJobs(SLAMDServer slamdServer, java.lang.String folderName)
          Retrieves summary information for the set of optimizing jobs contained in the specified folder of the configuration database.
 UploadedFile getUploadedFile(java.lang.String folderName, java.lang.String fileName)
          Retrieves the specified uploaded file from the configuration database.
 UploadedFile[] getUploadedFiles(java.lang.String folderName)
          Retrieves the set of uploaded files associated with the specified folder.
 UploadedFile getUploadedFileWithoutData(java.lang.String folderName, java.lang.String fileName)
          Retrieves the specified uploaded file from the configuration database.
 void moveJob(SLAMDServer slamdServer, java.lang.String jobID, java.lang.String folderName)
          Moves the specified job from its current folder to the new folder.
 void moveOptimizingJob(SLAMDServer slamdServer, java.lang.String optimizingJobID, java.lang.String folderName)
          Moves the specified optimizing job from its current folder to the new folder.
 void openDatabases(boolean createIfNecessary)
          Opens all the databases used in the SLAMD database environment.
 void putConfigParameter(java.lang.String parameterName, boolean parameterValue)
          Sets the value of the specified parameter in the configuration database.
 void putConfigParameter(java.lang.String parameterName, int parameterValue)
          Sets the value of the specified parameter in the configuration database.
 void putConfigParameter(java.lang.String parameterName, java.lang.String parameterValue)
          Sets the value of the specified parameter in the configuration database.
 void removeConfigParameter(java.lang.String parameterName)
          Removes information about the specified parameter from the configuration database.
 void removeFolder(java.lang.String folderName)
          Removes information about the specified job folder from the configuration database.
 void removeJob(SLAMDServer slamdServer, java.lang.String jobID)
          Removes information about the specified job from the configuration database.
 void removeOptimizingJob(SLAMDServer slamdServer, java.lang.String optimizingJobID)
          Removes information about the specified optimizing job from the configuration database.
 void removeUploadedFile(java.lang.String folderName, java.lang.String fileName)
          Removes information about the specified uploaded file from the configuration database.
 void writeFolder(JobFolder jobFolder)
          Writes information about the provided job folder into the configuration database.
 void writeJob(SLAMDServer slamdServer, Job job)
          Writes information about the provided job into the configuration database.
 void writeOptimizingJob(SLAMDServer slamdServer, OptimizingJob optimizingJob)
          Writes information about the provided optimizing job into the configuration database.
 void writeUploadedFile(UploadedFile uploadedFile, java.lang.String folderName)
          Writes information about the provided uploaded file into the configuration database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SLAMDDB

public SLAMDDB(java.lang.String dbDirectory,
               boolean readOnly,
               boolean createIfNecessary)
        throws com.sleepycat.je.DatabaseException
Initializes the SLAMD database and opens the environment, creating a new one if necessary.

Parameters:
dbDirectory - The path to the directory in which the database files should be held.
readOnly - Indicates whether the database should be opened in read-only mode.
createIfNecessary - Indicates whether a new database environment should be created if one does not already exist.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while initializing the database environment.
Method Detail

openDatabases

public void openDatabases(boolean createIfNecessary)
                   throws com.sleepycat.je.DatabaseException
Opens all the databases used in the SLAMD database environment. If the databases are already open, then no action will be taken.

Parameters:
createIfNecessary - Indicates whether any database(s) that do not exist should be created.
Throws:
com.sleepycat.je.DatabaseException

closeDatabases

public void closeDatabases(boolean abortTransactions)
                    throws com.sleepycat.je.DatabaseException
Closes all databases in the environment. If the databases are already closed then this method will do anything.

Parameters:
abortTransactions - Indicates whether any transactions in progress should be aborted. If not and there are active transactions, then this method will fail.
Throws:
com.sleepycat.je.DatabaseException - If there are active transactions and this method is configured to not abort them.

closeEnvironment

public void closeEnvironment()
                      throws com.sleepycat.je.DatabaseException
Closes the database environment. This will only be allowed if the databases have already been closed.

Throws:
com.sleepycat.je.DatabaseException - If the databases are still open.

getConfigParameter

public java.lang.String getConfigParameter(java.lang.String parameterName)
                                    throws com.sleepycat.je.DatabaseException
Retrieves the value of the specified configuration parameter from the configuration database.

Parameters:
parameterName - The name of the configuration parameter to retrieve.
Returns:
The value of the specified configuration parameter, or null if there is no such parameter.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the database.

getConfigParameter

public java.lang.String getConfigParameter(java.lang.String parameterName,
                                           java.lang.String defaultValue)
                                    throws com.sleepycat.je.DatabaseException
Retrieves the value of the specified configuration parameter from the configuration database.

Parameters:
parameterName - The name of the configuration parameter to retrieve.
defaultValue - The value to use for the parameter if the specified key is not present in the database.
Returns:
The value of the specified configuration parameter, or the provided default value if there is no such parameter.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the database.

getConfigParameter

public boolean getConfigParameter(java.lang.String parameterName,
                                  boolean defaultValue)
                           throws com.sleepycat.je.DatabaseException
Retrieves the value of the specified configuration parameter from the configuration database.

Parameters:
parameterName - The name of the configuration parameter to retrieve.
defaultValue - The value to use for the parameter if the specified key is not present in the database.
Returns:
The value of the specified configuration parameter, or the provided default value if there is no such parameter.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the database.

getConfigParameter

public int getConfigParameter(java.lang.String parameterName,
                              int defaultValue)
                       throws com.sleepycat.je.DatabaseException
Retrieves the value of the specified configuration parameter from the configuration database.

Parameters:
parameterName - The name of the configuration parameter to retrieve.
defaultValue - The value to use for the parameter if the specified key is not present in the database.
Returns:
The value of the specified configuration parameter, or the provided default value if there is no such parameter.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the database.

putConfigParameter

public void putConfigParameter(java.lang.String parameterName,
                               java.lang.String parameterValue)
                        throws com.sleepycat.je.DatabaseException
Sets the value of the specified parameter in the configuration database.

Parameters:
parameterName - The name of the parameter to set.
parameterValue - The value to use for the configuration parameter.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while attempting to store the configuration parameter.

putConfigParameter

public void putConfigParameter(java.lang.String parameterName,
                               boolean parameterValue)
                        throws com.sleepycat.je.DatabaseException
Sets the value of the specified parameter in the configuration database.

Parameters:
parameterName - The name of the parameter to set.
parameterValue - The value to use for the configuration parameter.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while attempting to store the configuration parameter.

putConfigParameter

public void putConfigParameter(java.lang.String parameterName,
                               int parameterValue)
                        throws com.sleepycat.je.DatabaseException
Sets the value of the specified parameter in the configuration database.

Parameters:
parameterName - The name of the parameter to set.
parameterValue - The value to use for the configuration parameter.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while attempting to store the configuration parameter.

removeConfigParameter

public void removeConfigParameter(java.lang.String parameterName)
                           throws com.sleepycat.je.DatabaseException
Removes information about the specified parameter from the configuration database.

Parameters:
parameterName - The name of the configuration parameter to remove from the configuration database.
Throws:
com.sleepycat.je.DatabaseException - If problem occurs while interacting with the configuration database.

getFolder

public JobFolder getFolder(java.lang.String folderName)
                    throws com.sleepycat.je.DatabaseException,
                           DecodeException
Retrieves the specified folder from the configuration database.

Parameters:
folderName - The name of the folder to retrieve.
Returns:
The requested folder, or null if no such folder exists.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.
DecodeException - If a problem occurs while trying to decode the folder from the configuration database.

getFolders

public JobFolder[] getFolders()
                       throws com.sleepycat.je.DatabaseException
Retrieves a list of all job folders defined in the configuration database.

Returns:
A list of all job folders defined in the configuration database.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.

writeFolder

public void writeFolder(JobFolder jobFolder)
                 throws com.sleepycat.je.DatabaseException
Writes information about the provided job folder into the configuration database. If the specified job already exists, then it will be replaced.

Parameters:
jobFolder - The folder to write to the configuration database.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.

removeFolder

public void removeFolder(java.lang.String folderName)
                  throws com.sleepycat.je.DatabaseException
Removes information about the specified job folder from the configuration database. If the specified folder does not exist, then no action will be taken.

Parameters:
folderName - The name of the job folder to remove from the configuration database.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.

getJob

public Job getJob(SLAMDServer slamdServer,
                  java.lang.String jobID)
           throws com.sleepycat.je.DatabaseException,
                  DecodeException
Retrieves the specified job from the configuration database.

Parameters:
slamdServer - The SLAMD server with which the job is associated.
jobID - The job ID of the job to retrieve from the database.
Returns:
The requested job from the configuration database, or null if no such job exists.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.
DecodeException - If a problem occurs while decoding the job information.

getSummaryJob

public Job getSummaryJob(SLAMDServer slamdServer,
                         java.lang.String jobID)
                  throws com.sleepycat.je.DatabaseException,
                         DecodeException
Retrieves summary information for the specified job from the configuration database.

Parameters:
slamdServer - The SLAMD server with which the job is associated.
jobID - The job ID of the job to retrieve from the database.
Returns:
Summary information for the requested job from the configuration database, or null if no such job exists.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.
DecodeException - If a problem occurs while decoding the job information.

getJobs

public Job[] getJobs(SLAMDServer slamdServer,
                     java.lang.String folderName)
              throws com.sleepycat.je.DatabaseException,
                     DecodeException
Retrieves the set of jobs contained in the specified folder of the configuration database.

Parameters:
slamdServer - The SLAMD server with which the jobs are associated.
folderName - The name of the folder for which to retrieve the associated jobs.
Returns:
The set of jobs contained in the specified folder of the configuration database, or null if there is no such folder.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.
DecodeException - If a problem occurs while attempting to decode the specified folder.

getSummaryJobs

public Job[] getSummaryJobs(SLAMDServer slamdServer,
                            java.lang.String folderName)
                     throws com.sleepycat.je.DatabaseException,
                            DecodeException
Retrieves summary information for the set of jobs contained in the specified folder of the configuration database.

Parameters:
slamdServer - The SLAMD server with which the jobs are associated.
folderName - The name of the folder for which to retrieve the associated jobs.
Returns:
Summary information about the set of jobs contained in the specified folder of the configuration database, or null if there is no such folder.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.
DecodeException - If a problem occurs while attempting to decode the specified folder.

writeJob

public void writeJob(SLAMDServer slamdServer,
                     Job job)
              throws com.sleepycat.je.DatabaseException
Writes information about the provided job into the configuration database. If the specified job already exists, it will be overwritten. Otherwise, it will be added.

Parameters:
slamdServer - The SLAMD server with which the job is associated.
job - The job to write to the database.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while attempting to write the job information.

removeJob

public void removeJob(SLAMDServer slamdServer,
                      java.lang.String jobID)
               throws com.sleepycat.je.DatabaseException
Removes information about the specified job from the configuration database.

Parameters:
slamdServer - The SLAMD server with which the job is associated.
jobID - The job ID of the job to remove from the configuration database.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.

moveJob

public void moveJob(SLAMDServer slamdServer,
                    java.lang.String jobID,
                    java.lang.String folderName)
             throws com.sleepycat.je.DatabaseException
Moves the specified job from its current folder to the new folder.

Parameters:
slamdServer - The SLAMD server with which the job is assocaited.
jobID - The job ID of the job to move.
folderName - The name of the new folder in which to place the job.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.

getOptimizingJob

public OptimizingJob getOptimizingJob(SLAMDServer slamdServer,
                                      java.lang.String optimizingJobID)
                               throws com.sleepycat.je.DatabaseException,
                                      DecodeException
Retrieves the specified optimizing job from the configuration database.

Parameters:
slamdServer - The SLAMD server with which the optimizing job is associated.
optimizingJobID - The ID of the optimizing job to retrieve from the database.
Returns:
The requested optimizing job from the configuration database, or null if no such job exists.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.
DecodeException - If a problem occurs while decoding the optimizing job information.

getSummaryOptimizingJob

public OptimizingJob getSummaryOptimizingJob(SLAMDServer slamdServer,
                                             java.lang.String optimizingJobID)
                                      throws com.sleepycat.je.DatabaseException,
                                             DecodeException
Retrieves summary information for the specified optimizing job from the configuration database.

Parameters:
slamdServer - The SLAMD server with which the optimizing job is associated.
optimizingJobID - The ID of the optimizing job to retrieve from the database.
Returns:
Summary information for the requested optimizing job from the configuration database, or null if no such job exists.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.
DecodeException - If a problem occurs while decoding the optimizing job information.

getOptimizingJobs

public OptimizingJob[] getOptimizingJobs(SLAMDServer slamdServer,
                                         java.lang.String folderName)
                                  throws com.sleepycat.je.DatabaseException,
                                         DecodeException
Retrieves the set of optimizing jobs contained in the specified folder of the configuration database.

Parameters:
slamdServer - The SLAMD server with which the optimizing jobs are associated.
folderName - The name of the folder for which to retrieve the associated optimizing jobs.
Returns:
The set of optimizing jobs contained in the specified folder of the configuration database, or null if there is no such folder.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.
DecodeException - If a problem occurs while attempting to decode the specified folder.

getSummaryOptimizingJobs

public OptimizingJob[] getSummaryOptimizingJobs(SLAMDServer slamdServer,
                                                java.lang.String folderName)
                                         throws com.sleepycat.je.DatabaseException,
                                                DecodeException
Retrieves summary information for the set of optimizing jobs contained in the specified folder of the configuration database.

Parameters:
slamdServer - The SLAMD server with which the optimizing jobs are associated.
folderName - The name of the folder for which to retrieve the associated optimizing jobs.
Returns:
Summary information for the set of optimizing jobs contained in the specified folder of the configuration database, or null if there is no such folder.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.
DecodeException - If a problem occurs while attempting to decode the specified folder.

writeOptimizingJob

public void writeOptimizingJob(SLAMDServer slamdServer,
                               OptimizingJob optimizingJob)
                        throws com.sleepycat.je.DatabaseException
Writes information about the provided optimizing job into the configuration database. If the specified optimizing job already exists, it will be overwritten. Otherwise, it will be added.

Parameters:
slamdServer - The SLAMD server with which the optimizing job is associated.
optimizingJob - The optimizing job to write to the database.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while attempting to write the optimizing job information.

removeOptimizingJob

public void removeOptimizingJob(SLAMDServer slamdServer,
                                java.lang.String optimizingJobID)
                         throws com.sleepycat.je.DatabaseException
Removes information about the specified optimizing job from the configuration database.

Parameters:
slamdServer - The SLAMD server with which the job is associated.
optimizingJobID - The ID of the optimizing job to remove from the configuration database.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.

moveOptimizingJob

public void moveOptimizingJob(SLAMDServer slamdServer,
                              java.lang.String optimizingJobID,
                              java.lang.String folderName)
                       throws com.sleepycat.je.DatabaseException
Moves the specified optimizing job from its current folder to the new folder.

Parameters:
slamdServer - The SLAMD server with which the optimizing job is assocaited.
optimizingJobID - The job ID of the job to move.
folderName - The name of the new folder in which to place the optimizing job.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.

getUploadedFile

public UploadedFile getUploadedFile(java.lang.String folderName,
                                    java.lang.String fileName)
                             throws com.sleepycat.je.DatabaseException,
                                    DecodeException
Retrieves the specified uploaded file from the configuration database.

Parameters:
folderName - The name of the folder in which the speified file is located.
fileName - The name of the uploaded file to retrieve.
Returns:
The requested uploaded file, or null if no such file exists.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.
DecodeException - If the uploaded file cannot be decoded for some reason.

getUploadedFileWithoutData

public UploadedFile getUploadedFileWithoutData(java.lang.String folderName,
                                               java.lang.String fileName)
                                        throws com.sleepycat.je.DatabaseException,
                                               DecodeException
Retrieves the specified uploaded file from the configuration database. The file returned will not include the actual file data.

Parameters:
folderName - The name of the folder in which the speified file is located.
fileName - The name of the uploaded file to retrieve.
Returns:
The requested uploaded file, or null if no such file exists.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.
DecodeException - If the uploaded file cannot be decoded for some reason.

getUploadedFiles

public UploadedFile[] getUploadedFiles(java.lang.String folderName)
                                throws com.sleepycat.je.DatabaseException
Retrieves the set of uploaded files associated with the specified folder. The files returned will not include the actual file data.

Parameters:
folderName - The name of the folder for which to retrieve the uploaded files.
Returns:
The set of uploaded files associated with the specified folder, or null if there is no such folder.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.

writeUploadedFile

public void writeUploadedFile(UploadedFile uploadedFile,
                              java.lang.String folderName)
                       throws com.sleepycat.je.DatabaseException
Writes information about the provided uploaded file into the configuration database. If the file already exists, then it will be overwritten. Otherwise, it will be added and the corresponding folder will be updated.

Parameters:
uploadedFile - The uploaded file to be written to the configuration database.
folderName - The name of the folder in which the speicified file should be placed.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while writing information about the specified file to the configuration database.

removeUploadedFile

public void removeUploadedFile(java.lang.String folderName,
                               java.lang.String fileName)
                        throws com.sleepycat.je.DatabaseException
Removes information about the specified uploaded file from the configuration database.

Parameters:
folderName - The name of the folder from which to remove the file.
fileName - The name of the uploaded file to remove.
Throws:
com.sleepycat.je.DatabaseException - If a problem occurs while interacting with the configuration database.