org.edg.security.voms.database.connection
Class Database

java.lang.Object
  |
  +--org.edg.security.voms.database.connection.Database

public 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.

Version:
$Name: v0_7_0 $
Author:
Karoly Lorentey
See Also:
org.edg.security.voms.operation

Field Summary
private static org.apache.log4j.Logger log
          Logger.
private static int MAX_TRANSACTION_RESTARTS
           
 
Constructor Summary
Database()
           
 
Method Summary
static java.lang.Object ask(Question question)
          Ask the given question by calling its Question.ask() method in the appropriate environment.
static java.lang.Object execute(DirectManipulation op)
          Execute the SQL commands in the given DirectManipulation by calling its DirectManipulation.execute(org.edg.security.voms.database.connection.DirectUpdate) method in the appropriate environment.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_TRANSACTION_RESTARTS

private static final int MAX_TRANSACTION_RESTARTS

log

private static org.apache.log4j.Logger log
Logger.

Constructor Detail

Database

public Database()
Method Detail

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.
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.edg.security.voms.operation.Action), but does not do any permission checks.

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.
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.edg.security.voms.database.connection.DirectUpdate) method in the appropriate environment. This is used for manipulation of the SEQUENCE and REALTIME tables.

VOMSException