org.mega.gasp.platform.impl
Class DBManagerImpl

java.lang.Object
  extended byorg.mega.gasp.platform.impl.DBManagerImpl
All Implemented Interfaces:
DBManager

public class DBManagerImpl
extends java.lang.Object
implements DBManager

DBManager contains all the methods requiring an acces to the GASP DB.

Author:
PELLERIN Romain (pellerin@cnam.fr) - MEGA Project

Field Summary
private  org.apache.log4j.Category cat
           
private  java.sql.Connection connection
           
private  javax.sql.DataSource dataSource
           
private  java.lang.String dbUrl
           
private  boolean isDBConnectivityOK
           
 
Constructor Summary
DBManagerImpl(PropertiesReader propertiesReader)
           
 
Method Summary
 void closeDBConnection()
          Close the DB connection.
 int generateActorID()
          Generate a DB persistant Actor ID.
 Actor getActorIfAuthentificationOK(int aID, java.lang.String username, java.lang.String password)
          Verify if the login authentification of an Actor is valid then return the authentified actor or null.
 boolean isDBConnectionOK()
          Verify if the connection to the GASP DB is ok.
private  boolean isUserAllowed(java.sql.Statement statement, java.lang.String uid, int appID)
          Determine by search the table rights if the user have the rigths to play the application appID.
 void openDBConnection()
          Open a DB connection.
 int registerNewActor(java.lang.String uid, int appID, java.lang.String username, java.lang.String password)
          Register a new actor for the double (uid,appID) if the user have the appropriate rights.
 void saveLastUsedPseudo(int actorID, java.lang.String pseudoName)
          Saves in the DB the last used pseudo.
private  int userAlreadyRegistered(java.sql.Statement statement, java.lang.String uid, int appID)
          Determine by search the table rights if the user have already an actorID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cat

private org.apache.log4j.Category cat

connection

private java.sql.Connection connection

dataSource

private javax.sql.DataSource dataSource

dbUrl

private java.lang.String dbUrl

isDBConnectivityOK

private boolean isDBConnectivityOK
Constructor Detail

DBManagerImpl

public DBManagerImpl(PropertiesReader propertiesReader)
Method Detail

isDBConnectionOK

public boolean isDBConnectionOK()
Verify if the connection to the GASP DB is ok.

Specified by:
isDBConnectionOK in interface DBManager
Returns:
boolean

openDBConnection

public void openDBConnection()
Open a DB connection.


closeDBConnection

public void closeDBConnection()
Close the DB connection.


generateActorID

public int generateActorID()
Generate a DB persistant Actor ID.

Specified by:
generateActorID in interface DBManager
Returns:
the actor ID

getActorIfAuthentificationOK

public Actor getActorIfAuthentificationOK(int aID,
                                          java.lang.String username,
                                          java.lang.String password)
Verify if the login authentification of an Actor is valid then return the authentified actor or null.

Specified by:
getActorIfAuthentificationOK in interface DBManager
Parameters:
aID - the actor ID
username -
password -
Returns:
the Actor instance object

registerNewActor

public int registerNewActor(java.lang.String uid,
                            int appID,
                            java.lang.String username,
                            java.lang.String password)
Register a new actor for the double (uid,appID) if the user have the appropriate rights.

Specified by:
registerNewActor in interface DBManager
Parameters:
uid -
appID -
username -
password -
Returns:
the Actor ID

userAlreadyRegistered

private int userAlreadyRegistered(java.sql.Statement statement,
                                  java.lang.String uid,
                                  int appID)
Determine by search the table rights if the user have already an actorID.

Parameters:
statement - the Statement of DB
uid - the User ID
appID - the Application ID
Returns:
boolean

isUserAllowed

private boolean isUserAllowed(java.sql.Statement statement,
                              java.lang.String uid,
                              int appID)
Determine by search the table rights if the user have the rigths to play the application appID.

Parameters:
statement - the Statement of DB
uid - the User ID
appID - the Application ID
Returns:
boolean

saveLastUsedPseudo

public void saveLastUsedPseudo(int actorID,
                               java.lang.String pseudoName)
Saves in the DB the last used pseudo.

Specified by:
saveLastUsedPseudo in interface DBManager
Parameters:
actorID -
pseudoName -