tigase.db

## Interface UserRepository

- All Known Implementing Classes:
    DummyRepository, JDBCRepository, UserRepositoryMDImpl, UserRepositoryPool, XMLRepository

      public interface UserRepository

  `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

  Version:
    $Rev$
  Author:
    Artur Hefczyc

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addDataList(tigase.xmpp.BareJID 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` | `addUser(tigase.xmpp.BareJID user)` This `addUser` method allows to add new user to repository.
    `String` | `getData(tigase.xmpp.BareJID user, String key)` `getData` method returns a value associated with given key for user repository in default subnode.
    `String` | `getData(tigase.xmpp.BareJID user, String subnode, String key)` `getData` method returns a value associated with given key for user repository in given subnode.
    `String` | `getData(tigase.xmpp.BareJID user, String subnode, String key, String def)` `getData` method returns a value associated with given key for user repository in given subnode.
    `String[]` | `getDataList(tigase.xmpp.BareJID 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(tigase.xmpp.BareJID user)` `getKeys` method returns list of all keys stored in default user repository node.
    `String[]` | `getKeys(tigase.xmpp.BareJID user, String subnode)` `getKeys` method returns list of all keys stored in given subnode in user repository.
    `String` | `getResourceUri()` Returns a DB connection string or DB connection URI.
    `String[]` | `getSubnodes(tigase.xmpp.BareJID user)` `getSubnodes` method returns list of all root nodes for given user.
    `String[]` | `getSubnodes(tigase.xmpp.BareJID user, String subnode)` `getSubnodes` method returns list of all direct subnodes from given node.
    `List<tigase.xmpp.BareJID>` | `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.
    `long` | `getUserUID(tigase.xmpp.BareJID user)` Returns a user unique ID number within the given repository.
    `void` | `initRepository(String resource_uri, Map<String,String> params)` The method is called to initialize the data repository.
    `void` | `removeData(tigase.xmpp.BareJID user, String key)` `removeData` method removes pair (key, value) from user repository in default repository node.
    `void` | `removeData(tigase.xmpp.BareJID user, String subnode, String key)` `removeData` method removes pair (key, value) from user repository in given subnode.
    `void` | `removeSubnode(tigase.xmpp.BareJID 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(tigase.xmpp.BareJID user)` This `removeUser` method allows to remove user and all his data from user repository.
    `void` | `setData(tigase.xmpp.BareJID 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(tigase.xmpp.BareJID 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(tigase.xmpp.BareJID 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.
    `boolean` | `userExists(tigase.xmpp.BareJID user)` Method `userExists` checks whether the user (or repository top node) exists in the database.

- - ### Method Detail

    - #### addDataList

          void addDataList(tigase.xmpp.BareJID user,
                         String subnode,
                         String key,
                         String[] list)
                           throws UserNotFoundException,
                                  TigaseDBException

      `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.
      Parameters:
        `user` - a `BareJID` 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.

    - #### addUser

          void addUser(tigase.xmpp.BareJID user)
                       throws UserExistsException,
                              TigaseDBException

      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.
      Parameters:
        `user` - a `BareJID` 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.

    - #### getData

          String getData(tigase.xmpp.BareJID user,
                       String subnode,
                       String key,
                       String def)
                         throws UserNotFoundException,
                                TigaseDBException

      `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.
      Parameters:
        `user` - a `BareJID` 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

          String getData(tigase.xmpp.BareJID user,
                       String subnode,
                       String key)
                         throws UserNotFoundException,
                                TigaseDBException

      `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.
      Parameters:
        `user` - a `BareJID` 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

          String getData(tigase.xmpp.BareJID user,
                       String key)
                         throws UserNotFoundException,
                                TigaseDBException

      `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.
      Parameters:
        `user` - a `BareJID` 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.

    - #### getDataList

          String[] getDataList(tigase.xmpp.BareJID user,
                             String subnode,
                             String key)
                               throws UserNotFoundException,
                                      TigaseDBException

      `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.
      Parameters:
        `user` - a `BareJID` 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.

    - #### getKeys

          String[] getKeys(tigase.xmpp.BareJID user,
                         String subnode)
                           throws UserNotFoundException,
                                  TigaseDBException

      `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.
      Parameters:
        `user` - a `BareJID` 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

          String[] getKeys(tigase.xmpp.BareJID user)
                           throws UserNotFoundException,
                                  TigaseDBException

      `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.
      Parameters:
        `user` - a `BareJID` value 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 `String` value representing database connection string.

    - #### getSubnodes

          String[] getSubnodes(tigase.xmpp.BareJID user,
                             String subnode)
                               throws UserNotFoundException,
                                      TigaseDBException

      `getSubnodes` method returns list of all direct subnodes from given node.
      Parameters:
        `user` - a `BareJID` 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

          String[] getSubnodes(tigase.xmpp.BareJID user)
                               throws UserNotFoundException,
                                      TigaseDBException

      `getSubnodes` method returns list of all root nodes for given user.
      Parameters:
        `user` - a `BareJID` 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.

    - #### getUserUID

          long getUserUID(tigase.xmpp.BareJID user)
                          throws TigaseDBException

      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` - a `BareJID` value 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

          List<tigase.xmpp.BareJID> getUsers()
                                             throws TigaseDBException

      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 `long` number of registered users in the repository.

    - #### getUsersCount

          long getUsersCount(String domain)

      This method is only used by the server statistics component to report number of registered users for given domain.
      Parameters:
        `domain` -
      Returns:
        a `long` number of registered users in the repository.

    - #### initRepository

          void initRepository(String resource_uri,
                            Map<String,String> params)
                              throws DBInitException

      The method is called to initialize the data repository. Depending on the implementation all the initialization parameters can be passed either via `resource_uri` parameter as the database connection string or via `params` map if the required repository parameters are more complex or both.
      Parameters:
        `resource_uri` - value in most cases representing the database connection string.
        `params` - is a `Map` with repository properties necessary to initialize and perform all the functions. The initialization parameters are implementation dependent.
      Throws:
        `DBInitException` - if there was an error during repository initialization. Some implementations, though, perform so called lazy initialization so even though there is a problem with the underlying repository it may not be signaled through this method call.

    - #### removeData

          void removeData(tigase.xmpp.BareJID user,
                        String subnode,
                        String key)
                          throws UserNotFoundException,
                                 TigaseDBException

      `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.
      Parameters:
        `user` - a `BareJID` 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

          void removeData(tigase.xmpp.BareJID user,
                        String key)
                          throws UserNotFoundException,
                                 TigaseDBException

      `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.
      Parameters:
        `user` - a `BareJID` 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

          void removeSubnode(tigase.xmpp.BareJID user,
                           String subnode)
                             throws UserNotFoundException,
                                    TigaseDBException

      `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.
      Parameters:
        `user` - a `BareJID` 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.

    - #### removeUser

          void removeUser(tigase.xmpp.BareJID user)
                          throws UserNotFoundException,
                                 TigaseDBException

      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.
      Parameters:
        `user` - a `BareJID` 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.

    - #### setData

          void setData(tigase.xmpp.BareJID user,
                     String subnode,
                     String key,
                     String value)
                       throws UserNotFoundException,
                              TigaseDBException

      `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.
      Parameters:
        `user` - a `BareJID` 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

          void setData(tigase.xmpp.BareJID user,
                     String key,
                     String value)
                       throws UserNotFoundException,
                              TigaseDBException

      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.
      Parameters:
        `user` - a `BareJID` 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

          void setDataList(tigase.xmpp.BareJID user,
                         String subnode,
                         String key,
                         String[] list)
                           throws UserNotFoundException,
                                  TigaseDBException

      `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.
      Parameters:
        `user` - a `BareJID` 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.

    - #### userExists

          boolean userExists(tigase.xmpp.BareJID user)

      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.
      Parameters:
        `user` - a `BareJID` value
      Returns:
        a `boolean` value

Copyright © 2014 "Tigase, Inc.". All rights reserved.