tigase.xmpp.impl

## Class PresenceSubscription

- java.lang.Object
- - tigase.xmpp.XMPPProcessor
  - - tigase.xmpp.impl.annotation.AnnotatedXMPPProcessor
    - - tigase.xmpp.impl.PresenceAbstract
      - - tigase.xmpp.impl.PresenceSubscription

- All Implemented Interfaces:
    Comparable<XMPPImplIfc>, XMPPImplIfc, XMPPProcessorIfc

      public class PresenceSubscription
      extends PresenceAbstract

  Author:
    andrzej

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `AUTO_AUTHORIZE_PROP_KEY` key allowing enabling automatic authorisation.
    `protected static String` | `ID`

    - ### Fields inherited from class tigase.xmpp.impl.PresenceAbstract

      `PRESENCE_ELEMENT_NAME, PRESENCE_PROBE_FULL_JID_KEY, probeFullJID, roster_util, SKIP_OFFLINE_PROP_KEY, SKIP_OFFLINE_SYS_PROP_KEY, skipOffline, USERS_STATUS_CHANGES, XMLNS`

    - ### Fields inherited from class tigase.xmpp.XMPPProcessor

      `ALL_NAMES, ALL_PATHS, cmpInfo`

    - ### Fields inherited from interface tigase.xmpp.XMPPImplIfc

      `CLIENT_XMLNS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PresenceSubscription()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `init(Map<String,Object> settings)` Method `init` is called just after the plugin has been loaded into memory.
    `void` | `process(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, Queue<Packet> results, Map<String,Object> settings)` Performs processing of presence packets and calls different methods for particular `RosterAbstract.PresenceType`
    `protected void` | `processInSubscribe(Packet packet, XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings, RosterAbstract.PresenceType pres_type)` Method is responsible for processing incoming subscription request (i.e. in the receivers session manager).
    `protected void` | `processInSubscribed(Packet packet, XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings, RosterAbstract.PresenceType pres_type)` Method is responsible for processing incoming subscribed presence (i.e. in the receivers session manager).
    `protected void` | `processInUnsubscribe(Packet packet, XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings, RosterAbstract.PresenceType pres_type)` Method is responsible for processing incoming unsubscribe presence (i.e. in the receivers session manager).
    `protected void` | `processInUnsubscribed(Packet packet, XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings, RosterAbstract.PresenceType pres_type)` Method is responsible for processing incoming unsubscribed presence (i.e.
    `protected void` | `processOutSubscribe(Packet packet, XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings, RosterAbstract.PresenceType pres_type)` Method is responsible for processing outgoing subscribe and unsubscribe presence (i.e. in the sender session manager).
    `protected void` | `processOutSubscribed(Packet packet, XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings, RosterAbstract.PresenceType pres_type)` Method is responsible for processing outgoing subscribed and unsubscribed presence (i.e. in the sender session manager).
    `Set<StanzaType>` | `supTypes()` Method returns an array of all stanza types which the plugin is able to handle.

    - ### Methods inherited from class tigase.xmpp.impl.PresenceAbstract

      `broadcastProbe, concurrentQueuesNo, forwardPresence, getRosterUtil, initSettings, prepareProbe, requiresPresenceSending, sendPresence, sendPresence, updatePresenceChange, updateUserResources`

    - ### Methods inherited from class tigase.xmpp.impl.annotation.AnnotatedXMPPProcessor

      `id, supDiscoFeatures, supElementNamePaths, supNamespaces, supStreamFeatures`

    - ### Methods inherited from class tigase.xmpp.XMPPProcessor

      `canHandle, compareTo, concurrentThreadsPerQueue, getComponentInfo, getInstance, getStatistics, isSupporting, supElements, toString`

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

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

    - ### Methods inherited from interface tigase.xmpp.XMPPImplIfc

      `canHandle, concurrentThreadsPerQueue, getComponentInfo, getStatistics, id, isSupporting, supDiscoFeatures, supElementNamePaths, supElements, supNamespaces, supStreamFeatures`

    - ### Methods inherited from interface java.lang.Comparable

      `compareTo`

- - ### Field Detail

    - #### AUTO_AUTHORIZE_PROP_KEY

          public static final String AUTO_AUTHORIZE_PROP_KEY

      key allowing enabling automatic authorisation.
      See Also:
        Constant Field Values

    - #### ID

          protected static final String ID

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### PresenceSubscription

          public PresenceSubscription()

  - ### Method Detail

    - #### init

          public void init(Map<String,Object> settings)
                    throws TigaseDBException

      Description copied from interface: `XMPPImplIfc`
      Method `init` is called just after the plugin has been loaded into memory. The idea behind this is to allow it to initialize or check the database. This might be especially useful for plugins which want to have a database access via non-standard stored procedures or need schema upgrade.
      Specified by:
        `init` in interface `XMPPImplIfc`
      Overrides:
        `init` in class `XMPPProcessor`
      Parameters:
        `settings` - is a Map with initial processor settings from the configuration file.
      Throws:
        `TigaseDBException`

    - #### supTypes

          public Set<StanzaType> supTypes()

      Description copied from interface: `XMPPImplIfc`
      Method returns an array of all stanza types which the plugin is able to handle. If the method returns NULL, then all stanzas of all types will be passed to the plugin for processing. Otherwise only stanzas with selected types, assuming that element names and name-spaces match as well.
      Specified by:
        `supTypes` in interface `XMPPImplIfc`
      Overrides:
        `supTypes` in class `AnnotatedXMPPProcessor`
      Returns:
        a `StanzaType[]` array of supported stanza types.

    - #### process

          public void process(Packet packet,
                              XMPPResourceConnection session,
                              NonAuthUserRepository repo,
                              Queue<Packet> results,
                              Map<String,Object> settings)
                       throws XMPPException

      Performs processing of presence packets and calls different methods for particular `RosterAbstract.PresenceType`
      Parameters:
        `packet` - packet is which being processed. This parameter may never be null. Even though this is not immutable object it mustn't be altered. None of it's fields or attributes can be changed during processing.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data. It allows for storing information in a permanent storage or in memory only during the live of the online session. This parameter can be null if there is no online user session at the time of the packet processing.
        `repo` - this is a user data storage which is normally used when the user session (parameter above) is null. This is repository allows for a very restricted access only. It allows for storing some user private data (doesn't allow overwriting existing data) like messages for offline users and it also allows for reading user public data like VCard.
        `results` - this a collection with packets which have been generated as input packet processing results. Regardless a response to a user request is sent or the packet is forwarded to it's destination it is always required that a copy of the input packet is created and stored in the results queue.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration. In most cases it is unused, however if the plugin needs to access an external database that this is a way to pass database connection string to the plugin.
      Throws:
        `XMPPException`

    - #### processInSubscribe

          protected void processInSubscribe(Packet packet,
                                            XMPPResourceConnection session,
                                            Queue<Packet> results,
                                            Map<String,Object> settings,
                                            RosterAbstract.PresenceType pres_type)
                                     throws NotAuthorizedException,
                                            TigaseDBException,
                                            NoConnectionIdException,
                                            PolicyViolationException

      Method is responsible for processing incoming subscription request (i.e. in the receivers session manager).

      If the contact is already subscribed the an auto-reply with type='subscribded' is sent, otherwise contact is added to the roster (if it's missing/there is no current subscription), sets the subscription type to `PresenceType.in_subscribe` and subsequently broadcast presence update to all connected resources.

      Parameters:
        `packet` - packet is which being processed.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `pres_type` - specifies type of the presence.
      Throws:
        `NoConnectionIdException`
        `NotAuthorizedException`
        `TigaseDBException`
        `PolicyViolationException`

    - #### processInSubscribed

          protected void processInSubscribed(Packet packet,
                                             XMPPResourceConnection session,
                                             Queue<Packet> results,
                                             Map<String,Object> settings,
                                             RosterAbstract.PresenceType pres_type)
                                      throws NotAuthorizedException,
                                             TigaseDBException,
                                             NoConnectionIdException,
                                             PolicyViolationException

      Method is responsible for processing incoming subscribed presence (i.e. in the receivers session manager).

      Contact is added to the roster (if it's missing/there is no current subscription), sets the subscription type to `PresenceType.in_subscribed` and subsequently, if subscription has changed,forwards the presence to user resource connection as well as broadcast presence update to all connected resources.

      Parameters:
        `packet` - packet is which being processed.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `pres_type` - specifies type of the presence.
      Throws:
        `NoConnectionIdException`
        `NotAuthorizedException`
        `TigaseDBException`
        `PolicyViolationException`

    - #### processInUnsubscribe

          protected void processInUnsubscribe(Packet packet,
                                              XMPPResourceConnection session,
                                              Queue<Packet> results,
                                              Map<String,Object> settings,
                                              RosterAbstract.PresenceType pres_type)
                                       throws NotAuthorizedException,
                                              TigaseDBException,
                                              NoConnectionIdException,
                                              PolicyViolationException

      Method is responsible for processing incoming unsubscribe presence (i.e. in the receivers session manager).

      First method performs update of subscription of the given contact and subsequently the request is forwarded to the client to make sure it says in synch with the server (in case there was actual change in subscription). Lastly a roster push is generated to all connected resources to update them with current state of the roster and items subscriptions.

      Parameters:
        `packet` - packet is which being processed.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `pres_type` - specifies type of the presence.
      Throws:
        `NoConnectionIdException`
        `NotAuthorizedException`
        `TigaseDBException`
        `PolicyViolationException`

    - #### processInUnsubscribed

          protected void processInUnsubscribed(Packet packet,
                                               XMPPResourceConnection session,
                                               Queue<Packet> results,
                                               Map<String,Object> settings,
                                               RosterAbstract.PresenceType pres_type)
                                        throws NotAuthorizedException,
                                               TigaseDBException,
                                               NoConnectionIdException,
                                               PolicyViolationException

      Method is responsible for processing incoming unsubscribed presence (i.e. in the receivers session manager).

      First method checks for the current subscription of the contact and if this verifies performs subsequent actions such as forwarding presence to the user connection to make sure it says in synch with the server, updates contact subscription with `PresenceType.in_unsubscribed` and in case that there was a change in user subscription send out a roster push to all connected resources to update them with current state of the roster and items subscriptions.

      Parameters:
        `packet` - packet is which being processed.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `pres_type` - specifies type of the presence.
      Throws:
        `NoConnectionIdException`
        `NotAuthorizedException`
        `TigaseDBException`
        `PolicyViolationException`

    - #### processOutSubscribe

          protected void processOutSubscribe(Packet packet,
                                             XMPPResourceConnection session,
                                             Queue<Packet> results,
                                             Map<String,Object> settings,
                                             RosterAbstract.PresenceType pres_type)
                                      throws NotAuthorizedException,
                                             TigaseDBException,
                                             NoConnectionIdException,
                                             PolicyViolationException

      Method is responsible for processing outgoing subscribe and unsubscribe presence (i.e. in the sender session manager).

      Presence packet is forwarded to the destination with the JID stripped from the resource.

      In case of `PresenceType.out_subscribe` packet type contact is added to the roster (in case it was missing), a subscription state is being updated and, in case there was a change, a roster push is being sent to all user resources.

      In case of `PresenceType.out_unsubscribe` method updates contact subscription (and generates roster push if there was a change) and if the resulting contact subscription is NONE then contact is removed from the roster.

      Parameters:
        `packet` - packet is which being processed.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `pres_type` - specifies type of the presence.
      Throws:
        `NoConnectionIdException`
        `NotAuthorizedException`
        `TigaseDBException`
        `PolicyViolationException`

    - #### processOutSubscribed

          protected void processOutSubscribed(Packet packet,
                                              XMPPResourceConnection session,
                                              Queue<Packet> results,
                                              Map<String,Object> settings,
                                              RosterAbstract.PresenceType pres_type)
                                       throws NotAuthorizedException,
                                              TigaseDBException,
                                              NoConnectionIdException,
                                              PolicyViolationException

      Method is responsible for processing outgoing subscribed and unsubscribed presence (i.e. in the sender session manager).

      Presence packet is forwarded to the destination with the JID stripped from the resource, a subscription state is being updated and, in case there was a change, a roster push is being sent to all user resources. Also, in case of presence type out_subscribed server send current presence to the user from each of the contact's available resources. For the presence type out_unsubscribed an unavailable presence is sent.

      Parameters:
        `packet` - packet is which being processed.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `pres_type` - specifies type of the presence.
      Throws:
        `NoConnectionIdException`
        `NotAuthorizedException`
        `TigaseDBException`
        `PolicyViolationException`

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