CFEngine API

org.recommender.clients.console
Class ClientDBManager

java.lang.Object
  |
  +--org.recommender.clients.console.ClientDBManager

public class ClientDBManager
extends java.lang.Object

Created by User: herlock Date: Apr 16, 2003 Time: 8:49:26 AM


Method Summary
 int clientAddNewUser(User user)
          Adds the user to the database and returns the assigned userid for this user.
 Item clientLookupItem(int itemId)
          Check whether there is a client-side record for an item with this server id.
 Item clientLookupItem(java.lang.String itemName)
          Check whether there is a Item with this name.
 Type clientLookupType(int id)
           
 Type clientLookupType(java.lang.String typeName)
           
 Type clientLookupType(java.lang.String typeName, int id)
          Check whether there is a Item with this name.
 User clientLookupUser(int userId)
          Returns a User object with all User information
 User clientLookupUser(java.lang.String userName)
          Returns a User object with all User information
 User clientLookupUser(java.lang.String userName, int userId)
          Returns a User object with all User information returns NULL if invalid user or password is incorrect.
 java.util.Vector clientRetrieveAllItems()
          Returns a vector of names of all items that the client knows about.
 void getConnection()
          Get connection with database and cache it in a private instance variable.
static ClientDBManager getInstance()
           
 java.util.Vector retrieveUserVector()
          Fill an array with all the current usernames from the client database.
 java.util.Vector retriveAllTypes()
          Gets a list of all the types that the client is currently aware of
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ClientDBManager getInstance()

getConnection

public void getConnection()
                   throws java.sql.SQLException
Get connection with database and cache it in a private instance variable. Upon return from this function, there should be a 99% guarantee that the connection is still valid. // @todo - should also check to see if cached connection still works

Throws:
java.sql.SQLException

retriveAllTypes

public java.util.Vector retriveAllTypes()
Gets a list of all the types that the client is currently aware of

Returns:
- An array of Types.

clientLookupItem

public Item clientLookupItem(int itemId)
Check whether there is a client-side record for an item with this server id.

Parameters:
itemId - - cfengine server itemid for the item
Returns:
a populated Item object

clientLookupItem

public Item clientLookupItem(java.lang.String itemName)
                      throws ClientNoSuchItemException
Check whether there is a Item with this name.

Parameters:
itemName -
Returns:
a populated Item object
Throws:
ClientNoSuchItemException

clientLookupType

public Type clientLookupType(java.lang.String typeName,
                             int id)
Check whether there is a Item with this name. Exactly one of the parameters is used.

Parameters:
typeName - - name of the type. Null indicates id should be used instead.
id - - id of the type. Ignored if typename is non-null.
Returns:
a populated Type object

clientLookupType

public Type clientLookupType(java.lang.String typeName)

clientLookupType

public Type clientLookupType(int id)

retrieveUserVector

public java.util.Vector retrieveUserVector()
Fill an array with all the current usernames from the client database.


clientLookupUser

public User clientLookupUser(java.lang.String userName)
Returns a User object with all User information

Parameters:
userName - Client-side username.
Returns:
new User - null if userName does not exist

clientLookupUser

public User clientLookupUser(int userId)
Returns a User object with all User information

Parameters:
userId - server-side userId.
Returns:
new User - null if userId does not exist in client database

clientLookupUser

public User clientLookupUser(java.lang.String userName,
                             int userId)
Returns a User object with all User information returns NULL if invalid user or password is incorrect. If userName is null, the lookup is done by userId, otherwise userId is ignored.

Parameters:
userName - - null if this is a lookup by userID
userId - - ignored if userName is non-null
Returns:
new User.

clientAddNewUser

public int clientAddNewUser(User user)
Adds the user to the database and returns the assigned userid for this user.

Parameters:
user -
Returns:
userID - returns -1 if unable to add the user user.

clientRetrieveAllItems

public java.util.Vector clientRetrieveAllItems()
Returns a vector of names of all items that the client knows about.

Returns:
A vector of Strings - each the name of one item

CFEngine API

Copyright © 2003 - Oregon State University www.orst.edu