org.glite.security.voms.database
Class Database

java.lang.Object
  extended byorg.glite.security.voms.database.Database

public final class Database
extends java.lang.Object

A façade class for executing operations (questions and actions) in the database, hiding the gory details of transaction management behind a simple interface. Also provides a database-independent schema description.

Author:
Karoly Lorentey
See Also:
org.glite.security.voms.operation

Method Summary
 void addGlobalAdmin(java.lang.String dn, java.lang.String ca)
          Add a Global ACL entry to allow all VO operations to the given client.
static java.lang.Object ask(Question question)
          Ask the given question by calling its Question.ask() method in the appropriate environment.
 void create()
          Drop and recreate all tables, unless they are already there.
 void drop()
          Drop all tables, i.e. delete the entire database.
static java.lang.Object execute(DirectManipulation op)
          Execute the SQL commands in the given DirectManipulation by calling its DirectManipulation.execute(org.glite.security.voms.database.connection.DirectUpdate) method in the appropriate environment.
static DBFlavour getDBFlavour()
          Return the current database flavour.
static void main(java.lang.String[] args)
           
static java.lang.Object perform(Action action)
          Perform the given action by calling its Action.performWithResult() method in the appropriate environment.
static java.lang.Object performDirectly(Action action)
          Perform a given action without regard for security.
static Database theDatabase()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

theDatabase

public static Database theDatabase()

getDBFlavour

public static DBFlavour getDBFlavour()
Return the current database flavour.


perform

public static java.lang.Object perform(Action action)
                                throws VOMSException
Perform the given action by calling its Action.performWithResult() method in the appropriate environment.

This method takes care of

  1. allocating a new database connection,
  2. beginning a new update transaction,
  3. identifying the client,
  4. doing the necessary permission checks (as defined by Action.checkPermission()),
  5. executing the action,
  6. commiting or rolling back the transaction depending on the result of the execution, and
  7. releasing the connection back to the connection pool.

If the transaction failed with a database error, the action is automatically retried with a new connection. Any other exception is passed up to the caller.

Returns:
The result of the action, or null if the action is valueless.
Throws:
VOMSException

performDirectly

public static java.lang.Object performDirectly(Action action)
                                        throws VOMSException
Perform a given action without regard for security. Behaves just like perform(org.glite.security.voms.operation.Action), but does not do any permission checks.

Throws:
VOMSException

ask

public static java.lang.Object ask(Question question)
                            throws VOMSException
Ask the given question by calling its Question.ask() method in the appropriate environment.

This method takes care of

  1. allocating a new database connection,
  2. beginning a new query transaction,
  3. identifying the client,
  4. doing the necessary permission checks (as defined by Question.checkPermission()),
  5. executing the question,
  6. ending the transaction, and
  7. releasing the connection back to the connection pool.

If the transaction failed with a database error, the question is automatically retried with a new connection. Any other exception is passed up to the caller.

Returns:
The result of the question.
Throws:
VOMSException

execute

public static java.lang.Object execute(DirectManipulation op)
                                throws VOMSException
Execute the SQL commands in the given DirectManipulation by calling its DirectManipulation.execute(org.glite.security.voms.database.connection.DirectUpdate) method in the appropriate environment. This is used for manipulation of the SEQUENCE and REALTIME tables.

Throws:
VOMSException

create

public void create()
            throws java.sql.SQLException,
                   VOMSException
Drop and recreate all tables, unless they are already there. A rather dangerous operation.

Throws:
java.sql.SQLException
VOMSException

drop

public void drop()
          throws java.sql.SQLException,
                 VOMSException
Drop all tables, i.e. delete the entire database. A rather dangerous operation.

Throws:
java.sql.SQLException
VOMSException

addGlobalAdmin

public void addGlobalAdmin(java.lang.String dn,
                           java.lang.String ca)
                    throws VOMSException
Add a Global ACL entry to allow all VO operations to the given client.

Throws:
VOMSException

main

public static void main(java.lang.String[] args)