tigase.db.jdbc

## Class JDBCRepository

- java.lang.Object
- - tigase.db.jdbc.JDBCRepository

- All Implemented Interfaces:
    AuthRepository, UserRepository

      public class JDBCRepository
      extends Object
      implements AuthRepository, UserRepository

  Not synchronized implementation! Musn't be used by more than one thread at the same time.

  Thanks to Daniele for better unique IDs handling. Created: Thu Oct 26 11:48:53 2006

  Version:
    $Rev$
  Author:
    Artur Hefczyc, Daniele

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CURRENT_DB_SCHEMA_VER` Field description
    `static String` | `DEF_MAXIDS_TBL` Field description
    `static String` | `DEF_NODES_TBL` Field description
    `static String` | `DEF_PAIRS_TBL` Field description
    `static String` | `DEF_ROOT_NODE` Field description
    `static String` | `DEF_USERS_TBL` Field description
    `static String` | `DERBY_GETSCHEMAVER_QUERY` Field description
    `static String` | `JDBC_GETSCHEMAVER_QUERY` Field description
    `static String` | `SCHEMA_UPGRADE_LINK` Field description

    - ### 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
    `JDBCRepository()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addDataList(tigase.xmpp.BareJID user_id, String subnode, String key, String[] list)` Describe `addDataList` method here.
    `void` | `addUser(tigase.xmpp.BareJID user_id)` Describe `addUser` method here.
    `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_id, String key)` Describe `getData` method here.
    `String` | `getData(tigase.xmpp.BareJID user_id, String subnode, String key)` Describe `getData` method here.
    `String` | `getData(tigase.xmpp.BareJID user_id, String subnode, String key, String def)` Describe `getData` method here.
    `String[]` | `getDataList(tigase.xmpp.BareJID user_id, String subnode, String key)` Describe `getDataList` method here.
    `String[]` | `getKeys(tigase.xmpp.BareJID user_id)` Describe `getKeys` method here.
    `String[]` | `getKeys(tigase.xmpp.BareJID user_id, String subnode)` Describe `getKeys` method here.
    `String` | `getResourceUri()` Method description
    `String[]` | `getSubnodes(tigase.xmpp.BareJID user_id)` Describe `getSubnodes` method here.
    `String[]` | `getSubnodes(tigase.xmpp.BareJID user_id, String subnode)` Describe `getSubnodes` method here.
    `List<tigase.xmpp.BareJID>` | `getUsers()` `getUsers` method is thread safe.
    `long` | `getUsersCount()` `getUsersCount` method is thread safe.
    `long` | `getUsersCount(String domain)` Method description
    `long` | `getUserUID(tigase.xmpp.BareJID user_id)` Method description
    `long` | `getUserUID(DataRepository repo, tigase.xmpp.BareJID user_id)` Method description
    `void` | `initRepository(String connection_str, Map<String,String> params)` Describe `initRepository` method here.
    `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_id, String key)` Describe `removeData` method here.
    `void` | `removeData(tigase.xmpp.BareJID user_id, String subnode, String key)` Describe `removeData` method here.
    `void` | `removeSubnode(tigase.xmpp.BareJID user_id, String subnode)` Describe `removeSubnode` method here.
    `void` | `removeUser(tigase.xmpp.BareJID user_id)` `removeUser` method is thread safe.
    `void` | `setData(tigase.xmpp.BareJID user_id, String key, String value)` Describe `setData` method here.
    `void` | `setData(tigase.xmpp.BareJID user_id, String subnode, String key, String value)` Describe `setData` method here.
    `void` | `setDataList(tigase.xmpp.BareJID user_id, String subnode, String key, String[] list)` Describe `setDataList` method here.
    `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`

- - ### Field Detail

    - #### CURRENT_DB_SCHEMA_VER

          public static final String CURRENT_DB_SCHEMA_VER

      Field description
      See Also:
        Constant Field Values

    - #### DEF_MAXIDS_TBL

          public static final String DEF_MAXIDS_TBL

      Field description
      See Also:
        Constant Field Values

    - #### DEF_NODES_TBL

          public static final String DEF_NODES_TBL

      Field description
      See Also:
        Constant Field Values

    - #### DEF_PAIRS_TBL

          public static final String DEF_PAIRS_TBL

      Field description
      See Also:
        Constant Field Values

    - #### DEF_ROOT_NODE

          public static final String DEF_ROOT_NODE

      Field description
      See Also:
        Constant Field Values

    - #### DEF_USERS_TBL

          public static final String DEF_USERS_TBL

      Field description
      See Also:
        Constant Field Values

    - #### DERBY_GETSCHEMAVER_QUERY

          public static final String DERBY_GETSCHEMAVER_QUERY

      Field description
      See Also:
        Constant Field Values

    - #### JDBC_GETSCHEMAVER_QUERY

          public static final String JDBC_GETSCHEMAVER_QUERY

      Field description
      See Also:
        Constant Field Values

    - #### SCHEMA_UPGRADE_LINK

          public static final String SCHEMA_UPGRADE_LINK

      Field description
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### JDBCRepository

          public JDBCRepository()

  - ### Method Detail

    - #### addDataList

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

      Describe `addDataList` method here.
      Specified by:
        `addDataList` in interface `UserRepository`
      Parameters:
        `user_id` - a `String` value
        `subnode` - a `String` value
        `key` - a `String` value
        `list` - a `String[]` value
      Throws:
        `UserNotFoundException` - if an error occurs
        `TigaseDBException`

    - #### addUser

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

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

    - #### 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_id,
                       String subnode,
                       String key,
                       String def)
                         throws UserNotFoundException,
                                TigaseDBException

      Describe `getData` method here.
      Specified by:
        `getData` in interface `UserRepository`
      Parameters:
        `user_id` - a `String` value
        `subnode` - a `String` value
        `key` - a `String` value
        `def` - a `String` value
      Returns:
        a `String` value
      Throws:
        `UserNotFoundException` - if an error occurs
        `TigaseDBException`

    - #### getData

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

      Describe `getData` method here.
      Specified by:
        `getData` in interface `UserRepository`
      Parameters:
        `user_id` - a `String` value
        `subnode` - a `String` value
        `key` - a `String` value
      Returns:
        a `String` value
      Throws:
        `UserNotFoundException` - if an error occurs
        `TigaseDBException`

    - #### getData

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

      Describe `getData` method here.
      Specified by:
        `getData` in interface `UserRepository`
      Parameters:
        `user_id` - a `String` value
        `key` - a `String` value
      Returns:
        a `String` value
      Throws:
        `UserNotFoundException` - if an error occurs
        `TigaseDBException`

    - #### getDataList

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

      Describe `getDataList` method here.
      Specified by:
        `getDataList` in interface `UserRepository`
      Parameters:
        `user_id` - a `String` value
        `subnode` - a `String` value
        `key` - a `String` value
      Returns:
        a `String[]` value
      Throws:
        `UserNotFoundException` - if an error occurs
        `TigaseDBException`

    - #### getKeys

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

      Describe `getKeys` method here.
      Specified by:
        `getKeys` in interface `UserRepository`
      Parameters:
        `user_id` - a `String` value
        `subnode` - a `String` value
      Returns:
        a `String[]` value
      Throws:
        `UserNotFoundException` - if an error occurs
        `TigaseDBException`

    - #### getKeys

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

      Describe `getKeys` method here.
      Specified by:
        `getKeys` in interface `UserRepository`
      Parameters:
        `user_id` - a `String` value
      Returns:
        a `String[]` value
      Throws:
        `UserNotFoundException` - if an error occurs
        `TigaseDBException`

    - #### 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_id,
                             String subnode)
                               throws UserNotFoundException,
                                      TigaseDBException

      Describe `getSubnodes` method here.
      Specified by:
        `getSubnodes` in interface `UserRepository`
      Parameters:
        `user_id` - a `String` value
        `subnode` - a `String` value
      Returns:
        a `String[]` value
      Throws:
        `UserNotFoundException` - if an error occurs
        `TigaseDBException`

    - #### getSubnodes

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

      Describe `getSubnodes` method here.
      Specified by:
        `getSubnodes` in interface `UserRepository`
      Parameters:
        `user_id` - a `String` value
      Returns:
        a `String[]` value
      Throws:
        `UserNotFoundException` - if an error occurs
        `TigaseDBException`

    - #### getUserUID

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

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

    - #### getUserUID

          public long getUserUID(DataRepository repo,
                        tigase.xmpp.BareJID user_id)
                          throws SQLException

      Method description
      Parameters:
        `repo` -
        `user_id` -
      Returns:
      Throws:
        `SQLException`

    - #### getUsers

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

      `getUsers` method is thread safe.
      Specified by:
        `getUsers` in interface `UserRepository`
      Returns:
        a `List` of user IDs from database.
      Throws:
        `TigaseDBException`

    - #### getUsersCount

          public long getUsersCount()

      `getUsersCount` method is thread safe. It uses local variable for storing `Statement`.
      Specified by:
        `getUsersCount` in interface `AuthRepository`
      Specified by:
        `getUsersCount` in interface `UserRepository`
      Returns:
        a `long` number of user accounts in database.

    - #### getUsersCount

          public long getUsersCount(String domain)

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

    - #### initRepository

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

      Describe `initRepository` method here.
      Specified by:
        `initRepository` in interface `AuthRepository`
      Specified by:
        `initRepository` in interface `UserRepository`
      Parameters:
        `connection_str` - a `String` value
        `params` -
      Throws:
        `DBInitException`

    - #### 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_id,
                        String subnode,
                        String key)
                          throws UserNotFoundException,
                                 TigaseDBException

      Describe `removeData` method here.
      Specified by:
        `removeData` in interface `UserRepository`
      Parameters:
        `user_id` - a `String` value
        `subnode` - a `String` value
        `key` - a `String` value
      Throws:
        `UserNotFoundException` - if an error occurs
        `TigaseDBException`

    - #### removeData

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

      Describe `removeData` method here.
      Specified by:
        `removeData` in interface `UserRepository`
      Parameters:
        `user_id` - a `String` value
        `key` - a `String` value
      Throws:
        `UserNotFoundException` - if an error occurs
        `TigaseDBException`

    - #### removeSubnode

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

      Describe `removeSubnode` method here.
      Specified by:
        `removeSubnode` in interface `UserRepository`
      Parameters:
        `user_id` - a `String` value
        `subnode` - a `String` value
      Throws:
        `UserNotFoundException` - if an error occurs
        `TigaseDBException`

    - #### removeUser

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

      `removeUser` method is thread safe. It uses local variable for storing `Statement`.
      Specified by:
        `removeUser` in interface `AuthRepository`
      Specified by:
        `removeUser` in interface `UserRepository`
      Parameters:
        `user_id` - a `String` value the user Jabber ID.
      Throws:
        `TigaseDBException`
        `UserNotFoundException` - if an error occurs

    - #### setData

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

      Describe `setData` method here.
      Specified by:
        `setData` in interface `UserRepository`
      Parameters:
        `user_id` - a `String` value
        `subnode` - a `String` value
        `key` - a `String` value
        `value` - a `String` value
      Throws:
        `UserNotFoundException` - if an error occurs
        `TigaseDBException`

    - #### setData

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

      Describe `setData` method here.
      Specified by:
        `setData` in interface `UserRepository`
      Parameters:
        `user_id` - a `String` value
        `key` - a `String` value
        `value` - a `String` value
      Throws:
        `UserNotFoundException` - if an error occurs
        `TigaseDBException`

    - #### setDataList

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

      Describe `setDataList` method here.
      Specified by:
        `setDataList` in interface `UserRepository`
      Parameters:
        `user_id` - a `String` value
        `subnode` - a `String` value
        `key` - a `String` value
        `list` - a `String[]` value
      Throws:
        `UserNotFoundException` - if an error occurs
        `TigaseDBException`

    - #### updatePassword

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

      Method description
      Specified by:
        `updatePassword` in interface `AuthRepository`
      Parameters:
        `user` -
        `password` -
      Throws:
        `TigaseDBException`
        `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.