suncertify.common
Interface QueryInterface

All Superinterfaces:
java.rmi.Remote
All Known Implementing Classes:
QueryInterfaceImpl

public interface QueryInterface
extends java.rmi.Remote

Remote interface for accessing Database. It have the same as DBMain interface but thay are additionally equipped with client login parameter and two additional method dataBase login and logout


Method Summary
 int create(java.lang.String[] data, java.lang.String clientId)
          Creates a new record in the database (possibly reusing a deleted entry).
 void delete(int recNo, java.lang.String clientId)
          Deletes a record, making the record number and associated disk storage available for reuse.
 int[] find(java.lang.String[] criteria, java.lang.String clientId)
          Returns an array of record numbers that match the specified criteria.
 boolean isLocked(int recNo, java.lang.String clientId)
          Determines if a record is currenly locked.
 void lock(int recNo, java.lang.String clientId)
          Locks a record so that it can only be updated or deleted by this client.
 java.lang.String logIn()
          The method performs client login it is required as server needs to identify clients
 void logIn(java.lang.String string)
          The method performs client login it is required as server needs to identify clients
 void logOut(java.lang.String clientId)
          The method performs client logout - no others connections with such login will be available
 java.lang.String[] read(int recNo, java.lang.String clientId)
          Reads a record from the file.
 void unlock(int recNo, java.lang.String clientId)
          Releases the lock on a record.
 void update(int recNo, java.lang.String[] data, java.lang.String clientId)
          Modifies the fields of a record.
 

Method Detail

read

public java.lang.String[] read(int recNo,
                               java.lang.String clientId)
                        throws RecordNotFoundException,
                               ClientNotLoggedInException,
                               java.rmi.RemoteException
Reads a record from the file. Returns an array where each element is a record value.

Parameters:
recNo - the index of the requested record
clientId - the unique identifier of the clienent thet is performing request
Returns:
string array with the values of requested record fields
Throws:
RecordNotFoundException - is thrown if a specified record does not exist or is marked as deleted in the database file.
java.rmi.RemoteException - - required for remote access
ClientNotLoggedInException - - is thrown when client login passed as argument is not a valid client login (e.g. client has not been logged in)

update

public void update(int recNo,
                   java.lang.String[] data,
                   java.lang.String clientId)
            throws RecordNotFoundException,
                   ClientNotLoggedInException,
                   java.rmi.RemoteException
Modifies the fields of a record. The new value for field n appears in data[n].

Parameters:
recNo - the index of the record to operate on
data - the new set of data for the requested record
clientId - the unique identifier of the clienent thet is performing request
Throws:
RecordNotFoundException - is thrown if a specified record does not exist or is marked as deleted in the database file.
java.rmi.RemoteException - - required for remote access
ClientNotLoggedInException - - is thrown when client login passed as argument is not a valid client login (e.g. client has not been logged in)

delete

public void delete(int recNo,
                   java.lang.String clientId)
            throws RecordNotFoundException,
                   ClientNotLoggedInException,
                   java.rmi.RemoteException
Deletes a record, making the record number and associated disk storage available for reuse.

Parameters:
recNo - the index of the record to delete
clientId - the unique identifier of the clienent thet is performing request
Throws:
RecordNotFoundException - is thrown if a specified record does not exist or is marked as deleted in the database file.
java.rmi.RemoteException - - required for remote access
ClientNotLoggedInException - - is thrown when client login passed as argument is not a valid client login (e.g. client has not been logged in)

find

public int[] find(java.lang.String[] criteria,
                  java.lang.String clientId)
           throws RecordNotFoundException,
                  ClientNotLoggedInException,
                  java.rmi.RemoteException
Returns an array of record numbers that match the specified criteria. Field n in the database file is described by criteria[n]. A null value in criteria[n] matches any field value. A non-null value in criteria[n] matches any field value that begins with criteria[n]. (For example, "Fred" matches "Fred" or "Freddy".)

Parameters:
criteria - String array representing the criteria for each record field
clientId - the unique identifier of the clienent thet is performing request
Returns:
array containig indexes of all records meeting the criteria
Throws:
RecordNotFoundException - is thrown if a specified record does not exist or is marked as deleted in the database file.
java.rmi.RemoteException - - required for remote access
ClientNotLoggedInException - - is thrown when client login passed as argument is not a valid client login (e.g. client has not been logged in)

create

public int create(java.lang.String[] data,
                  java.lang.String clientId)
           throws DuplicateKeyException,
                  ClientNotLoggedInException,
                  java.rmi.RemoteException
Creates a new record in the database (possibly reusing a deleted entry). Inserts the given data, and returns the record number of the new record.

Parameters:
data - the array string representig values of the fields of the new record
clientId - the unique identifier of the clienent thet is performing request
Returns:
index of the newly created record
Throws:
DuplicateKeyException - - thrown when record could not be created
java.rmi.RemoteException - - required for remote access
ClientNotLoggedInException - - is thrown when client login passed as argument is not a valid client login (e.g. client has not been logged in)

lock

public void lock(int recNo,
                 java.lang.String clientId)
          throws RecordNotFoundException,
                 ClientNotLoggedInException,
                 java.rmi.RemoteException
Locks a record so that it can only be updated or deleted by this client. If the specified record is already locked, the current thread gives up the CPU and consumes no CPU cycles until the record is unlocked.

Parameters:
recNo - the index of the record to lock
clientId - the unique identifier of the clienent thet is performing request
Throws:
RecordNotFoundException - is thrown if a specified record does not exist or is marked as deleted in the database file.
java.rmi.RemoteException - - required for remote access
ClientNotLoggedInException - - is thrown when client login passed as argument is not a valid client login (e.g. client has not been logged in)

unlock

public void unlock(int recNo,
                   java.lang.String clientId)
            throws RecordNotFoundException,
                   ClientNotLoggedInException,
                   java.rmi.RemoteException
Releases the lock on a record.

Parameters:
recNo - the index of the record to lock
clientId - the unique identifier of the clienent thet is performing request
Throws:
RecordNotFoundException - is thrown if a specified record does not exist or is marked as deleted in the database file.
java.rmi.RemoteException - - required for remote access
ClientNotLoggedInException - - is thrown when client login passed as argument is not a valid client login (e.g. client has not been logged in)

isLocked

public boolean isLocked(int recNo,
                        java.lang.String clientId)
                 throws RecordNotFoundException,
                        ClientNotLoggedInException,
                        java.rmi.RemoteException
Determines if a record is currenly locked. Returns true if the record is locked, false otherwise.

Parameters:
recNo - the index of the record to check
clientId - the unique identifier of the clienent thet is performing request
Throws:
RecordNotFoundException - is thrown if a specified record does not exist or is marked as deleted in the database file.
java.rmi.RemoteException - - required for remote access
ClientNotLoggedInException - - is thrown when client login passed as argument is not a valid client login (e.g. client has not been logged in)

logIn

public java.lang.String logIn()
                       throws java.rmi.RemoteException
The method performs client login it is required as server needs to identify clients

Returns:
uniqe identifier that is required for all dataBase action invocations
Throws:
java.rmi.RemoteException - - required for remote access

logOut

public void logOut(java.lang.String clientId)
            throws java.rmi.RemoteException,
                   ClientNotLoggedInException
The method performs client logout - no others connections with such login will be available

Parameters:
clientId - uniqe client identifier
Throws:
java.rmi.RemoteException - - required for remote access
ClientNotLoggedInException - - is thrown when client login passed as argument is not a valid client login (e.g. client has not been logged in)

logIn

public void logIn(java.lang.String string)
           throws java.rmi.RemoteException
The method performs client login it is required as server needs to identify clients

Parameters:
string - client login
Throws:
java.rmi.RemoteException - - required for remote access