Package tigase.db
Interface UserRepository
- All Superinterfaces:
Repository
- All Known Implementing Classes:
DummyRepository,JDBCRepository,UserRepositoryMDImpl,UserRepositoryMDPoolBean,UserRepositoryPool,XMLRepository
UserRepository interface defines all functionalities required to store user data. It contains adding,
removing and searching methods. User repository is organized as hierarchical data base. It means you can add items to
repository on different levels like files in file systems. Instead, however of working with directories you work with
nodes. You can create many levels of nodes and store data on any level. It helps to organize data in more logical
order.
Created: Tue Oct 26 15:09:28 2004
- Author:
- Artur Hefczyc
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic classNested classes/interfaces inherited from interface tigase.db.Repository
Repository.Meta, Repository.SchemaId -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDataList(BareJID user, String subnode, String key, String[] list) addDataListmethod adds mode entries to existing data list associated with given key in repository under given node path.voidThisaddUsermethod allows to add new user to repository.getDatamethod returns a value associated with given key for user repository in default subnode.getDatamethod returns a value associated with given key for user repository in given subnode.getDatamethod returns a value associated with given key for user repository in given subnode.String[]getDataList(BareJID user, String subnode, String key) getDataListmethod returns array of values associated with given key ornullif given key does not exist for given user ID in given node path.getDataMap(@NonNull String key) getDataMap(BareJID user, String subnode) getDataMapmethod returns a values associated with each key for user repository in given subnode.getDataMap(BareJID user, String subnode, Function<String, T> converter) getDataMapmethod returns a values associated with each key for user repository in given subnode.String[]getKeysmethod returns list of all keys stored in default user repository node.String[]getKeysmethod returns list of all keys stored in given subnode in user repository.Returns a DB connection string or DB connection URI.String[]getSubnodes(BareJID user) getSubnodesmethod returns list of all root nodes for given user.String[]getSubnodes(BareJID user, String subnode) Deprecated.getUsers()This method is only used by the data conversion tools.longThis method is only used by the server statistics component to report number of registered users.longgetUsersCount(String domain) This method is only used by the server statistics component to report number of registered users for given domain.longgetUserUID(BareJID user) Deprecated.voidremoveData(BareJID user, String key) removeDatamethod removes pair (key, value) from user repository in default repository node.voidremoveData(BareJID user, String subnode, String key) removeDatamethod removes pair (key, value) from user repository in given subnode.voidremoveSubnode(BareJID user, String subnode) removeSubnodemethod removes given subnode with all subnodes in this node and all data stored in this node and in all subnodes.voidremoveUser(BareJID user) ThisremoveUsermethod allows to remove user and all his data from user repository.voidThissetDatamethod sets data value for given user ID associated with given key in default repository node.voidsetDatamethod sets data value for given user ID in repository under given node path and associates it with given key.voidsetDataList(BareJID user, String subnode, String key, String[] list) setDataListmethod sets list of values for given user associated given key in repository under given node path.booleanuserExists(BareJID user) MethoduserExistschecks whether the user (or repository top node) exists in the database.Methods inherited from interface tigase.db.Repository
initRepository
-
Method Details
-
addDataList
void addDataList(BareJID user, String subnode, String key, String[] list) throws UserNotFoundException, TigaseDBException addDataListmethod adds mode entries to existing data list associated with given key in repository under given node path. This method is very similar tosetDataList(...)except it doesn't remove existing data.- Parameters:
user- aBareJIDvalue of user ID for which data must be stored. User ID consists of user name and domain name.subnode- aStringvalue is a node path where data is stored. Node path has the same form as directory path on file system:/root/subnode1/subnode2
.key- aStringwith which the specified values list is to be associated.list- aString[]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.
-
addUser
ThisaddUsermethod allows to add new user to repository. It must throw en exceptionUserExistsExceptionif 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 thatuserid consists of user name and domain address: username@domain.address.net for example.- Parameters:
user- aBareJIDvalue 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.
-
getData
String getData(BareJID user, String subnode, String key, String def) throws UserNotFoundException, TigaseDBException getDatamethod 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.- Parameters:
user- aBareJIDvalue of user ID for which data must be stored. User ID consists of user name and domain name.subnode- aStringvalue is a node path where data is stored. Node path has the same form as directory path on file system:/root/subnode1/subnode2
.key- aStringwith which the needed value is associated.def- aStringvalue which is returned in case if data for specified key does not exixist in repository.- Returns:
- a
Stringvalue - Throws:
UserNotFoundException- if user id hasn't been found in repository.TigaseDBException- if database backend error occurs.
-
getData
String getData(BareJID user, String subnode, String key) throws UserNotFoundException, TigaseDBException getDatamethod returns a value associated with given key for user repository in given subnode. If key is not found in repositorynullvalue is returned.- Parameters:
user- aBareJIDvalue of user ID for which data must be stored. User ID consists of user name and domain name.subnode- aStringvalue is a node path where data is stored. Node path has the same form as directory path on file system:/root/subnode1/subnode2
.key- aStringwith which the needed value is associated.- Returns:
- a
Stringvalue - Throws:
UserNotFoundException- if user id hasn't been found in repository.TigaseDBException- if database backend error occurs.
-
getData
getDatamethod returns a value associated with given key for user repository in default subnode. If key is not found in repositorynullvalue is returned.- Parameters:
user- aBareJIDvalue of user ID for which data must be stored. User ID consists of user name and domain name.key- aStringwith which the needed value is associated.- Returns:
- a
Stringvalue - Throws:
UserNotFoundException- if user id hasn't been found in repository.TigaseDBException- if database backend error occurs.
-
getDataMap
default Map<String,String> getDataMap(BareJID user, String subnode) throws UserNotFoundException, TigaseDBException getDataMapmethod returns a values associated with each key for user repository in given subnode.- Parameters:
user- aBareJIDvalue of user ID for which data must be stored. User ID consists of user name and domain name.subnode- aStringvalue 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
Mapwith values - Throws:
UserNotFoundException- if user id hasn't been found in repository.TigaseDBException- if database backend error occurs.
-
getDataMap
default Map<BareJID,String> getDataMap(@NonNull String key) throws UserNotFoundException, TigaseDBException - Parameters:
key- key for which return of map of users and values corresponding to the value- Returns:
- a
Mapwith user JID as key and value corresponding to the key passed as parameter - Throws:
UserNotFoundException- if user id hasn't been found in repository.TigaseDBException- if database backend error occurs.
-
getDataMap
default <T> Map<String,T> getDataMap(BareJID user, String subnode, Function<String, T> converter) throws UserNotFoundException, TigaseDBExceptiongetDataMapmethod returns a values associated with each key for user repository in given subnode.- Parameters:
user- aBareJIDvalue of user ID for which data must be stored. User ID consists of user name and domain name.subnode- aStringvalue is a node path where data is stored. Node path has the same form as directory path on file system:/root/subnode1/subnode2
.converter- aFunctionwhich takes value for a key and converts to expected value type- Returns:
- a
Mapwith values - Throws:
UserNotFoundException- if user id hasn't been found in repository.TigaseDBException- if database backend error occurs.
-
getDataList
String[] getDataList(BareJID user, String subnode, String key) throws UserNotFoundException, TigaseDBException getDataListmethod returns array of values associated with given key ornullif given key does not exist for given user ID in given node path.- Parameters:
user- aBareJIDvalue of user ID for which data must be stored. User ID consists of user name and domain name.subnode- aStringvalue is a node path where data is stored. Node path has the same form as directory path on file system:/root/subnode1/subnode2
.key- aStringwith 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.
-
getKeys
getKeysmethod 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.- Parameters:
user- aBareJIDvalue of user ID for which data must be stored. User ID consists of user name and domain name.subnode- aStringvalue 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
getKeysmethod 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.- Parameters:
user- aBareJIDvalue of user ID for which data must be stored or retrieved. 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.
-
getResourceUri
String getResourceUri()Returns a DB connection string or DB connection URI.- Returns:
- a
Stringvalue representing database connection string.
-
getSubnodes
@Deprecated String[] getSubnodes(BareJID user, String subnode) throws UserNotFoundException, TigaseDBException Deprecated.getSubnodesmethod returns list of all direct subnodes from given node.- Parameters:
user- aBareJIDvalue of user ID for which data must be stored. User ID consists of user name and domain name.subnode- aStringvalue 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
getSubnodesmethod returns list of all root nodes for given user.- Parameters:
user- aBareJIDvalue 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.
-
getUserUID
Deprecated.Returns a user unique ID number within the given repository. Please note it is also possible that the ID number is unique only for the user domain. The ID is a positive number if the user exists and negative if the user was not found in the repository.- Parameters:
user- aBareJIDvalue of user ID for which data must be stored or retrieved. User ID consists of user name and domain name.- Returns:
- a user inique ID number within the repository or domain. The ID is a positive number if the user exists and negative if the user was not found in the repository.
- Throws:
TigaseDBException- if there is a problem with accessing user repository.
-
getUsers
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.- Returns:
- returns a collection of all user IDs (Jabber IDs) stored in the user repository.
- Throws:
TigaseDBException
-
getUsersCount
long getUsersCount()This method is only used by the server statistics component to report number of registered users.- Returns:
- a
longnumber of registered users in the repository.
-
getUsersCount
This method is only used by the server statistics component to report number of registered users for given domain.- Returns:
- a
longnumber of registered users in the repository.
-
removeData
void removeData(BareJID user, String subnode, String key) throws UserNotFoundException, TigaseDBException removeDatamethod 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 emptyString. If key does not exist thenullvalue is returned from repository backend or given default value.- Parameters:
user- aBareJIDvalue of user ID for which data must be stored. User ID consists of user name and domain name.subnode- aStringvalue is a node path where data is stored. Node path has the same form as directory path on file system:/root/subnode1/subnode2
.key- aStringfor 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
removeDatamethod 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 emptyString. If key does not exist thenullvalue is returned from repository backend or given default value.- Parameters:
user- aBareJIDvalue of user ID for which data must be stored. User ID consists of user name and domain name.key- aStringfor 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
removeSubnodemethod 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.- Parameters:
user- aBareJIDvalue of user ID for which data must be stored. User ID consists of user name and domain name.subnode- aStringvalue 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.
-
removeUser
ThisremoveUsermethod allows to remove user and all his data from user repository. If given user id does not existUserNotFoundExceptionmust be thrown. As one XMPP server can support many virtual internet domains it is required thatuserid consists of user name and domain address: username@domain.address.net for example.- Parameters:
user- aBareJIDvalue 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.
-
setData
void setData(BareJID user, String subnode, String key, String value) throws UserNotFoundException, TigaseDBException setDatamethod 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.- Parameters:
user- aBareJIDvalue of user ID for which data must be stored. User ID consists of user name and domain name.subnode- aStringvalue is a node path where data is stored. Node path has the same form as directory path on file system:/root/subnode1/subnode2
.key- aStringwith which the specified value is to be associated.value- aStringvalue 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
void setData(BareJID user, String key, String value) throws UserNotFoundException, TigaseDBException ThissetDatamethod 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.- Parameters:
user- aBareJIDvalue of user ID for which data must be stored. User ID consists of user name and domain name.key- aStringwith which the specified value is to be associated.value- aStringvalue 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
void setDataList(BareJID user, String subnode, String key, String[] list) throws UserNotFoundException, TigaseDBException setDataListmethod 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.- Parameters:
user- aBareJIDvalue of user ID for which data must be stored. User ID consists of user name and domain name.subnode- aStringvalue is a node path where data is stored. Node path has the same form as directory path on file system:/root/subnode1/subnode2
.key- aStringwith which the specified values list is to be associated.list- aString[]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.
-
userExists
MethoduserExistschecks 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 throwUserNotFoundExceptionexception in case the user is missing for which you executed the method. The exception is thrown unlessuserAutoCreateproperty 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.- Parameters:
user- aBareJIDvalue- Returns:
- a
booleanvalue
-