tigase.db
Class UserRepositoryPool

java.lang.Object
  extended by tigase.db.UserRepositoryPool
All Implemented Interfaces:
UserRepository

public class UserRepositoryPool
extends Object
implements UserRepository

Created: Jan 28, 2009 8:46:53 PM

Version:
$Rev$
Author:
Artur Hefczyc

Constructor Summary
UserRepositoryPool()
           
 
Method Summary
 void addDataList(String user, String subnode, String key, String[] list)
          addDataList method adds mode entries to existing data list associated with given key in repository under given node path.
 void addRepo(UserRepository repo)
           
 void addUser(String user)
          This addUser method allows to add new user to repository.
 String getData(String user, String key)
          getData method returns a value associated with given key for user repository in default subnode.
 String getData(String user, String subnode, String key)
          getData method returns a value associated with given key for user repository in given subnode.
 String getData(String user, String subnode, String key, String def)
          getData method returns a value associated with given key for user repository in given subnode.
 String[] getDataList(String user, String subnode, String key)
          getDataList method returns array of values associated with given key or null if given key does not exist for given user ID in given node path.
 String[] getKeys(String user)
          getKeys method returns list of all keys stored in default user repository node.
 String[] getKeys(String user, String subnode)
          getKeys method returns list of all keys stored in given subnode in user repository.
 String getResourceUri()
           
 String[] getSubnodes(String user)
          getSubnodes method returns list of all root nodes for given user.
 String[] getSubnodes(String user, String subnode)
          getSubnodes method returns list of all direct subnodes from given node.
 List<String> getUsers()
          This method is only used by the data conversion tools.
 long getUsersCount()
          This method is only used by the server statistics component to report number of registered users.
 long getUsersCount(String domain)
          This method is only used by the server statistics component to report number of registered users for given domain.
 void initRepository(String resource_uri, Map<String,String> params)
           
 void removeData(String user, String key)
          removeData method removes pair (key, value) from user repository in default repository node.
 void removeData(String user, String subnode, String key)
          removeData method removes pair (key, value) from user repository in given subnode.
 void removeSubnode(String user, String subnode)
          removeSubnode method removes given subnode with all subnodes in this node and all data stored in this node and in all subnodes.
 void removeUser(String user)
          This removeUser method allows to remove user and all his data from user repository.
 void setData(String user, String key, String value)
          This setData method sets data value for given user ID associated with given key in default repository node.
 void setData(String user, String subnode, String key, String value)
          setData method sets data value for given user ID in repository under given node path and associates it with given key.
 void setDataList(String user, String subnode, String key, String[] list)
          setDataList method sets list of values for given user associated given key in repository under given node path.
 UserRepository takeRepo()
           
 boolean userExists(String user)
          Method userExists checks whether the user (or repository top node) exists in the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserRepositoryPool

public UserRepositoryPool()
Method Detail

addRepo

public void addRepo(UserRepository repo)

takeRepo

public UserRepository takeRepo()

initRepository

public void initRepository(String resource_uri,
                           Map<String,String> params)
                    throws DBInitException
Specified by:
initRepository in interface UserRepository
Throws:
DBInitException

getResourceUri

public String getResourceUri()
Specified by:
getResourceUri in interface UserRepository
Returns:

getUsers

public List<String> getUsers()
                      throws TigaseDBException
Description copied from interface: UserRepository
This method is only used by the data conversion tools. They attempt to copy whole user repositories from one to another database. Databases might not be compatible but as long as the API is implemented and they support adding user the user database can be copied to a different data source.

Specified by:
getUsers in interface UserRepository
Returns:
returns a collection of all user IDs (Jabber IDs) stored in the user repository.
Throws:
TigaseDBException

getUsersCount

public long getUsersCount()
Description copied from interface: UserRepository
This method is only used by the server statistics component to report number of registered users.

Specified by:
getUsersCount in interface UserRepository
Returns:
a long number of registered users in the repository.

userExists

public boolean userExists(String user)
Description copied from interface: UserRepository
Method userExists checks whether the user (or repository top node) exists in the database. The method doesn't throw any exception nor it creates the user in case it is missing. It just checks whether the user is already in the database. Please don't overuse this method. All other methods throw UserNotFoundException exception in case the user is missing for which you executed the method. The exception is thrown unless userAutoCreate property is set to true. In such case the exception is never thrown and the methods are executed for given parameters prior to creating user entry if it is missing. Therefore this method should be used only to check whether the account exists without creating it.

Specified by:
userExists in interface UserRepository
Parameters:
user - a String value
Returns:
a boolean value

addUser

public void addUser(String user)
             throws UserExistsException,
                    TigaseDBException
Description copied from interface: UserRepository
This addUser method allows to add new user to repository. It must throw en exception UserExistsException if such user already exists because user must be unique within user repository data base.
As one XMPP server can support many virtual internet domains it is required that user id consists of user name and domain address: username@domain.address.net for example.

Specified by:
addUser in interface UserRepository
Parameters:
user - a String value of user id consisting of user name and domain address.
Throws:
UserExistsException - if user with the same id already exists.
TigaseDBException - if database backend error occurs.

removeUser

public void removeUser(String user)
                throws UserNotFoundException,
                       TigaseDBException
Description copied from interface: UserRepository
This removeUser method allows to remove user and all his data from user repository. If given user id does not exist UserNotFoundException must be thrown. As one XMPP server can support many virtual internet domains it is required that user id consists of user name and domain address: username@domain.address.net for example.

Specified by:
removeUser in interface UserRepository
Parameters:
user - a String value of user id consisting of user name and domain address.
Throws:
UserNotFoundException - if user id hasn't been found in repository.
TigaseDBException - if database backend error occurs.

getDataList

public String[] getDataList(String user,
                            String subnode,
                            String key)
                     throws UserNotFoundException,
                            TigaseDBException
Description copied from interface: UserRepository
getDataList method returns array of values associated with given key or null if given key does not exist for given user ID in given node path.

Specified by:
getDataList in interface UserRepository
Parameters:
user - a String value of user ID for which data must be stored. User ID consists of user name and domain name.
subnode - a String value is a node path where data is stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2
.
key - a String with which the needed values list is associated.
Returns:
a String[] value
Throws:
UserNotFoundException - if user id hasn't been found in repository.
TigaseDBException - if database backend error occurs.

getData

public String getData(String user,
                      String subnode,
                      String key,
                      String def)
               throws UserNotFoundException,
                      TigaseDBException
Description copied from interface: UserRepository
getData method returns a value associated with given key for user repository in given subnode. If key is not found in repository given default value is returned.

Specified by:
getData in interface UserRepository
Parameters:
user - a String value of user ID for which data must be stored. User ID consists of user name and domain name.
subnode - a String value is a node path where data is stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2
.
key - a String with which the needed value is associated.
def - a String value which is returned in case if data for specified key does not exixist in repository.
Returns:
a String value
Throws:
UserNotFoundException - if user id hasn't been found in repository.
TigaseDBException - if database backend error occurs.

getData

public String getData(String user,
                      String subnode,
                      String key)
               throws UserNotFoundException,
                      TigaseDBException
Description copied from interface: UserRepository
getData method returns a value associated with given key for user repository in given subnode. If key is not found in repository null value is returned.

Specified by:
getData in interface UserRepository
Parameters:
user - a String value of user ID for which data must be stored. User ID consists of user name and domain name.
subnode - a String value is a node path where data is stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2
.
key - a String with which the needed value is associated.
Returns:
a String value
Throws:
UserNotFoundException - if user id hasn't been found in repository.
TigaseDBException - if database backend error occurs.

getData

public String getData(String user,
                      String key)
               throws UserNotFoundException,
                      TigaseDBException
Description copied from interface: UserRepository
getData method returns a value associated with given key for user repository in default subnode. If key is not found in repository null value is returned.

Specified by:
getData in interface UserRepository
Parameters:
user - a String value of user ID for which data must be stored. User ID consists of user name and domain name.
key - a String with which the needed value is associated.
Returns:
a String value
Throws:
UserNotFoundException - if user id hasn't been found in repository.
TigaseDBException - if database backend error occurs.

getSubnodes

public String[] getSubnodes(String user,
                            String subnode)
                     throws UserNotFoundException,
                            TigaseDBException
Description copied from interface: UserRepository
getSubnodes method returns list of all direct subnodes from given node.

Specified by:
getSubnodes in interface UserRepository
Parameters:
user - a String value of user ID for which data must be stored. User ID consists of user name and domain name.
subnode - a String value is a node path where data is stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2
.
Returns:
a String[] value is an array of all direct subnodes.
Throws:
UserNotFoundException - if user id hasn't been found in repository.
TigaseDBException - if database backend error occurs.

getSubnodes

public String[] getSubnodes(String user)
                     throws UserNotFoundException,
                            TigaseDBException
Description copied from interface: UserRepository
getSubnodes method returns list of all root nodes for given user.

Specified by:
getSubnodes in interface UserRepository
Parameters:
user - a String value of user ID for which data must be stored. User ID consists of user name and domain name.
Returns:
a String[] value is an array of all root nodes for given user.
Throws:
UserNotFoundException - if user id hasn't been found in repository.
TigaseDBException - if database backend error occurs.

getKeys

public String[] getKeys(String user,
                        String subnode)
                 throws UserNotFoundException,
                        TigaseDBException
Description copied from interface: UserRepository
getKeys method returns list of all keys stored in given subnode in user repository. There is a value (or list of values) associated with each key. It is up to user (developer) to know what key keeps one value and what key keeps list of values.

Specified by:
getKeys in interface UserRepository
Parameters:
user - a String value of user ID for which data must be stored. User ID consists of user name and domain name.
subnode - a String value is a node path where data is stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2
.
Returns:
a String[] value
Throws:
UserNotFoundException - if user id hasn't been found in repository.
TigaseDBException - if database backend error occurs.

getKeys

public String[] getKeys(String user)
                 throws UserNotFoundException,
                        TigaseDBException
Description copied from interface: UserRepository
getKeys method returns list of all keys stored in default user repository node. There is some a value (or list of values) associated with each key. It is up to user (developer) to know what key keeps one value and what key keeps list of values.

Specified by:
getKeys in interface UserRepository
Parameters:
user - a String value of user ID for which data must be stored. User ID consists of user name and domain name.
Returns:
a String[] value
Throws:
UserNotFoundException - if user id hasn't been found in repository.
TigaseDBException - if database backend error occurs.

removeData

public void removeData(String user,
                       String subnode,
                       String key)
                throws UserNotFoundException,
                       TigaseDBException
Description copied from interface: UserRepository
removeData method removes pair (key, value) from user repository in given subnode. If the key exists in user repository there is always a value associated with this key - even empty String. If key does not exist the null value is returned from repository backend or given default value.

Specified by:
removeData in interface UserRepository
Parameters:
user - a String value of user ID for which data must be stored. User ID consists of user name and domain name.
subnode - a String value is a node path where data is stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2
.
key - a String for which the value is to be removed.
Throws:
UserNotFoundException - if user id hasn't been found in repository.
TigaseDBException - if database backend error occurs.

removeData

public void removeData(String user,
                       String key)
                throws UserNotFoundException,
                       TigaseDBException
Description copied from interface: UserRepository
removeData method removes pair (key, value) from user repository in default repository node. If the key exists in user repository there is always a value associated with this key - even empty String. If key does not exist the null value is returned from repository backend or given default value.

Specified by:
removeData in interface UserRepository
Parameters:
user - a String value of user ID for which data must be stored. User ID consists of user name and domain name.
key - a String for which the value is to be removed.
Throws:
UserNotFoundException - if user id hasn't been found in repository.
TigaseDBException - if database backend error occurs.

removeSubnode

public void removeSubnode(String user,
                          String subnode)
                   throws UserNotFoundException,
                          TigaseDBException
Description copied from interface: UserRepository
removeSubnode method removes given subnode with all subnodes in this node and all data stored in this node and in all subnodes. Effectively it removes entire repository tree starting from given node.

Specified by:
removeSubnode in interface UserRepository
Parameters:
user - a String value of user ID for which data must be stored. User ID consists of user name and domain name.
subnode - a String value is a node path to subnode which has to be removed. Node path has the same form as directory path on file system:
/root/subnode1/subnode2
.
Throws:
UserNotFoundException - if user id hasn't been found in repository.
TigaseDBException - if database backend error occurs.

setData

public void setData(String user,
                    String subnode,
                    String key,
                    String value)
             throws UserNotFoundException,
                    TigaseDBException
Description copied from interface: UserRepository
setData method sets data value for given user ID in repository under given node path and associates it with given key. If there already exists value for given key in given node, old value is replaced with new value. No warning or exception is thrown in case if methods overwrites old value.

Specified by:
setData in interface UserRepository
Parameters:
user - a String value of user ID for which data must be stored. User ID consists of user name and domain name.
subnode - a String value is a node path where data is stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2
.
key - a String with which the specified value is to be associated.
value - a String value to be associated with the specified key.
Throws:
UserNotFoundException - if user id hasn't been found in repository.
TigaseDBException - if database backend error occurs.

setData

public void setData(String user,
                    String key,
                    String value)
             throws UserNotFoundException,
                    TigaseDBException
Description copied from interface: UserRepository
This setData method sets data value for given user ID associated with given key in default repository node. Default node is dependent on implementation and usually it is root user node. If there already exists value for given key in given node, old value is replaced with new value. No warning or exception is thrown in case if methods overwrites old value.

Specified by:
setData in interface UserRepository
Parameters:
user - a String value of user ID for which data must be stored. User ID consists of user name and domain name.
key - a String with which the specified value is to be associated.
value - a String value to be associated with the specified key.
Throws:
UserNotFoundException - if user id hasn't been found in repository.
TigaseDBException - if database backend error occurs.

setDataList

public void setDataList(String user,
                        String subnode,
                        String key,
                        String[] list)
                 throws UserNotFoundException,
                        TigaseDBException
Description copied from interface: UserRepository
setDataList method sets list of values for given user associated given key in repository under given node path. If there already exist values for given key in given node, all old values are replaced with new values. No warning or exception is thrown in case if methods overwrites old value.

Specified by:
setDataList in interface UserRepository
Parameters:
user - a String value of user ID for which data must be stored. User ID consists of user name and domain name.
subnode - a String value is a node path where data is stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2
.
key - a String with which the specified values list is to be associated.
list - a String[] is an array of values to be associated with the specified key.
Throws:
UserNotFoundException - if user id hasn't been found in repository.
TigaseDBException - if database backend error occurs.

addDataList

public void addDataList(String user,
                        String subnode,
                        String key,
                        String[] list)
                 throws UserNotFoundException,
                        TigaseDBException
Description copied from interface: UserRepository
addDataList method adds mode entries to existing data list associated with given key in repository under given node path. This method is very similar to setDataList(...) except it doesn't remove existing data.

Specified by:
addDataList in interface UserRepository
Parameters:
user - a String value of user ID for which data must be stored. User ID consists of user name and domain name.
subnode - a String value is a node path where data is stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2
.
key - a String with which the specified values list is to be associated.
list - a String[] is an array of values to be associated with the specified key.
Throws:
UserNotFoundException - if user id hasn't been found in repository.
TigaseDBException - if database backend error occurs.

getUsersCount

public long getUsersCount(String domain)
Description copied from interface: UserRepository
This method is only used by the server statistics component to report number of registered users for given domain.

Specified by:
getUsersCount in interface UserRepository
Returns:
a long number of registered users in the repository.


Copyright © 2001-2006 Tigase Developers Team. All rights Reserved.