tigase.server

## Enum Command

- java.lang.Object
- - java.lang.Enum<Command>
  - - tigase.server.Command

- All Implemented Interfaces:
    Serializable, Comparable<Command>

      public enum Command
      extends Enum<Command>

  Helper enum to make it easier to operate on packets with ad-hoc commands. It allows to create a packet with command, add and retrieve command data field values, set actions and so on. It contains predefined set of commands used internally by the Tigase server and also 'OTHER' command which refers all other not predefined commands. Most of the implementation details, constants and parameters is based on the XEP-0050 for ad-hoc commands protocol. Please refer to the XEP for more details. Created: Thu Feb 9 20:52:02 2006
  Version:
    $Rev$
  Author:
    Artur Hefczyc

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Command.Action` Ad-hoc command actions ad defined in the XEP-0050.
    `static class` | `Command.DataType` Data form-types as defined in the XEP-0050.
    `static class` | `Command.Status` Ad-hoc command statuses as defined in the XEP-0050.

  - ### Enum Constant Summary

    Enum Constants
    Enum Constant and Description
    `BROADCAST_TO_ALL` Command used to set a broadcast message to all registered local users.
    `BROADCAST_TO_ONLINE` Command used to set a broadcast message to all online users.
    `CHECK_USER_CONNECTION` Sends a command from SM to the connection holder to confirm whether the connection is still active.
    `CLIENT_AUTH` Command sent from connection manager to the session manager after TLS handshake if client sent certificate.
    `CLOSE` Command sent from the session manager to a client manager to close the client connection.
    `GETDISCO` This is depreciated command sent between components in the Tigase server for service discovery handling.
    `GETFEATURES` Command sent between a connection manager and the session manager to retrieve stream features.
    `GETSTATS` Command used by the StatisticsCollector to provide server statistics through ad-hoc command.
    `OTHER` Identifies all other, not predefined commands.
    `REDIRECT` Command used to redirect packets from a connection manager to other than default session manager.
    `STARTTLS` Command sent from the session manager to a connection manager to start TLS handshaking over the client connection.
    `STARTZLIB` Command sent from the session manager to a connection manager to start zlib compression on the connection stream.
    `STREAM_CLOSED` Command sent from a connection manager to the session manager when a connection or stream has been closed.
    `STREAM_CLOSED_UPDATE`
    `STREAM_MOVED` Command sent to SessionManager to change connectionId of existing session.
    `STREAM_OPENED` Command sent from a connection manager to the session manager when a new stream from the client has been opened.
    `USER_LOGIN` Command sent from session manager to the connection manager after successful user login.
    `USER_STATUS` Command sent to the session manager from an external entity to activate a user session with the connection end-point at the given address.
    `VHOSTS_RELOAD` Command sent to the VHostManager to reload virtual hosts from the database.
    `VHOSTS_REMOVE` Command sent to the VHostManager to remove existing virtual host.
    `VHOSTS_UPDATE` Command sent to the VHostManager to add or update existing virtual host.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `COMMAND_EL` Field description
    `static String` | `FIELD_EL` Field description
    `protected static String[]` | `FIELD_VALUE_PATH` Field description
    `static String` | `VALUE_EL` Field description
    `static String` | `XMLNS` Field description

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `addAction(Packet packet, Command.Action action)` Method description
    `static void` | `addCheckBoxField(Packet packet, String f_name, boolean f_value)` Method description
    `static void` | `addFieldMultiValue(Packet packet, String f_name, List<String> f_value)` A simple method for adding a multi-line (text-multi) data field to the command data form.
    `static void` | `addFieldMultiValue(Packet packet, String f_name, Throwable ex)` Method description
    `static void` | `addFieldValue(Packet packet, String f_name, String f_value)` Simple method for adding a new field to the command data form.
    `static void` | `addFieldValue(Packet packet, String f_name, String[] f_values, String label, String[] labels, String[] options)` This method allows to add a new multi-option-select-many data field to the command data form.
    `static void` | `addFieldValue(Packet packet, String f_name, String f_value, String type)` Method description
    `static void` | `addFieldValue(Packet packet, String f_name, String f_value, String type, String label)` Method description
    `static void` | `addFieldValue(Packet packet, String f_name, String f_value, String label, String[] labels, String[] options)` This method allows to add a new multi-option-select-one data field to the command data form.
    `static void` | `addFieldValue(Packet packet, String f_name, String f_value, String label, String[] labels, String[] options, String type)` Method description
    `static void` | `addHiddenField(Packet packet, String f_name, String f_value)` Method description
    `static void` | `addInstructions(Packet packet, String instructions)` Method description
    `static void` | `addNote(Packet packet, String note)` Method description
    `static void` | `addTextField(Packet packet, String f_name, String f_value)` Method description
    `static void` | `addTitle(Packet packet, String title)` Method description
    `static tigase.xml.Element` | `createIqCommand(tigase.xmpp.JID from, tigase.xmpp.JID to, StanzaType type, String id, String node, Command.DataType data_type)` Method description
    `static Command.Action` | `getAction(Packet packet)` Method description
    `static boolean` | `getCheckBoxFieldValue(Packet packet, String f_name)` Method description
    `static List<tigase.xml.Element>` | `getData(Packet packet)` Method description
    `static tigase.xml.Element` | `getData(Packet packet, String el_name, String xmlns)` Method description
    `static String` | `getFieldKeyStartingWith(Packet packet, String f_name)` Method description
    `static String` | `getFieldValue(Packet packet, String f_name)` Method description
    `static String` | `getFieldValue(Packet packet, String f_name, boolean debug)` Method description
    `static String[]` | `getFieldValues(Packet packet, String f_name)` Method description
    `Packet` | `getPacket(tigase.xmpp.JID from, tigase.xmpp.JID to, StanzaType type, String id)` Method description
    `Packet` | `getPacket(tigase.xmpp.JID from, tigase.xmpp.JID to, StanzaType type, String id, Command.DataType data_type)` Method description
    `static boolean` | `removeFieldValue(Packet packet, String f_name)` Method description
    `static void` | `setData(Packet packet, tigase.xml.Element data)` Method description
    `static void` | `setData(Packet packet, List<tigase.xml.Element> data)` Method description
    `static void` | `setStatus(Packet packet, Command.Status status)` Method description
    `static Command` | `valueof(String cmd)` Method description
    `static Command` | `valueOf(String name)` Returns the enum constant of this type with the specified name.
    `static Command[]` | `values()` Returns an array containing the constants of this enum type, in the order they are declared.

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

      `clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

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

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Enum Constant Detail

    - #### STREAM_OPENED

          public static final Command STREAM_OPENED

      Command sent from a connection manager to the session manager when a new stream from the client has been opened.

    - #### CLIENT_AUTH

          public static final Command CLIENT_AUTH

      Command sent from connection manager to the session manager after TLS handshake if client sent certificate.

    - #### USER_LOGIN

          public static final Command USER_LOGIN

      Command sent from session manager to the connection manager after successful user login.

    - #### STREAM_CLOSED

          public static final Command STREAM_CLOSED

      Command sent from a connection manager to the session manager when a connection or stream has been closed.

    - #### STREAM_CLOSED_UPDATE

          public static final Command STREAM_CLOSED_UPDATE

    - #### CHECK_USER_CONNECTION

          public static final Command CHECK_USER_CONNECTION

      Sends a command from SM to the connection holder to confirm whether the connection is still active. Expects result for ok, error or timeout if the connection is no longer active.

    - #### STARTTLS

          public static final Command STARTTLS

      Command sent from the session manager to a connection manager to start TLS handshaking over the client connection.

    - #### STARTZLIB

          public static final Command STARTZLIB

      Command sent from the session manager to a connection manager to start zlib compression on the connection stream.

    - #### GETFEATURES

          public static final Command GETFEATURES

      Command sent between a connection manager and the session manager to retrieve stream features.

    - #### GETDISCO

          public static final Command GETDISCO

      This is depreciated command sent between components in the Tigase server for service discovery handling.

    - #### CLOSE

          public static final Command CLOSE

      Command sent from the session manager to a client manager to close the client connection.

    - #### GETSTATS

          public static final Command GETSTATS

      Command used by the StatisticsCollector to provide server statistics through ad-hoc command.

    - #### USER_STATUS

          public static final Command USER_STATUS

      Command sent to the session manager from an external entity to activate a user session with the connection end-point at the given address.

    - #### BROADCAST_TO_ONLINE

          public static final Command BROADCAST_TO_ONLINE

      Command used to set a broadcast message to all online users.

    - #### BROADCAST_TO_ALL

          public static final Command BROADCAST_TO_ALL

      Command used to set a broadcast message to all registered local users.

    - #### REDIRECT

          public static final Command REDIRECT

      Command used to redirect packets from a connection manager to other than default session manager. (Mostly used in the clustering.)

    - #### VHOSTS_RELOAD

          public static final Command VHOSTS_RELOAD

      Command sent to the VHostManager to reload virtual hosts from the database.

    - #### VHOSTS_UPDATE

          public static final Command VHOSTS_UPDATE

      Command sent to the VHostManager to add or update existing virtual host.

    - #### VHOSTS_REMOVE

          public static final Command VHOSTS_REMOVE

      Command sent to the VHostManager to remove existing virtual host.

    - #### STREAM_MOVED

          public static final Command STREAM_MOVED

      Command sent to SessionManager to change connectionId of existing session.

    - #### OTHER

          public static final Command OTHER

      Identifies all other, not predefined commands.

  - ### Field Detail

    - #### COMMAND_EL

          public static final String COMMAND_EL

      Field description
      See Also:
        Constant Field Values

    - #### FIELD_EL

          public static final String FIELD_EL

      Field description
      See Also:
        Constant Field Values

    - #### VALUE_EL

          public static final String VALUE_EL

      Field description
      See Also:
        Constant Field Values

    - #### XMLNS

          public static final String XMLNS

      Field description
      See Also:
        Constant Field Values

    - #### FIELD_VALUE_PATH

          protected static final String[] FIELD_VALUE_PATH

      Field description

  - ### Method Detail

    - #### values

          public static Command[] values()

      Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

          for (Command c : Command.values())
              System.out.println(c);

      Returns:
        an array containing the constants of this enum type, in the order they are declared

    - #### valueOf

          public static Command valueOf(String name)

      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
        `name` - the name of the enum constant to be returned.
      Returns:
        the enum constant with the specified name
      Throws:
        `IllegalArgumentException` - if this enum type has no constant with the specified name
        `NullPointerException` - if the argument is null

    - #### addAction

          public static void addAction(Packet packet,
                       Command.Action action)

      Method description
      Parameters:
        `packet` -
        `action` -

    - #### addCheckBoxField

          public static void addCheckBoxField(Packet packet,
                              String f_name,
                              boolean f_value)

      Method description
      Parameters:
        `packet` -
        `f_name` -
        `f_value` -

    - #### addFieldMultiValue

          public static void addFieldMultiValue(Packet packet,
                                String f_name,
                                List<String> f_value)

      A simple method for adding a multi-line (text-multi) data field to the command data form. Only field name (variable name) and field default value can be set.
      Parameters:
        `packet` - is a `Packet` instance of the ad-hoc command request to be modified.
        `f_name` - is a `String` instance with the field name. In ad-hoc command terms this is a variable name. This field name (variable name) will be also displayed as the field label.
        `f_value` - is a list with lines of text to be displayed as a multi-line field content.

    - #### addFieldMultiValue

          public static void addFieldMultiValue(Packet packet,
                                String f_name,
                                Throwable ex)

      Method description
      Parameters:
        `packet` -
        `f_name` -
        `ex` -

    - #### addFieldValue

          public static void addFieldValue(Packet packet,
                           String f_name,
                           String f_value)

      Simple method for adding a new field to the command data form. Only field name (variable name) and field default value can be set.
      Parameters:
        `packet` - is a `Packet` instance of the ad-hoc command request to be modified.
        `f_name` - is a `String` instance with the field name. In ad-hoc command terms this is a variable name. This field name (variable name) will be also displayed as the field label.
        `f_value` - is a `String` instance with the field default value.

    - #### addFieldValue

          public static void addFieldValue(Packet packet,
                           String f_name,
                           String f_value,
                           String label,
                           String[] labels,
                           String[] options)

      This method allows to add a new multi-option-select-one data field to the command data form. This is much more complex implementation allowing to set a field label and labels for all provided field options. It allows the end-user to select a single option from a given list.
      Parameters:
        `packet` - is a `Packet` instance of the ad-hoc command request to be modified.
        `f_name` - is a `String` instance with the field name. In ad-hoc command terms this is a variable name.
        `f_value` - is a `String` instance with the field default value. It must match one of the options vaulues provided as a list in 'options' parameter.
        `label` - is a `String` instance with the field label. This time a label set here is displayed to the user instead of the field name (variable name). This is useful if the variable name is not suitable or clear enough to the end-user.
        `labels` - is an array with options labels which are displayed to the end-user upon presenting the selection options.
        `options` - is an array with options values to be selected by the end-user. Normally these values are not displayed to the end-user. Only options labels are.

    - #### addFieldValue

          public static void addFieldValue(Packet packet,
                           String f_name,
                           String[] f_values,
                           String label,
                           String[] labels,
                           String[] options)

      This method allows to add a new multi-option-select-many data field to the command data form. This is much more complex implementation allowing to set a field label and labels for all provided field options. It allows the end-user to select many options from the given list.
      Parameters:
        `packet` - is a `Packet` instance of the ad-hoc command request to be modified.
        `f_name` - is a `String` instance with the field name. In ad-hoc command terms this is a variable name.
        `f_values` - is an array of default values which are presented to the end user as preselected options. They must match options vaulues provided as a list in 'options' parameter.
        `label` - is a `String` instance with the field label. This time a label set here is displayed to the user instead of the field name (variable name). This is useful if the variable name is not suitable or clear enough to the end-user.
        `labels` - is an array with options labels which are displayed to the end-user upon presenting the selection options.
        `options` - is an array with options values to be selected by the end-user. Normally these values are not displayed to the end-user. Only options labels are.

    - #### addFieldValue

          public static void addFieldValue(Packet packet,
                           String f_name,
                           String f_value,
                           String label,
                           String[] labels,
                           String[] options,
                           String type)

      Method description
      Parameters:
        `packet` -
        `f_name` -
        `f_value` -
        `label` -
        `labels` -
        `options` -
        `type` -

    - #### addFieldValue

          public static void addFieldValue(Packet packet,
                           String f_name,
                           String f_value,
                           String type)

      Method description
      Parameters:
        `packet` -
        `f_name` -
        `f_value` -
        `type` -

    - #### addFieldValue

          public static void addFieldValue(Packet packet,
                           String f_name,
                           String f_value,
                           String type,
                           String label)

      Method description
      Parameters:
        `packet` -
        `f_name` -
        `f_value` -
        `type` -
        `label` -

    - #### addHiddenField

          public static void addHiddenField(Packet packet,
                            String f_name,
                            String f_value)

      Method description
      Parameters:
        `packet` -
        `f_name` -
        `f_value` -

    - #### addInstructions

          public static void addInstructions(Packet packet,
                             String instructions)

      Method description
      Parameters:
        `packet` -
        `instructions` -

    - #### addNote

          public static void addNote(Packet packet,
                     String note)

      Method description
      Parameters:
        `packet` -
        `note` -

    - #### addTextField

          public static void addTextField(Packet packet,
                          String f_name,
                          String f_value)

      Method description
      Parameters:
        `packet` -
        `f_name` -
        `f_value` -

    - #### addTitle

          public static void addTitle(Packet packet,
                      String title)

      Method description
      Parameters:
        `packet` -
        `title` -

    - #### createIqCommand

          public static tigase.xml.Element createIqCommand(tigase.xmpp.JID from,
                                           tigase.xmpp.JID to,
                                           StanzaType type,
                                           String id,
                                           String node,
                                           Command.DataType data_type)

      Method description
      Parameters:
        `from` -
        `to` -
        `type` -
        `id` -
        `node` -
        `data_type` -

    - #### getAction

          public static Command.Action getAction(Packet packet)

      Method description
      Parameters:
        `packet` -

    - #### getCheckBoxFieldValue

          public static boolean getCheckBoxFieldValue(Packet packet,
                                      String f_name)

      Method description
      Parameters:
        `packet` -
        `f_name` -

    - #### getData

          public static List<tigase.xml.Element> getData(Packet packet)

      Method description
      Parameters:
        `packet` -

    - #### getData

          public static tigase.xml.Element getData(Packet packet,
                                   String el_name,
                                   String xmlns)

      Method description
      Parameters:
        `packet` -
        `el_name` -
        `xmlns` -

    - #### getFieldValue

          public static String getFieldValue(Packet packet,
                             String f_name)

      Method description
      Parameters:
        `packet` -
        `f_name` -

    - #### getFieldValue

          public static String getFieldValue(Packet packet,
                             String f_name,
                             boolean debug)

      Method description
      Parameters:
        `packet` -
        `f_name` -
        `debug` -

    - #### getFieldValues

          public static String[] getFieldValues(Packet packet,
                                String f_name)

      Method description
      Parameters:
        `packet` -
        `f_name` -

    - #### removeFieldValue

          public static boolean removeFieldValue(Packet packet,
                                 String f_name)

      Method description
      Parameters:
        `packet` -
        `f_name` -

    - #### getFieldKeyStartingWith

          public static String getFieldKeyStartingWith(Packet packet,
                                       String f_name)

      Method description
      Parameters:
        `packet` -
        `f_name` -

    - #### setData

          public static void setData(Packet packet,
                     tigase.xml.Element data)

      Method description
      Parameters:
        `packet` -
        `data` -

    - #### setData

          public static void setData(Packet packet,
                     List<tigase.xml.Element> data)

      Method description
      Parameters:
        `packet` -
        `data` -

    - #### setStatus

          public static void setStatus(Packet packet,
                       Command.Status status)

      Method description
      Parameters:
        `packet` -
        `status` -

    - #### valueof

          public static Command valueof(String cmd)

      Method description
      Parameters:
        `cmd` -

    - #### getPacket

          public Packet getPacket(tigase.xmpp.JID from,
                         tigase.xmpp.JID to,
                         StanzaType type,
                         String id)

      Method description
      Parameters:
        `from` -
        `to` -
        `type` -
        `id` -

    - #### getPacket

          public Packet getPacket(tigase.xmpp.JID from,
                         tigase.xmpp.JID to,
                         StanzaType type,
                         String id,
                         Command.DataType data_type)

      Method description
      Parameters:
        `from` -
        `to` -
        `type` -
        `id` -
        `data_type` -

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