tigase.server.amp

## Class JDBCMsgRepository

- java.lang.Object
- - tigase.server.amp.MsgRepository<Long>
  - - tigase.server.amp.JDBCMsgRepository

- All Implemented Interfaces:
    MsgRepositoryIfc, Repository

      public class JDBCMsgRepository
      extends MsgRepository<Long>

  Created: May 3, 2010 5:28:02 PM
  Version:
    $Rev$
  Author:
    Artur Hefczyc

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class tigase.server.amp.MsgRepository

      `MsgRepository.BroadcastMsg, MsgRepository.MSG_TYPES, MsgRepository.MsgDBItem, MsgRepository.OfflineMessagesProcessor`

    - ### Nested classes/interfaces inherited from interface tigase.db.Repository

      `Repository.Meta`

  - ### Field Summary

    - ### Fields inherited from class tigase.server.amp.MsgRepository

      `broadcastMessages, broadcastMessagesLastCleanup, earliestOffline, expiredQueue, MAX_QUEUE_SIZE, MSGS_STORE_LIMIT_KEY, OFFLINE_MSGS_KEY, parser`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JDBCMsgRepository()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `deleteMessage(Long msg_id)`
    `int` | `deleteMessagesToJID(List<String> db_ids, XMPPResourceConnection session)`
    `protected void` | `ensureBroadcastMessageRecipient(String id, BareJID recipient)`
    `Map<Enum,Long>` | `getMessagesCount(JID to)`
    `List<Element>` | `getMessagesList(JID to)`
    `void` | `initRepository(String conn_str, Map<String,String> map)` The method is called to initialize the data repository.
    `protected void` | `insertBroadcastMessage(String id, Element msg, Date expire, BareJID recipient)`
    `protected void` | `loadExpiredQueue(Date expired)`
    `protected void` | `loadExpiredQueue(int min_elements)`
    `void` | `loadMessagesToBroadcast()`
    `Queue<Element>` | `loadMessagesToJID(List<String> db_ids, XMPPResourceConnection session, boolean delete, MsgRepository.OfflineMessagesProcessor proc)`
    `Queue<Element>` | `loadMessagesToJID(XMPPResourceConnection session, boolean delete)` Loads all payloads for the given user's `JID` from repository.
    `Queue<Element>` | `loadMessagesToJID(XMPPResourceConnection session, boolean delete, MsgRepository.OfflineMessagesProcessor proc)`
    `protected Queue<Element>` | `parseLoadedMessages(MsgRepository.OfflineMessagesProcessor proc, ResultSet rs)`
    `boolean` | `storeMessage(JID from, JID to, Date expired, Element msg, NonAuthUserRepository userRepo)` Saves the massage to the repository

    - ### Methods inherited from class tigase.server.amp.MsgRepository

      `dumpBroadcastMessageKeys, getBroadcastMessages, getBroadcastMsg, getInstance, getMessageExpired, getMsgsStoreLimit, getStanzaTo, updateBroadcastMessage`

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

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

- - ### Constructor Detail

    - #### JDBCMsgRepository

          public JDBCMsgRepository()

  - ### Method Detail

    - #### initRepository

          public void initRepository(String conn_str,
                                     Map<String,String> map)
                              throws DBInitException

      Description copied from interface: `Repository`
      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.
      Specified by:
        `initRepository` in interface `Repository`
      Overrides:
        `initRepository` in class `MsgRepository<Long>`
      Parameters:
        `conn_str` - value in most cases representing the database connection string.
        `map` - 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.

    - #### getMessagesCount

          public Map<Enum,Long> getMessagesCount(JID to)
                                          throws UserNotFoundException

      Specified by:
        `getMessagesCount` in class `MsgRepository<Long>`
      Throws:
        `UserNotFoundException`

    - #### getMessagesList

          public List<Element> getMessagesList(JID to)
                                        throws UserNotFoundException

      Specified by:
        `getMessagesList` in class `MsgRepository<Long>`
      Throws:
        `UserNotFoundException`

    - #### loadMessagesToJID

          public Queue<Element> loadMessagesToJID(List<String> db_ids,
                                                  XMPPResourceConnection session,
                                                  boolean delete,
                                                  MsgRepository.OfflineMessagesProcessor proc)
                                           throws UserNotFoundException

      Specified by:
        `loadMessagesToJID` in class `MsgRepository<Long>`
      Throws:
        `UserNotFoundException`

    - #### deleteMessagesToJID

          public int deleteMessagesToJID(List<String> db_ids,
                                         XMPPResourceConnection session)
                                  throws UserNotFoundException

      Specified by:
        `deleteMessagesToJID` in class `MsgRepository<Long>`
      Throws:
        `UserNotFoundException`

    - #### loadMessagesToJID

          public Queue<Element> loadMessagesToJID(XMPPResourceConnection session,
                                                  boolean delete)
                                           throws UserNotFoundException

      Description copied from interface: `MsgRepositoryIfc`
      Loads all payloads for the given user's `JID` from repository.
      Parameters:
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `delete` - boolean parameter controlling whether messages should be removed from repository after they retrieved.
      Returns:
        a `Queue` of `Element` objects representing stored payloads for the given user's `JID`
      Throws:
        `UserNotFoundException`

    - #### loadMessagesToJID

          public Queue<Element> loadMessagesToJID(XMPPResourceConnection session,
                                                  boolean delete,
                                                  MsgRepository.OfflineMessagesProcessor proc)
                                           throws UserNotFoundException

      Throws:
        `UserNotFoundException`

    - #### parseLoadedMessages

          protected Queue<Element> parseLoadedMessages(MsgRepository.OfflineMessagesProcessor proc,
                                                       ResultSet rs)
                                                throws SQLException

      Throws:
        `SQLException`

    - #### storeMessage

          public boolean storeMessage(JID from,
                                      JID to,
                                      Date expired,
                                      Element msg,
                                      NonAuthUserRepository userRepo)
                               throws UserNotFoundException

      Description copied from interface: `MsgRepositoryIfc`
      Saves the massage to the repository
      Parameters:
        `from` - `JID` denotes address of the sender
        `to` - `JID` denotes address of the receiver
        `expired` - `Date` object denoting expiration date of the message
        `msg` - `Element` payload of the stanza to be saved
        `userRepo` - `NonAuthUserRepository` instance of non auth user repository to get user settings for offline messages
      Returns:
        `true` if the packet was correctly saved to repository, `false` otherwise.
      Throws:
        `UserNotFoundException`

    - #### loadMessagesToBroadcast

          public void loadMessagesToBroadcast()

      Specified by:
        `loadMessagesToBroadcast` in class `MsgRepository<Long>`

    - #### insertBroadcastMessage

          protected void insertBroadcastMessage(String id,
                                                Element msg,
                                                Date expire,
                                                BareJID recipient)

      Specified by:
        `insertBroadcastMessage` in class `MsgRepository<Long>`

    - #### ensureBroadcastMessageRecipient

          protected void ensureBroadcastMessageRecipient(String id,
                                                         BareJID recipient)

      Specified by:
        `ensureBroadcastMessageRecipient` in class `MsgRepository<Long>`

    - #### deleteMessage

          protected void deleteMessage(Long msg_id)

      Specified by:
        `deleteMessage` in class `MsgRepository<Long>`

    - #### loadExpiredQueue

          protected void loadExpiredQueue(int min_elements)

      Specified by:
        `loadExpiredQueue` in class `MsgRepository<Long>`

    - #### loadExpiredQueue

          protected void loadExpiredQueue(Date expired)

      Specified by:
        `loadExpiredQueue` in class `MsgRepository<Long>`

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