Package org.jivesoftware.smackx.commands
Class AdHocCommandHandler
- java.lang.Object
-
- org.jivesoftware.smackx.commands.AbstractAdHocCommand
-
- org.jivesoftware.smackx.commands.AdHocCommandHandler
-
- Direct Known Subclasses:
AdHocCommandHandler.SingleStage
public abstract class AdHocCommandHandler extends AbstractAdHocCommand
Represents a command that can be executed locally from a remote location. This class must be extended to implement an specific ad-hoc command. This class provides some useful tools:- Node
- Name
- Session ID
- Current Stage
- Available actions
- Default action
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AdHocCommandHandler.SingleStage
-
Constructor Summary
Constructors Constructor Description AdHocCommandHandler(String node, String name, String sessionId)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract AdHocCommandData
complete(AdHocCommandDataBuilder response, SubmitForm submittedForm)
protected abstract AdHocCommandData
execute(AdHocCommandDataBuilder response)
long
getCreationDate()
Returns the date the command was created.int
getCurrentStage()
Returns the currently executing stage number.boolean
hasPermission(Jid jid)
Returns true if the specified requester has permission to execute all the stages of this action.protected static XMPPException.XMPPErrorException
newBadRequestException(String descriptiveTest)
protected static XMPPException.XMPPErrorException
newXmppErrorException(StanzaError.Condition condition)
protected static XMPPException.XMPPErrorException
newXmppErrorException(StanzaError.Condition condition, String descriptiveText)
protected abstract AdHocCommandData
next(AdHocCommandDataBuilder response, SubmitForm submittedForm)
protected abstract AdHocCommandData
prev(AdHocCommandDataBuilder response)
-
Methods inherited from class org.jivesoftware.smackx.commands.AbstractAdHocCommand
cancel, getActions, getExecuteAction, getLastRequest, getLastResult, getName, getNode, getNotes, getSessionId, getSpecificErrorCondition, getStatus, isCompleted, isValidAction, setSessionId
-
-
-
-
Constructor Detail
-
AdHocCommandHandler
public AdHocCommandHandler(String node, String name, String sessionId)
-
-
Method Detail
-
execute
protected abstract AdHocCommandData execute(AdHocCommandDataBuilder response) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, IllegalStateException
-
next
protected abstract AdHocCommandData next(AdHocCommandDataBuilder response, SubmitForm submittedForm) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, IllegalStateException
-
complete
protected abstract AdHocCommandData complete(AdHocCommandDataBuilder response, SubmitForm submittedForm) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, IllegalStateException
-
prev
protected abstract AdHocCommandData prev(AdHocCommandDataBuilder response) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, IllegalStateException
-
getCreationDate
public long getCreationDate()
Returns the date the command was created.- Returns:
- the date the command was created.
-
hasPermission
public boolean hasPermission(Jid jid)
Returns true if the specified requester has permission to execute all the stages of this action. This is checked when the first request is received, if the permission is grant then the requester will be able to execute all the stages of the command. It is not checked again during the execution.- Parameters:
jid
- the JID to check permissions on.- Returns:
- true if the user has permission to execute this action.
-
getCurrentStage
public final int getCurrentStage()
Returns the currently executing stage number. The first stage number is 1. During the execution of the first action this method will answer 1.- Returns:
- the current stage number.
-
newXmppErrorException
protected static XMPPException.XMPPErrorException newXmppErrorException(StanzaError.Condition condition)
-
newXmppErrorException
protected static XMPPException.XMPPErrorException newXmppErrorException(StanzaError.Condition condition, String descriptiveText)
-
newBadRequestException
protected static XMPPException.XMPPErrorException newBadRequestException(String descriptiveTest)
-
-