Class AbstractAdHocCommand
- Direct Known Subclasses:
AdHocCommand
,AdHocCommandHandler
getForm
method retrieves a form with all the users.
Each command has a node
that should be unique within a given JID.
Commands may have zero or more stages. Each stage is usually used for gathering information required for the command execution. Users are able to move forward or backward across the different stages. Commands may not be cancelled while they are being executed. However, users may request the "cancel" action when submitting a stage response indicating that the command execution should be aborted. Thus, releasing any collected information. Commands that require user interaction (i.e. have more than one stage) will have to provide the data forms the user must complete in each stage and the allowed actions the user might perform during each stage (e.g. go to the previous stage or go to the next stage).
All the actions may throw an XMPPException if there is a problem executing them. TheXMPPError
of that exception may have some specific
information about the problem. The possible extensions are:
- malformed-action. Extension of a bad-request error.
- bad-action. Extension of a bad-request error.
- bad-locale. Extension of a bad-request error.
- bad-payload. Extension of a bad-request error.
- bad-sessionid. Extension of a bad-request error.
- session-expired. Extension of a not-allowed error.
See the SpecificErrorCondition
class for detailed description
of each one.
getSpecificErrorConditionFrom
to obtain the specific
information from an XMPPError
.-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractAdHocCommand
(String node) protected
AbstractAdHocCommand
(String node, String name) -
Method Summary
Modifier and TypeMethodDescriptionabstract void
cancel()
Cancels the execution of the command.Returns a collection with the allowed actions based on the current stage.protected AdHocCommandData.AllowedAction
Returns the action available for the current stage which is considered the equivalent to "execute".getName()
Returns the human readable name of the command.getNode()
Returns the unique identifier of the command.getNotes()
Returns the notes that the command has at the current stage.static SpecificErrorCondition
Returns the specific condition of theerror
ornull
if the error doesn't have any.Returns the status of the current stage.boolean
Check if this command has been completed successfully.final boolean
isValidAction
(AdHocCommandData.Action action) Returns true if theaction
is available in the current stage.protected void
setSessionId
(String sessionId)
-
Constructor Details
-
AbstractAdHocCommand
-
AbstractAdHocCommand
-
-
Method Details
-
getSpecificErrorCondition
Returns the specific condition of theerror
ornull
if the error doesn't have any.- Parameters:
error
- the error the get the specific condition from.- Returns:
- the specific condition of this error, or null if it doesn't have any.
-
getName
Returns the human readable name of the command.- Returns:
- the human readable name of the command
-
getNode
Returns the unique identifier of the command. It is unique for theOwnerJID
.- Returns:
- the unique identifier of the command.
-
getSessionId
-
setSessionId
-
getLastRequest
-
getLastResult
-
getNotes
Returns the notes that the command has at the current stage.- Returns:
- a list of notes.
-
cancel
public abstract void cancel() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedExceptionCancels the execution of the command. This can be invoked on any stage of the execution. If there is a problem executing the command it throws an XMPPException.- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there is a problem executing the command.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getActions
Returns a collection with the allowed actions based on the current stage. Possible actions are:prev
,next
andcomplete
. This method will be only invoked for commands that have one or more stages.- Returns:
- a collection with the allowed actions based on the current stage as defined in the SessionData.
-
getExecuteAction
Returns the action available for the current stage which 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.- Returns:
- the action available for the current stage which is considered the equivalent to "execute".
-
getStatus
Returns the status of the current stage.- Returns:
- the current status.
-
isCompleted
Check if this command has been completed successfully.- Returns:
true
if this command is completed.- Since:
- 4.2
-
isValidAction
Returns true if theaction
is available in the current stage. Thecancel
action is always allowed. To define the available actions use theaddActionAvailable
method.- Parameters:
action
- The action to check if it is available.- Returns:
- True if the action is available for the current stage.
-