Wildfire 3.2.4 Javadoc

org.jivesoftware.wildfire.commands
Class AdHocCommandHandler

java.lang.Object
  extended by org.jivesoftware.wildfire.container.BasicModule
      extended by org.jivesoftware.wildfire.handler.IQHandler
          extended by org.jivesoftware.wildfire.commands.AdHocCommandHandler
All Implemented Interfaces:
ChannelHandler, Module, DiscoInfoProvider, DiscoItemsProvider, ServerFeaturesProvider

public class AdHocCommandHandler
extends IQHandler
implements ServerFeaturesProvider, DiscoInfoProvider, DiscoItemsProvider

An AdHocCommandHandler is responsbile for providing discoverable information about the supported commands and for handling commands requests. This is an implementation of JEP-50: Ad-Hoc Commands.

Ad-hoc commands that require user interaction will have one or more stages. For each stage the user will complete a data form and send it back to the server. The data entered by the user is kept in a SessionData. Instances of AdHocCommand are stateless. In order to prevent "bad" users from consuming all system memory there exists a limit of simultaneous commands that a user might perform. Configure the system property "xmpp.command.limit" to control this limit. User sessions will also timeout and their data destroyed if they have not been executed within a time limit since the session was created. The default timeout value is 10 minutes. The timeout value can be modified by setting the system property "xmpp.command.timeout".

New commands can be added dynamically by sending the message addCommand(AdHocCommand). The command will immediatelly appear in the disco#items list and might be executed by those users with enough execution permissions.

Author:
Gaston Dombiak

Field Summary
 
Fields inherited from class org.jivesoftware.wildfire.handler.IQHandler
deliverer, sessionManager
 
Constructor Summary
AdHocCommandHandler()
           
 
Method Summary
 void addCommand(AdHocCommand command)
          Adds a new command to the list of supported ad-hoc commands by this server.
 XDataFormImpl getExtendedInfo(String name, String node, JID senderJID)
          Returns an XDataForm with the extended information about the entity or null if none.
 Iterator<String> getFeatures()
          Returns an Iterator (of String) with the supported features by the server.
 Iterator<String> getFeatures(String name, String node, JID senderJID)
          Returns an Iterator (of String) with the supported features.
 Iterator<org.dom4j.Element> getIdentities(String name, String node, JID senderJID)
          Returns an Iterator (of Element) with the target entity's identities.
 IQHandlerInfo getInfo()
          Returns the handler information to help generically handle IQ packets.
 Iterator<org.dom4j.Element> getItems(String name, String node, JID senderJID)
          Returns an Iterator (of Element) with the target entity's items or null if none.
 IQ handleIQ(IQ packet)
          Handles the received IQ packet.
 boolean hasInfo(String name, String node, JID senderJID)
          Returns true if we can provide information related to the requested name and node.
 void initialize(XMPPServer server)
          Initializes the basic module.
 void removeCommand(AdHocCommand command)
          Removes the command from the list of ad-hoc commands supported by this server.
 void start()
          Starts the basic module.
 void stop()
          Stops the basic module.
 
Methods inherited from class org.jivesoftware.wildfire.handler.IQHandler
process
 
Methods inherited from class org.jivesoftware.wildfire.container.BasicModule
destroy, getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdHocCommandHandler

public AdHocCommandHandler()
Method Detail

handleIQ

public IQ handleIQ(IQ packet)
            throws UnauthorizedException
Description copied from class: IQHandler
Handles the received IQ packet.

Specified by:
handleIQ in class IQHandler
Parameters:
packet - the IQ packet to handle.
Returns:
the response to send back.
Throws:
UnauthorizedException - if the user that sent the packet is not authorized to request the given operation.

getInfo

public IQHandlerInfo getInfo()
Description copied from class: IQHandler
Returns the handler information to help generically handle IQ packets. IQHandlers that aren't local server iq handlers (e.g. chatbots, transports, etc) return null.

Specified by:
getInfo in class IQHandler
Returns:
The IQHandlerInfo for this handler

getFeatures

public Iterator<String> getFeatures()
Description copied from interface: ServerFeaturesProvider
Returns an Iterator (of String) with the supported features by the server. The features to include are the features offered and supported protocols by the SERVER. The idea is that different modules may provide their features that will ultimately be part of the features offered by the server.

Specified by:
getFeatures in interface ServerFeaturesProvider
Returns:
an Iterator (of String) with the supported features by the server.

getIdentities

public Iterator<org.dom4j.Element> getIdentities(String name,
                                                 String node,
                                                 JID senderJID)
Description copied from interface: DiscoInfoProvider
Returns an Iterator (of Element) with the target entity's identities. Each Element must include the categoty, type and name attributes of the entity.

Specified by:
getIdentities in interface DiscoInfoProvider
Parameters:
name - the recipient JID's name.
node - the requested disco node.
senderJID - the XMPPAddress of user that sent the disco info request.
Returns:
an Iterator (of Element) with the target entity's identities.

getFeatures

public Iterator<String> getFeatures(String name,
                                    String node,
                                    JID senderJID)
Description copied from interface: DiscoInfoProvider
Returns an Iterator (of String) with the supported features. The features to include are the features offered and supported protocols by the target entity identified by the requested name and node.

Specified by:
getFeatures in interface DiscoInfoProvider
Parameters:
name - the recipient JID's name.
node - the requested disco node.
senderJID - the XMPPAddress of user that sent the disco info request.
Returns:
an Iterator (of String) with the supported features.

getExtendedInfo

public XDataFormImpl getExtendedInfo(String name,
                                     String node,
                                     JID senderJID)
Description copied from interface: DiscoInfoProvider
Returns an XDataForm with the extended information about the entity or null if none. Each bit of information about the entity must be included as a value of a field of the form.

Specified by:
getExtendedInfo in interface DiscoInfoProvider
Parameters:
name - the recipient JID's name.
node - the requested disco node.
senderJID - the XMPPAddress of user that sent the disco info request.
Returns:
an XDataForm with the extended information about the entity or null if none.

hasInfo

public boolean hasInfo(String name,
                       String node,
                       JID senderJID)
Description copied from interface: DiscoInfoProvider
Returns true if we can provide information related to the requested name and node. For example, if the requested name refers to a non-existant MUC room then the answer will be false. In case that the sender of the disco request is not authorized to discover this information an UnauthorizedException will be thrown.

Specified by:
hasInfo in interface DiscoInfoProvider
Parameters:
name - the recipient JID's name.
node - the requested disco node.
senderJID - the XMPPAddress of user that sent the disco info request.
Returns:
true if we can provide information related to the requested name and node.

getItems

public Iterator<org.dom4j.Element> getItems(String name,
                                            String node,
                                            JID senderJID)
Description copied from interface: DiscoItemsProvider
Returns an Iterator (of Element) with the target entity's items or null if none. Each Element must include a JID attribute and may include the name and node attributes of the entity. In case that the sender of the disco request is not authorized to discover items an UnauthorizedException will be thrown.

Specified by:
getItems in interface DiscoItemsProvider
Parameters:
name - the recipient JID's name.
node - the requested disco node.
senderJID - the XMPPAddress of user that sent the disco items request.
Returns:
an Iterator (of Element) with the target entity's items or null if none.

initialize

public void initialize(XMPPServer server)
Description copied from class: BasicModule

Initializes the basic module.

Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.

Specified by:
initialize in interface Module
Overrides:
initialize in class IQHandler
Parameters:
server - the server hosting this module.

start

public void start()
           throws IllegalStateException
Description copied from class: BasicModule

Starts the basic module.

Inheriting classes that choose to override this method MUST call this start() method before accessing BasicModule resources.

Specified by:
start in interface Module
Overrides:
start in class BasicModule
Throws:
IllegalStateException - If start is called before initialize successfully returns

stop

public void stop()
Description copied from class: BasicModule

Stops the basic module.

Inheriting classes that choose to override this method MUST call this stop() method before accessing BasicModule resources.

Specified by:
stop in interface Module
Overrides:
stop in class BasicModule

addCommand

public void addCommand(AdHocCommand command)
Adds a new command to the list of supported ad-hoc commands by this server. The new command will appear in the discoverable items list and will be executed for those users with enough permission.

Parameters:
command - the new ad-hoc command to add.

removeCommand

public void removeCommand(AdHocCommand command)
Removes the command from the list of ad-hoc commands supported by this server. The command will no longer appear in the discoverable items list.

Parameters:
command - the ad-hoc command to remove.

Wildfire 3.2.4 Javadoc

Copyright © 2003-2007 Jive Software.