tigase.xmpp

## Class RepositoryAccess

- java.lang.Object
- - tigase.xmpp.RepositoryAccess

- Direct Known Subclasses:
    XMPPResourceConnection

      public abstract class RepositoryAccess
      extends Object

  Describe class RepositoryAccess here. Created: Tue Oct 24 10:38:41 2006
  Version:
    $Rev$
  Author:
    Artur Hefczyc

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected AuthRepository` | `authRepo` Field description
    `protected Authorization` | `authState` Current authorization state - initialy session i `NOT_AUTHORIZED`.
    `protected VHostItem` | `domain` Field description
    `protected boolean` | `is_anonymous` Field description
    `protected static String` | `NO_ACCESS_TO_REP_MSG` Field description
    `protected static String` | `NOT_AUTHORIZED_MSG` Field description

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RepositoryAccess(UserRepository rep, AuthRepository auth)` Creates a new `RepositoryAccess` instance.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addDataList(String subnode, String key, String[] list)` Method description
    `void` | `addOfflineDataList(String subnode, String key, String[] list)` Method description
    `void` | `addPublicDataList(String subnode, String key, String[] list)` Method description
    `String` | `getAuthenticationToken(String xmpp_sessionId)` Method description
    `Authorization` | `getAuthState()` Gets the value of authState
    `abstract tigase.xmpp.BareJID` | `getBareJID()` Method description
    `String` | `getData(String subnode, String key, String def)` `getData` method is a twin sister (brother?) of `setData(String, String, String)` method.
    `String[]` | `getDataGroups(String subnode)` This method retrieves list of all direct subnodes for given node.
    `String[]` | `getDataKeys(String subnode)` This method returns all data keys available in permanent storage in given node.
    `String[]` | `getDataList(String subnode, String key)` This method allows to retrieve list of values associated with one key.
    `VHostItem` | `getDomain()` Method description
    `tigase.xmpp.JID` | `getDomainAsJID()` Method description
    `String` | `getOfflineData(String subnode, String key, String def)` Method description
    `String[]` | `getOfflineDataList(String subnode, String key)` Method description
    `String` | `getPublicData(String subnode, String key, String def)` Method description
    `String[]` | `getPublicDataList(String subnode, String key)` Method description
    `abstract String` | `getUserName()` Method description
    `boolean` | `isAnonymous()` Method description
    `boolean` | `isAuthorized()` This method allows you test this session if it already has been authorized.
    `protected abstract void` | `login()` Method description
    `Authorization` | `loginDigest(tigase.xmpp.BareJID userId, String digest, String id, String alg)` Deprecated.
    `Authorization` | `loginOther(Map<String,Object> props)` Deprecated.
    `Authorization` | `loginPlain(tigase.xmpp.BareJID userId, String password)` Deprecated.
    `Authorization` | `loginToken(tigase.xmpp.BareJID userId, String xmpp_sessionId, String token)` Deprecated.
    `void` | `logout()` Method description
    `void` | `queryAuth(Map<String,Object> authProps)` Method description
    `Authorization` | `register(String name_param, String pass_param, Map<String,String> reg_params)` Method description
    `Authorization` | `register(String name_param, String pass_param, String email_param)` Deprecated.
    `void` | `removeData(String subnode, String key)` Method description
    `void` | `removeDataGroup(String subnode)` Removes the last data node given in subnode path as parameter to this method.
    `void` | `removeOfflineData(String subnode, String key)` Method description
    `void` | `removeOfflineDataGroup(String subnode)` Method description
    `void` | `removePublicData(String subnode, String key)` Method description
    `void` | `removePublicDataGroup(String subnode)` Method description
    `void` | `setData(String subnode, String key, String value)` This method stores given data in permanent storage in given point of hierarchy of data base.
    `void` | `setDataList(String subnode, String key, String[] list)` This method allows to store list of values under one key ID reference.
    `void` | `setDomain(VHostItem domain)` Method description
    `void` | `setOfflineData(String subnode, String key, String value)` Method description
    `void` | `setOfflineDataList(String subnode, String key, String[] list)` Method description
    `void` | `setPublicData(String subnode, String key, String value)` Method description
    `void` | `setPublicDataList(String subnode, String key, String[] list)` Method description
    `Authorization` | `unregister(String name_param)` Method description

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

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

- - ### Field Detail

    - #### NO_ACCESS_TO_REP_MSG

          protected static final String NO_ACCESS_TO_REP_MSG

      Field description
      See Also:
        Constant Field Values

    - #### NOT_AUTHORIZED_MSG

          protected static final String NOT_AUTHORIZED_MSG

      Field description
      See Also:
        Constant Field Values

    - #### authRepo

          protected AuthRepository authRepo

      Field description

    - #### domain

          protected VHostItem domain

      Field description

    - #### is_anonymous

          protected boolean is_anonymous

      Field description

    - #### authState

          protected Authorization authState

      Current authorization state - initialy session i `NOT_AUTHORIZED`. It becomes `AUTHORIZED`

  - ### Constructor Detail

    - #### RepositoryAccess

          public RepositoryAccess(UserRepository rep,
                          AuthRepository auth)

      Creates a new `RepositoryAccess` instance.
      Parameters:
        `rep` -
        `auth` -

  - ### Method Detail

    - #### addDataList

          public void addDataList(String subnode,
                         String key,
                         String[] list)
                           throws NotAuthorizedException,
                                  TigaseDBException

      Method description
      Parameters:
        `subnode` -
        `key` -
        `list` -
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### addOfflineDataList

          public void addOfflineDataList(String subnode,
                                String key,
                                String[] list)
                                  throws NotAuthorizedException,
                                         TigaseDBException

      Method description
      Parameters:
        `subnode` -
        `key` -
        `list` -
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### addPublicDataList

          public void addPublicDataList(String subnode,
                               String key,
                               String[] list)
                                 throws NotAuthorizedException,
                                        TigaseDBException

      Method description
      Parameters:
        `subnode` -
        `key` -
        `list` -
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### loginDigest

          @Deprecated
          public Authorization loginDigest(tigase.xmpp.BareJID userId,
                                             String digest,
                                             String id,
                                             String alg)
                                    throws NotAuthorizedException,
                                           AuthorizationException,
                                           TigaseDBException

      Deprecated.
      Method description
      Parameters:
        `userId` -
        `digest` -
        `id` -
        `alg` -
      Returns:
        a value of `Authorization`
      Throws:
        `AuthorizationException`
        `NotAuthorizedException`
        `TigaseDBException`

    - #### loginOther

          @Deprecated
          public Authorization loginOther(Map<String,Object> props)
                                   throws NotAuthorizedException,
                                          AuthorizationException,
                                          TigaseDBException

      Deprecated.
      Method description
      Parameters:
        `props` -
      Returns:
        a value of `Authorization`
      Throws:
        `AuthorizationException`
        `NotAuthorizedException`
        `TigaseDBException`

    - #### loginPlain

          @Deprecated
          public Authorization loginPlain(tigase.xmpp.BareJID userId,
                                            String password)
                                   throws NotAuthorizedException,
                                          AuthorizationException,
                                          TigaseDBException

      Deprecated.
      `authorize` method performs authorization with given password as plain text. If `AUTHORIZED` has been returned it means authorization process is successful and session has been activated, otherwise session hasn't been authorized and return code gives more detailed information of fail reason. Please refer to `Authorization` documentation for more details.
      Parameters:
        `userId` -
        `password` -
      Returns:
        a `Authorization` value of result code.
      Throws:
        `NotAuthorizedException`
        `AuthorizationException`
        `TigaseDBException`

    - #### loginToken

          @Deprecated
          public Authorization loginToken(tigase.xmpp.BareJID userId,
                                            String xmpp_sessionId,
                                            String token)
                                   throws NotAuthorizedException,
                                          AuthorizationException,
                                          TigaseDBException

      Deprecated.
      Method description
      Parameters:
        `userId` -
        `xmpp_sessionId` -
        `token` -
      Returns:
        a value of `Authorization`
      Throws:
        `AuthorizationException`
        `NotAuthorizedException`
        `TigaseDBException`

    - #### logout

          public void logout()
                      throws NotAuthorizedException

      Method description
      Throws:
        `NotAuthorizedException`

    - #### queryAuth

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

      Method description
      Parameters:
        `authProps` -
      Throws:
        `TigaseDBException`

    - #### register

          @Deprecated
          public Authorization register(String name_param,
                                          String pass_param,
                                          String email_param)
                                 throws NotAuthorizedException,
                                        TigaseDBException,
                                        tigase.util.TigaseStringprepException

      Deprecated.
      Method description
      Parameters:
        `name_param` -
        `pass_param` -
        `email_param` -
      Returns:
        a value of `Authorization`
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`
        `tigase.util.TigaseStringprepException`

    - #### register

          public Authorization register(String name_param,
                               String pass_param,
                               Map<String,String> reg_params)
                                 throws NotAuthorizedException,
                                        TigaseDBException,
                                        tigase.util.TigaseStringprepException

      Method description
      Parameters:
        `name_param` -
        `pass_param` -
        `reg_params` -
      Returns:
        a value of `Authorization`
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`
        `tigase.util.TigaseStringprepException`

    - #### removeData

          public void removeData(String subnode,
                        String key)
                          throws NotAuthorizedException,
                                 TigaseDBException

      Method description
      Parameters:
        `subnode` -
        `key` -
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### removeDataGroup

          public void removeDataGroup(String subnode)
                               throws NotAuthorizedException,
                                      TigaseDBException

      Removes the last data node given in subnode path as parameter to this method. All subnodes are moved as well an all data stored as `(key, val)` are removed as well. Changes are commited to repository immediatelly and there is no way to undo this operation so use it with care.
      Parameters:
        `subnode` - a `String` value of path to node which has to be removed.
      Throws:
        `NotAuthorizedException` - is thrown when session has not been authorized yet and there is no access to permanent storage.
        `TigaseDBException`
      See Also:
        `setData(String, String, String)`

    - #### removeOfflineData

          public void removeOfflineData(String subnode,
                               String key)
                                 throws NotAuthorizedException,
                                        TigaseDBException

      Method description
      Parameters:
        `subnode` -
        `key` -
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### removeOfflineDataGroup

          public void removeOfflineDataGroup(String subnode)
                                      throws NotAuthorizedException,
                                             TigaseDBException

      Method description
      Parameters:
        `subnode` -
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### removePublicData

          public void removePublicData(String subnode,
                              String key)
                                throws NotAuthorizedException,
                                       TigaseDBException

      Method description
      Parameters:
        `subnode` -
        `key` -
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### removePublicDataGroup

          public void removePublicDataGroup(String subnode)
                                     throws NotAuthorizedException,
                                            TigaseDBException

      Method description
      Parameters:
        `subnode` -
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### unregister

          public Authorization unregister(String name_param)
                                   throws NotAuthorizedException,
                                          TigaseDBException,
                                          tigase.util.TigaseStringprepException

      Method description
      Parameters:
        `name_param` -
      Returns:
        a value of `Authorization`
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`
        `tigase.util.TigaseStringprepException`

    - #### getAuthenticationToken

          public String getAuthenticationToken(String xmpp_sessionId)
                                        throws NotAuthorizedException,
                                               TigaseDBException

      Method description
      Parameters:
        `xmpp_sessionId` -
      Returns:
        a value of `String`
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### getAuthState

          public final Authorization getAuthState()

      Gets the value of authState
      Returns:
        the value of authState

    - #### getBareJID

          public abstract tigase.xmpp.BareJID getBareJID()
                                                  throws NotAuthorizedException

      Method description
      Returns:
        a value of `BareJID`
      Throws:
        `NotAuthorizedException`

    - #### getData

          public String getData(String subnode,
                       String key,
                       String def)
                         throws NotAuthorizedException,
                                TigaseDBException

      `getData` method is a twin sister (brother?) of `setData(String, String, String)` method. It allows you to retrieve data stored with above method. It is data stored in given node with given key identifier. If there are no data associated with given key or given node does not exist given `def` value is returned.
      Parameters:
        `subnode` - a `String` value is path to node where pair `(key, value)` are stored.
        `key` - a `String` value of key ID for data to retrieve.
        `def` - a `String` value of default returned if there is nothing stored with given key. `def` can be set to any value you wish to have back as default value or `null` if you want to have back `null` if no data was found. If you set `def` to `null` it has exactly the same effect as if you use `getData(String)` method.
      Returns:
        a `String` value of data found for given key or `def` if there was no data associated with given key.
      Throws:
        `NotAuthorizedException` - is thrown when session has not been authorized yet and there is no access to permanent storage.
        `TigaseDBException`
      See Also:
        `setData(String, String, String)`

    - #### getDataGroups

          public String[] getDataGroups(String subnode)
                                 throws NotAuthorizedException,
                                        TigaseDBException

      This method retrieves list of all direct subnodes for given node. It works in similar way as `ls` unix command or `dir` under DOS/Windows systems.
      Parameters:
        `subnode` - a `String` value of path to node for which we want to retrieve list of direct subnodes.
      Returns:
        a `String[]` array of direct subnodes names for given node.
      Throws:
        `NotAuthorizedException` - is thrown when session has not been authorized yet and there is no access to permanent storage.
        `TigaseDBException`
      See Also:
        `setData(String, String, String)`

    - #### getDataKeys

          public String[] getDataKeys(String subnode)
                               throws NotAuthorizedException,
                                      TigaseDBException

      This method returns all data keys available in permanent storage in given node. There is not though any information what kind of data is stored with this key. This is up to user (developer) to determine what data type is associated with key and what is it's meaning.
      Parameters:
        `subnode` - a `String` value pointing to specific subnode in user reposiotry where data have to be stored.
      Returns:
        a `String[]` array containing all data keys found in given subnode.
      Throws:
        `NotAuthorizedException` - is thrown when session has not been authorized yet and there is no access to permanent storage.
        `TigaseDBException`
      See Also:
        `setData(String, String, String)`

    - #### getDataList

          public String[] getDataList(String subnode,
                             String key)
                               throws NotAuthorizedException,
                                      TigaseDBException

      This method allows to retrieve list of values associated with one key. As it is possible to store many values with one key there are a few methods which provides this functionality. If given key does not exists in given subnode `null` is returned.
      Parameters:
        `subnode` - a `String` value pointing to specific subnode in user reposiotry where data have to be stored.
        `key` - a `String` value of data key ID.
      Returns:
        a `String[]` array containing all values found for given key.
      Throws:
        `NotAuthorizedException` - is thrown when session has not been authorized yet and there is no access to permanent storage.
        `TigaseDBException`
      See Also:
        `setData(String, String, String)`

    - #### getDomain

          public VHostItem getDomain()

      Method description
      Returns:
        a value of `VHostItem`

    - #### getDomainAsJID

          public tigase.xmpp.JID getDomainAsJID()

      Method description
      Returns:
        a value of `JID`

    - #### getOfflineData

          public String getOfflineData(String subnode,
                              String key,
                              String def)
                                throws NotAuthorizedException,
                                       TigaseDBException

      Method description
      Parameters:
        `subnode` -
        `key` -
        `def` -
      Returns:
        a value of `String`
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### getOfflineDataList

          public String[] getOfflineDataList(String subnode,
                                    String key)
                                      throws NotAuthorizedException,
                                             TigaseDBException

      Method description
      Parameters:
        `subnode` -
        `key` -
      Returns:
        a value of `String[]`
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### getPublicData

          public String getPublicData(String subnode,
                             String key,
                             String def)
                               throws NotAuthorizedException,
                                      TigaseDBException

      Method description
      Parameters:
        `subnode` -
        `key` -
        `def` -
      Returns:
        a value of `String`
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### getPublicDataList

          public String[] getPublicDataList(String subnode,
                                   String key)
                                     throws NotAuthorizedException,
                                            TigaseDBException

      Method description
      Parameters:
        `subnode` -
        `key` -
      Returns:
        a value of `String[]`
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### getUserName

          public abstract String getUserName()
                                      throws NotAuthorizedException

      Method description
      Returns:
        a value of `String`
      Throws:
        `NotAuthorizedException`

    - #### isAnonymous

          public boolean isAnonymous()

      Method description
      Returns:
        a value of `boolean`

    - #### isAuthorized

          public boolean isAuthorized()

      This method allows you test this session if it already has been authorized. If `true` is returned as method result it means session has already been authorized, if `false` however session is still not authorized.
      Returns:
        a `boolean` value which informs whether this session has been already authorized or not.

    - #### setData

          public void setData(String subnode,
                     String key,
                     String value)
                       throws NotAuthorizedException,
                              TigaseDBException

      This method stores given data in permanent storage in given point of hierarchy of data base. This method is similar to `setData(String, String)` and differs in one additional parameter which point to user data base subnode where data must be stored. It helps to organize user data in more logical hierarchy.
      User data is kind of tree where you can store data in each tree node. The most relevant sample might be structure like typical file system or XML like or LDAP data base. The first implementation is actually done as XML file to make it easier test application and deploy simple installation where there is no more users than 1000.
      To find out more about user repository refer to `UserRepository` interface for general info and to `XMLRepository` for detailed explanation regarding XML implementation of user repository.

      Thus `subnode` is kind of path to data node. If you specify `null` or empty node data will be stored in root user node. This has exactly the same effect as you call `setData(String, String)`. If you want to store data in different node you must just specify node path like you do it to directory on most file systems:

           /roster

      Or, if you need access deeper node:

           /just/like/path/to/file

      If given node does not yet exist it will be automaticaly created with all nodes in given path so there is no need for developer to perform additional action to create node. There is, however method `removeDataGroup(String)` for deleting specified node as nodes are not automaticaly deleted.
      Parameters:
        `subnode` - a `String` value pointing to specific subnode in user reposiotry where data have to be stored.
        `key` - a `String` value of data key ID.
        `value` - a `String` actual data stored in user repository.
      Throws:
        `NotAuthorizedException` - is thrown when session has not been authorized yet and there is no access to permanent storage.
        `TigaseDBException`
      See Also:
        `removeDataGroup(String)`, `UserRepository`

    - #### setDataList

          public void setDataList(String subnode,
                         String key,
                         String[] list)
                           throws NotAuthorizedException,
                                  TigaseDBException

      This method allows to store list of values under one key ID reference. It is often necessary to keep set of values which can be refered by one key. As an example might be list of groups for specific buddy in roster. There is no actual need to store each group with separate key because we usually need to acces whole list of groups.
      Parameters:
        `subnode` - a `String` value pointing to specific subnode in user reposiotry where data have to be stored.
        `key` - a `String` value of data key ID.
        `list` - a `String[]` keeping list of actual data to be stored in user repository.
      Throws:
        `NotAuthorizedException` - is thrown when session has not been authorized yet and there is no access to permanent storage.
        `TigaseDBException`
      See Also:
        `setData(String, String, String)`

    - #### setDomain

          public void setDomain(VHostItem domain)
                         throws tigase.util.TigaseStringprepException

      Method description
      Parameters:
        `domain` -
      Throws:
        `tigase.util.TigaseStringprepException`

    - #### setOfflineData

          public void setOfflineData(String subnode,
                            String key,
                            String value)
                              throws NotAuthorizedException,
                                     TigaseDBException

      Method description
      Parameters:
        `subnode` -
        `key` -
        `value` -
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### setOfflineDataList

          public void setOfflineDataList(String subnode,
                                String key,
                                String[] list)
                                  throws NotAuthorizedException,
                                         TigaseDBException

      Method description
      Parameters:
        `subnode` -
        `key` -
        `list` -
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### setPublicData

          public void setPublicData(String subnode,
                           String key,
                           String value)
                             throws NotAuthorizedException,
                                    TigaseDBException

      Method description
      Parameters:
        `subnode` -
        `key` -
        `value` -
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### setPublicDataList

          public void setPublicDataList(String subnode,
                               String key,
                               String[] list)
                                 throws NotAuthorizedException,
                                        TigaseDBException

      Method description
      Parameters:
        `subnode` -
        `key` -
        `list` -
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### login

          protected abstract void login()

      Method description

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