dist1.acb.CBL
Class DBExplorer

java.lang.Object
  extended bydist1.acb.CBL.DBExplorer
All Implemented Interfaces:
UpdatesExecutor

public class DBExplorer
extends java.lang.Object
implements UpdatesExecutor

Database Explorer

Version:
$Revision: 1.126 $
Author:
Gergana Krumova/Mariana Marin

Method Summary
 void clearSnapshotDir()
          Clears the directory for snapshots
 void clearUsersState()
          Set to null ip, port and cbl of user
 void connect()
          Connects to the database
 void createAtLeastOneAdmin()
          Checks number of administrators in the system and if there is no administrators, creates one
 java.util.LinkedList getAliveCBLs()
          Returns the list of CBLs from the database
 Response getBalance(java.lang.String login, Request request)
          Handler for request GetBalance
 Response getCashFlows(java.lang.String login, Request request)
          Handler for request Cash Flow
 java.util.LinkedList getCBLs()
          Returns the list of CBLs from the database
 java.util.LinkedList getCBLsInfo()
          Returns the list of CBLs from the database with addition Information (ResponseCBLsInfo.)
static DBExplorer getInstance()
          getInstance
 java.util.LinkedList getLog(long afterId)
          Returns the list of Logs from the database
 Response getPeersLocation(RequestGetPeersLocation request)
          Handles peer's location
 ResponseTopics getTopics(Request request)
          Returns a list of Topics in the database
 User getUser(java.lang.String login)
          given a login returns User object
 Response hBeginSellTransaction(java.lang.String login, RequestUpdate request)
          Handler for request insert register
 Response hCloseSession(java.lang.String login, RequestUpdate request)
          Handler for request CloseSession
 Response hDeleteOldUsers(java.lang.String login, RequestUpdate request)
          Delete Old users
 Response hEndSellTransaction(java.lang.String login, RequestUpdate request)
          Handler for request BeginSellTransaction
 Response hInitCBLTable(java.lang.String login, RequestUpdate request)
          Handler for request InitCBLTable (Clears (sets to 0) state of all CBLs in the table and updates Primary's record)
 Response hInsertLog(java.lang.String login, RequestUpdate request)
          Handler for request insert log
 Response hLogin(java.lang.String login, RequestUpdate request)
          Handler for request Login
 Response hMoneyFromAccount(java.lang.String login, RequestUpdate request)
          Handler for request MoneyFromAccount
 Response hMoneyToAccount(java.lang.String login, RequestUpdate request)
          Handler for request MoneyToAccount
 Response hRegister(java.lang.String login, RequestUpdate request)
          Handler for request Register
 Response hRemoveCBL(java.lang.String login, RequestUpdate request)
          Delete CBLs
 Response hRemoveFiles(java.lang.String login, RequestUpdate request)
          Handler for request RemoveFiles
 Response hShare(java.lang.String login, RequestUpdate request)
          Handler for request Share
 Response hUpdateCBL(java.lang.String login, RequestUpdate request)
          Handler for request update a CBL
 Response hUpdateUser(java.lang.String login, RequestUpdate request)
          Handler for request update a user
 void loadSnapshot()
          Clear the database and load the snapshot from directory \dbsnapshot
 void lockTables()
          Flushs and Locks all tables with read lock
 Response search(RequestSearch request)
          Search for files
 void storeSnapshot()
          Makes snapshot of database and put it to the \dbsnapshot directory.
 void unlockTables()
          Unlocks all tables previosly locked by lockTables() method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static DBExplorer getInstance()
getInstance

Returns:
instance

getAliveCBLs

public java.util.LinkedList getAliveCBLs()
                                  throws java.sql.SQLException
Returns the list of CBLs from the database

Returns:
List of active CBLs
Throws:
java.sql.SQLException - if something is wrong

getBalance

public Response getBalance(java.lang.String login,
                           Request request)
Handler for request GetBalance

Parameters:
login -
request -
Returns:
response

getCBLs

public java.util.LinkedList getCBLs()
                             throws java.sql.SQLException
Returns the list of CBLs from the database

Returns:
the list
Throws:
java.sql.SQLException - if something is wrong

getCBLsInfo

public java.util.LinkedList getCBLsInfo()
                                 throws java.sql.SQLException,
                                        java.lang.CloneNotSupportedException
Returns the list of CBLs from the database with addition Information (ResponseCBLsInfo.)

Returns:
the list
Throws:
java.sql.SQLException - if something is wrong
java.lang.CloneNotSupportedException - if CBL is not clonable

getCashFlows

public Response getCashFlows(java.lang.String login,
                             Request request)
Handler for request Cash Flow

Parameters:
login - User's login
request - The request
Returns:
A response

getLog

public java.util.LinkedList getLog(long afterId)
                            throws java.sql.SQLException
Returns the list of Logs from the database

Parameters:
afterId - DOCUMENT ME!
Returns:
the list
Throws:
java.sql.SQLException - if something is wrong

getPeersLocation

public Response getPeersLocation(RequestGetPeersLocation request)
Handles peer's location

Parameters:
request - DOCUMENT ME!
Returns:
DOCUMENT ME!

getTopics

public ResponseTopics getTopics(Request request)
                         throws java.sql.SQLException
Returns a list of Topics in the database

Parameters:
request - Request for topics
Returns:
list
Throws:
java.sql.SQLException

getUser

public User getUser(java.lang.String login)
             throws java.sql.SQLException,
                    java.lang.RuntimeException
given a login returns User object

Parameters:
login -
Returns:
user object or null
Throws:
java.sql.SQLException
java.lang.RuntimeException - if user was not found

clearSnapshotDir

public void clearSnapshotDir()
Clears the directory for snapshots


clearUsersState

public void clearUsersState()
Set to null ip, port and cbl of user


connect

public void connect()
             throws java.lang.Throwable
Connects to the database

Throws:
java.lang.Throwable - if something wrong
java.sql.SQLException - error in SQL

createAtLeastOneAdmin

public void createAtLeastOneAdmin()
                           throws java.sql.SQLException
Checks number of administrators in the system and if there is no administrators, creates one

Throws:
java.sql.SQLException - if something wrong

hBeginSellTransaction

public Response hBeginSellTransaction(java.lang.String login,
                                      RequestUpdate request)
Handler for request insert register

Specified by:
hBeginSellTransaction in interface UpdatesExecutor
Parameters:
login - Urer's login
request - The request
Returns:
A response

hCloseSession

public Response hCloseSession(java.lang.String login,
                              RequestUpdate request)
Handler for request CloseSession

Specified by:
hCloseSession in interface UpdatesExecutor
Parameters:
login - Urer's login
request - The request
Returns:
A response

hDeleteOldUsers

public Response hDeleteOldUsers(java.lang.String login,
                                RequestUpdate request)
Delete Old users

Specified by:
hDeleteOldUsers in interface UpdatesExecutor
Parameters:
login - Urer's login
request - The request
Returns:
A response

hRemoveCBL

public Response hRemoveCBL(java.lang.String login,
                           RequestUpdate request)
Delete CBLs

Specified by:
hRemoveCBL in interface UpdatesExecutor
Parameters:
login - Urer's login
request - The request
Returns:
A response

hEndSellTransaction

public Response hEndSellTransaction(java.lang.String login,
                                    RequestUpdate request)
Handler for request BeginSellTransaction

Specified by:
hEndSellTransaction in interface UpdatesExecutor
Parameters:
login - Urer's login
request - The request
Returns:
A response

hInitCBLTable

public Response hInitCBLTable(java.lang.String login,
                              RequestUpdate request)
Handler for request InitCBLTable (Clears (sets to 0) state of all CBLs in the table and updates Primary's record)

Specified by:
hInitCBLTable in interface UpdatesExecutor
Parameters:
login - Urer's login
request - The request
Returns:
A response

hInsertLog

public Response hInsertLog(java.lang.String login,
                           RequestUpdate request)
Handler for request insert log

Specified by:
hInsertLog in interface UpdatesExecutor
Parameters:
login - Urer's login
request - The request
Returns:
A response

hLogin

public Response hLogin(java.lang.String login,
                       RequestUpdate request)
Handler for request Login

Specified by:
hLogin in interface UpdatesExecutor
Parameters:
login - A user login
request - The request
Returns:
A response

hMoneyFromAccount

public Response hMoneyFromAccount(java.lang.String login,
                                  RequestUpdate request)
Handler for request MoneyFromAccount

Specified by:
hMoneyFromAccount in interface UpdatesExecutor
Parameters:
login - Urer's login
request - The request
Returns:
A response

hMoneyToAccount

public Response hMoneyToAccount(java.lang.String login,
                                RequestUpdate request)
Handler for request MoneyToAccount

Specified by:
hMoneyToAccount in interface UpdatesExecutor
Parameters:
login - Urer's login
request - The request
Returns:
A response

hRegister

public Response hRegister(java.lang.String login,
                          RequestUpdate request)
Handler for request Register

Specified by:
hRegister in interface UpdatesExecutor
Parameters:
login - Urer's login
request - The request
Returns:
A response
Throws:
java.lang.RuntimeException - internal exception

hRemoveFiles

public Response hRemoveFiles(java.lang.String login,
                             RequestUpdate request)
Handler for request RemoveFiles

Specified by:
hRemoveFiles in interface UpdatesExecutor
Parameters:
login - Urer's login
request - The request
Returns:
A response

hShare

public Response hShare(java.lang.String login,
                       RequestUpdate request)
Handler for request Share

Specified by:
hShare in interface UpdatesExecutor
Parameters:
login - Urer's login
request - The request
Returns:
A response

hUpdateCBL

public Response hUpdateCBL(java.lang.String login,
                           RequestUpdate request)
Handler for request update a CBL

Specified by:
hUpdateCBL in interface UpdatesExecutor
Parameters:
login - Urer's login
request - The request
Returns:
A response

hUpdateUser

public Response hUpdateUser(java.lang.String login,
                            RequestUpdate request)
Handler for request update a user

Specified by:
hUpdateUser in interface UpdatesExecutor
Parameters:
login - Urer's login
request - The request
Returns:
A response

loadSnapshot

public void loadSnapshot()
                  throws java.lang.Exception
Clear the database and load the snapshot from directory \dbsnapshot

Throws:
java.lang.Exception - is something wrong

lockTables

public void lockTables()
                throws java.sql.SQLException
Flushs and Locks all tables with read lock

Throws:
java.sql.SQLException - is something wrong

search

public Response search(RequestSearch request)
Search for files

Parameters:
request -
Returns:
response

storeSnapshot

public void storeSnapshot()
                   throws java.sql.SQLException
Makes snapshot of database and put it to the \dbsnapshot directory. The tables must be locked before the invocation of this method!

Throws:
java.sql.SQLException - if something wrong

unlockTables

public void unlockTables()
                  throws java.sql.SQLException
Unlocks all tables previosly locked by lockTables() method

Throws:
java.sql.SQLException - if something wrong


Copyright © 2004 Phoenix Team (CMU/AIT). All Rights Reserved.