Class 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
    To implement a new command extend this class and implement all the abstract methods. When implementing the actions remember that they could be invoked several times, and that you must use the current stage number to know what to do.
    • Constructor Detail

      • AdHocCommandHandler

        public AdHocCommandHandler​(java.lang.String node,
                                   java.lang.String name,
                                   java.lang.String sessionId)
    • 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)