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(java.lang.String node, java.lang.String name, java.lang.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(org.jxmpp.jid.Jid jid)
Returns true if the specified requester has permission to execute all the stages of this action.protected static org.jivesoftware.smack.XMPPException.XMPPErrorException
newBadRequestException(java.lang.String descriptiveTest)
protected static org.jivesoftware.smack.XMPPException.XMPPErrorException
newXmppErrorException(org.jivesoftware.smack.packet.StanzaError.Condition condition)
protected static org.jivesoftware.smack.XMPPException.XMPPErrorException
newXmppErrorException(org.jivesoftware.smack.packet.StanzaError.Condition condition, java.lang.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
-
-
-
-
Method Detail
-
execute
protected abstract AdHocCommandData execute(AdHocCommandDataBuilder response) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException, java.lang.IllegalStateException
- Throws:
org.jivesoftware.smack.SmackException.NoResponseException
org.jivesoftware.smack.XMPPException.XMPPErrorException
org.jivesoftware.smack.SmackException.NotConnectedException
java.lang.InterruptedException
java.lang.IllegalStateException
-
next
protected abstract AdHocCommandData next(AdHocCommandDataBuilder response, SubmitForm submittedForm) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException, java.lang.IllegalStateException
- Throws:
org.jivesoftware.smack.SmackException.NoResponseException
org.jivesoftware.smack.XMPPException.XMPPErrorException
org.jivesoftware.smack.SmackException.NotConnectedException
java.lang.InterruptedException
java.lang.IllegalStateException
-
complete
protected abstract AdHocCommandData complete(AdHocCommandDataBuilder response, SubmitForm submittedForm) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException, java.lang.IllegalStateException
- Throws:
org.jivesoftware.smack.SmackException.NoResponseException
org.jivesoftware.smack.XMPPException.XMPPErrorException
org.jivesoftware.smack.SmackException.NotConnectedException
java.lang.InterruptedException
java.lang.IllegalStateException
-
prev
protected abstract AdHocCommandData prev(AdHocCommandDataBuilder response) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException, java.lang.IllegalStateException
- Throws:
org.jivesoftware.smack.SmackException.NoResponseException
org.jivesoftware.smack.XMPPException.XMPPErrorException
org.jivesoftware.smack.SmackException.NotConnectedException
java.lang.InterruptedException
java.lang.IllegalStateException
-
getCreationDate
public long getCreationDate()
Returns the date the command was created.- Returns:
- the date the command was created.
-
hasPermission
public boolean hasPermission(org.jxmpp.jid.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 org.jivesoftware.smack.XMPPException.XMPPErrorException newXmppErrorException(org.jivesoftware.smack.packet.StanzaError.Condition condition)
-
newXmppErrorException
protected static org.jivesoftware.smack.XMPPException.XMPPErrorException newXmppErrorException(org.jivesoftware.smack.packet.StanzaError.Condition condition, java.lang.String descriptiveText)
-
newBadRequestException
protected static org.jivesoftware.smack.XMPPException.XMPPErrorException newBadRequestException(java.lang.String descriptiveTest)
-
-