tigase.db.xml

## Class XMLRepository

- java.lang.Object
- - tigase.db.xml.XMLRepository

- All Implemented Interfaces:
    AuthRepository, UserRepository

      public class XMLRepository
      extends Object
      implements AuthRepository, UserRepository

  Class `XMLRepository` is a XML implementation of `UserRepository`. It uses `tigase.xml.db` package as repository backend and uses Bridge design pattern to translate `XMLDB` calls to `UserRepository` functions.

  Created: Tue Oct 26 15:27:33 2004

  Version:
    $Rev$
  Author:
    Artur Hefczyc

- - ### Field Summary

    - ### Fields inherited from interface tigase.db.AuthRepository

      `DATA_KEY, DIGEST_ID_KEY, DIGEST_KEY, MACHANISM_KEY, PASSWORD_KEY, PROTOCOL_KEY, PROTOCOL_VAL_NONSASL, PROTOCOL_VAL_SASL, REALM_KEY, RESULT_KEY, SERVER_NAME_KEY, USER_ID_KEY, USERNAME_KEY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XMLRepository()`

  - ### 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.
    `void` | `addUser(tigase.xmpp.BareJID user, String password)` Describe `addUser` method here.
    `boolean` | `digestAuth(tigase.xmpp.BareJID user, String digest, String id, String alg)` Deprecated.
    `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()` Method description
    `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()` Method description
    `long` | `getUsersCount()` Method description
    `long` | `getUsersCount(String domain)` Method description
    `long` | `getUserUID(tigase.xmpp.BareJID user)` Method description
    `void` | `initRepository(String file, Map<String,String> params)` Method description
    `void` | `logout(tigase.xmpp.BareJID user)` Method description
    `boolean` | `otherAuth(Map<String,Object> props)` Describe `otherAuth` method here.
    `boolean` | `plainAuth(tigase.xmpp.BareJID user, String password)` Deprecated.
    `void` | `queryAuth(Map<String,Object> authProps)` Method description
    `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.
    `void` | `updatePassword(tigase.xmpp.BareJID user, String password)` Method description
    `boolean` | `userExists(tigase.xmpp.BareJID user)` Method description

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### XMLRepository

          public XMLRepository()

  - ### Method Detail

    - #### addDataList

          public 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.
      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:
        `TigaseDBException`
        `UserNotFoundException` - if user id hasn't been found in repository.

    - #### addUser

          public void addUser(tigase.xmpp.BareJID user)
                       throws UserExistsException

      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.

    - #### addUser

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

      Describe `addUser` method here.
      Specified by:
        `addUser` in interface `AuthRepository`
      Parameters:
        `user` - a `String` value
        `password` - a `String` value
      Throws:
        `UserExistsException` - if an error occurs
        `TigaseDBException` - if an error occurs

    - #### digestAuth

          @Deprecated
          public boolean digestAuth(tigase.xmpp.BareJID user,
                                      String digest,
                                      String id,
                                      String alg)
                             throws UserNotFoundException,
                                    TigaseDBException,
                                    AuthorizationException

      Deprecated.
      Describe `digestAuth` method here.
      Specified by:
        `digestAuth` in interface `AuthRepository`
      Parameters:
        `user` - a `String` value
        `digest` - a `String` value
        `id` - a `String` value
        `alg` - a `String` value
      Returns:
        a `boolean` value
      Throws:
        `AuthorizationException`
        `UserNotFoundException` - if an error occurs
        `TigaseDBException` - if an error occurs

    - #### getData

          public 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.
      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 exist in repository.
      Returns:
        a `String` value
      Throws:
        `TigaseDBException`
        `UserNotFoundException` - if user id hasn't been found in repository.

    - #### getData

          public 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.
      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:
        `TigaseDBException`
        `UserNotFoundException` - if user id hasn't been found in repository.

    - #### getData

          public 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.
      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:
        `TigaseDBException`
        `UserNotFoundException` - if user id hasn't been found in repository.

    - #### getDataList

          public 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.
      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:
        `TigaseDBException`
        `UserNotFoundException` - if user id hasn't been found in repository.

    - #### getKeys

          public 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.
      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:
        `TigaseDBException`
        `UserNotFoundException` - if user id hasn't been found in repository.

    - #### getKeys

          public 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.
      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:
        `TigaseDBException`
        `UserNotFoundException` - if user id hasn't been found in repository.

    - #### getResourceUri

          public String getResourceUri()

      Method description
      Specified by:
        `getResourceUri` in interface `AuthRepository`
      Specified by:
        `getResourceUri` in interface `UserRepository`
      Returns:

    - #### getSubnodes

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

      `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:
        `TigaseDBException`
        `UserNotFoundException` - if user id hasn't been found in repository.

    - #### getSubnodes

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

      `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:
        `TigaseDBException`
        `UserNotFoundException` - if user id hasn't been found in repository.

    - #### getUserUID

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

      Method description
      Specified by:
        `getUserUID` in interface `UserRepository`
      Parameters:
        `user` -
      Returns:
      Throws:
        `TigaseDBException`

    - #### getUsers

          public List<tigase.xmpp.BareJID> getUsers()

      Method description
      Specified by:
        `getUsers` in interface `UserRepository`
      Returns:

    - #### getUsersCount

          public long getUsersCount(String domain)

      Method description
      Specified by:
        `getUsersCount` in interface `AuthRepository`
      Specified by:
        `getUsersCount` in interface `UserRepository`
      Parameters:
        `domain` -
      Returns:

    - #### getUsersCount

          public long getUsersCount()

      Method description
      Specified by:
        `getUsersCount` in interface `AuthRepository`
      Specified by:
        `getUsersCount` in interface `UserRepository`
      Returns:

    - #### initRepository

          public void initRepository(String file,
                            Map<String,String> params)

      Method description
      Specified by:
        `initRepository` in interface `AuthRepository`
      Specified by:
        `initRepository` in interface `UserRepository`
      Parameters:
        `file` -
        `params` -

    - #### logout

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

      Method description
      Specified by:
        `logout` in interface `AuthRepository`
      Parameters:
        `user` -
      Throws:
        `TigaseDBException`
        `UserNotFoundException`

    - #### otherAuth

          public boolean otherAuth(Map<String,Object> props)
                            throws UserNotFoundException,
                                   TigaseDBException,
                                   AuthorizationException

      Describe `otherAuth` method here.
      Specified by:
        `otherAuth` in interface `AuthRepository`
      Parameters:
        `props` - a `Map` value
      Returns:
        a `boolean` value
      Throws:
        `UserNotFoundException` - if an error occurs
        `TigaseDBException` - if an error occurs
        `AuthorizationException` - if an error occurs

    - #### plainAuth

          @Deprecated
          public boolean plainAuth(tigase.xmpp.BareJID user,
                                     String password)
                            throws UserNotFoundException,
                                   TigaseDBException,
                                   AuthorizationException

      Deprecated.
      Describe `plainAuth` method here.
      Specified by:
        `plainAuth` in interface `AuthRepository`
      Parameters:
        `user` - a `String` value
        `password` - a `String` value
      Returns:
        a `boolean` value
      Throws:
        `AuthorizationException`
        `UserNotFoundException` - if an error occurs
        `TigaseDBException` - if an error occurs

    - #### queryAuth

          public void queryAuth(Map<String,Object> authProps)

      Method description
      Specified by:
        `queryAuth` in interface `AuthRepository`
      Parameters:
        `authProps` -

    - #### removeData

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

      `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.

    - #### removeData

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

      `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.

    - #### removeSubnode

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

      `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.

    - #### removeUser

          public void removeUser(tigase.xmpp.BareJID user)
                          throws UserNotFoundException

      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 `AuthRepository`
      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.

    - #### setData

          public 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.
      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:
        `TigaseDBException`
        `UserNotFoundException` - if user id hasn't been found in repository.

    - #### setData

          public 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.
      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:
        `TigaseDBException`
        `UserNotFoundException` - if user id hasn't been found in repository.

    - #### setDataList

          public 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.
      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:
        `TigaseDBException`
        `UserNotFoundException` - if user id hasn't been found in repository.

    - #### updatePassword

          public void updatePassword(tigase.xmpp.BareJID user,
                            String password)
                              throws UserExistsException,
                                     TigaseDBException

      Method description
      Specified by:
        `updatePassword` in interface `AuthRepository`
      Parameters:
        `user` -
        `password` -
      Throws:
        `TigaseDBException`
        `UserExistsException`
        `UserNotFoundException`

    - #### userExists

          public boolean userExists(tigase.xmpp.BareJID user)

      Method description
      Specified by:
        `userExists` in interface `UserRepository`
      Parameters:
        `user` -
      Returns:

Copyright © 2013 Tigase. All rights reserved.