Class Ping
java.lang.Object
org.jivesoftware.openfire.commands.AdHocCommand
org.jivesoftware.openfire.commands.generic.Ping
A (very) basic ad-hoc command that returns the server time in UTC. The ad-hoc command implemented in this class
differs from most others in the fact that it has no restrictions in what entity is allowed to execute/use it.
- Author:
- Guus der Kinderen, guus.der.kinderen@gmail.com
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jivesoftware.openfire.commands.AdHocCommand
AdHocCommand.Action, AdHocCommand.Status
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addStageInformation
(SessionData data, org.dom4j.Element command) Adds to the command element the data form or notes required by the current stage.void
execute
(SessionData data, org.dom4j.Element command) Executes the command with the specified session data.protected List<AdHocCommand.Action>
getActions
(SessionData data) Returns a collection with the allowed actions based on the current stage as defined in the SessionData.getCode()
Returns the unique identifier for this command for the containing JID.Returns the default label used for describing this command.protected AdHocCommand.Action
getExecuteAction
(SessionData data) Returns which of the actions available for the current stage is considered the equivalent to "execute".int
getMaxStages
(SessionData data) Returns the max number of stages for this command.boolean
hasPermission
(org.xmpp.packet.JID requester) Returns true if the requester is allowed to execute this command.Methods inherited from class org.jivesoftware.openfire.commands.AdHocCommand
addNextStageInformation, addPreviousStageInformation, addStageActions, get, getLabel, setLabel
-
Constructor Details
-
Ping
public Ping()
-
-
Method Details
-
getCode
Description copied from class:AdHocCommand
Returns the unique identifier for this command for the containing JID. The code will be used as the node in the disco#items or the node when executing the command.- Specified by:
getCode
in classAdHocCommand
- Returns:
- the unique identifier for this command for the containing JID.
-
getDefaultLabel
Description copied from class:AdHocCommand
Returns the default label used for describing this command. This information is usually used when returning commands as disco#items. Admins can later useAdHocCommand.setLabel(String)
to set a new label and reset to the default value at any time.- Specified by:
getDefaultLabel
in classAdHocCommand
- Returns:
- the default label used for describing this command.
-
getMaxStages
Description copied from class:AdHocCommand
Returns the max number of stages for this command. The number of stages may vary according to the collected data in previous stages. Therefore, a SessionData object is passed as a parameter. When the max number of stages has been reached then the command is ready to be executed.- Specified by:
getMaxStages
in classAdHocCommand
- Parameters:
data
- metadata and the gathered data through the command stages.- Returns:
- the max number of stages for this command.
-
execute
Description copied from class:AdHocCommand
Executes the command with the specified session data.- Specified by:
execute
in classAdHocCommand
- Parameters:
data
- metadata and the gathered data through the command stages.command
- the command element to be sent to the command requester with a reported data result or note element with the answer of the execution.
-
hasPermission
public boolean hasPermission(org.xmpp.packet.JID requester) Description copied from class:AdHocCommand
Returns true if the requester is allowed to execute this command. By default, only admins are allowed to execute commands. Subclasses may redefine this method with any specific logic. Note: The bare JID of the requester will be compared with the bare JID of the admins.- Overrides:
hasPermission
in classAdHocCommand
- Parameters:
requester
- the JID of the user requesting to execute this command.- Returns:
- true if the requester is allowed to execute this command.
-
addStageInformation
Description copied from class:AdHocCommand
Adds to the command element the data form or notes required by the current stage. The current stage is specified in the SessionData. This method will never be invoked for commands that have no stages.- Specified by:
addStageInformation
in classAdHocCommand
- Parameters:
data
- metadata and the gathered data through the command stages.command
- the command element to be sent to the command requester.
-
getActions
Description copied from class:AdHocCommand
Returns a collection with the allowed actions based on the current stage as defined in the SessionData. Possible actions are:prev
,next
andcomplete
. This method will never be invoked for commands that have no stages.- Specified by:
getActions
in classAdHocCommand
- Parameters:
data
- metadata and the gathered data through the command stages.- Returns:
- a collection with the allowed actions based on the current stage as defined in the SessionData.
-
getExecuteAction
Description copied from class:AdHocCommand
Returns which of the actions available for the current stage is considered the equivalent to "execute". When the requester sends his reply, if no action was defined in the command then the action will be assumed "execute" thus assuming the action returned by this method. This method will never be invoked for commands that have no stages.- Specified by:
getExecuteAction
in classAdHocCommand
- Parameters:
data
- metadata and the gathered data through the command stages.- Returns:
- which of the actions available for the current stage is considered the equivalent to "execute".
-