Class FtpDirectoryLister

    • Field Detail

      • m_Host

        protected String m_Host
        the FTP host.
      • m_User

        protected String m_User
        the FTP user to use.
      • m_Password

        protected BasePassword m_Password
        the FTP password to use.
      • m_UsePassiveMode

        protected boolean m_UsePassiveMode
        whether to use passive mode.
      • m_UseBinaryMode

        protected boolean m_UseBinaryMode
        whether to use binary file transfer mode.
      • m_Client

        protected transient org.apache.commons.net.ftp.FTPClient m_Client
        the FTP session.
    • Constructor Detail

      • FtpDirectoryLister

        public FtpDirectoryLister()
    • Method Detail

      • setHost

        public void setHost​(String value)
        Sets the host to connect to.
        Parameters:
        value - the host name/ip
      • getHost

        public String getHost()
        Returns the host to connect to.
        Returns:
        the host name/ip
      • setUser

        public void setUser​(String value)
        Sets the FTP user to use.
        Parameters:
        value - the user name
      • getUser

        public String getUser()
        Returns the FTP user name to use.
        Returns:
        the user name
      • setUsePassiveMode

        public void setUsePassiveMode​(boolean value)
        Sets whether to use passive mode.
        Parameters:
        value - if true passive mode is used
      • getUsePassiveMode

        public boolean getUsePassiveMode()
        Returns whether passive mode is used.
        Returns:
        true if passive mode is used
      • setUseBinaryMode

        public void setUseBinaryMode​(boolean value)
        Sets whether to use binary mode.
        Parameters:
        value - if true binary mode is used
      • getUseBinaryMode

        public boolean getUseBinaryMode()
        Returns whether binary mode is used.
        Returns:
        true if binary mode is used
      • setClient

        public void setClient​(org.apache.commons.net.ftp.FTPClient value)
        Sets the client to use.
        Parameters:
        value - the client
      • getClient

        public org.apache.commons.net.ftp.FTPClient getClient()
        Returns the current session provider.
        Returns:
        the client, null if none set
      • newClient

        protected org.apache.commons.net.ftp.FTPClient newClient()
        Returns a new client for the host defined in the options.
        Returns:
        the client, null if failed to create
      • disconnect

        protected void disconnect​(org.apache.commons.net.ftp.FTPClient client)
        Disconnects the SSH session, if necessary.
        Parameters:
        client - the client to disconnect
      • isLocal

        public boolean isLocal()
        Returns whether the directory lister operates locally or remotely.
        Specified by:
        isLocal in interface DirectoryLister
        Returns:
        true if local lister
      • hasParentDirectory

        public boolean hasParentDirectory()
        Returns whether the watch directory has a parent directory.
        Specified by:
        hasParentDirectory in interface DirectoryLister
        Returns:
        true if parent directory available
      • newDirectory

        public FtpFileObject newDirectory​(String dir)
        Returns a new directory relative to the watch directory.
        Specified by:
        newDirectory in interface DirectoryLister
        Parameters:
        dir - the directory name
        Returns:
        the new wrapper
      • newDirectory

        public FtpFileObject newDirectory​(String parent,
                                          String dir)
        Returns a new directory generated from parent and sub-directory.
        Specified by:
        newDirectory in interface DirectoryLister
        Parameters:
        parent - the parent directory
        dir - the directory name
        Returns:
        the new wrapper
      • search

        protected void search​(org.apache.commons.net.ftp.FTPClient client,
                              String current,
                              List<SortContainer> files,
                              int depth)
                       throws Exception
        Performs the recursive search. Search goes deeper if != 0 (use -1 to start with for infinite search).
        Parameters:
        client - the client to use
        current - the current directory
        files - the files collected so far
        depth - the depth indicator (searched no deeper, if 0)
        Throws:
        Exception - if listing fails
      • search

        public List<FtpFileObject> search​(org.apache.commons.net.ftp.FTPClient client)
                                   throws Exception
        Returns the list of files/directories in the watched directory. In case the execution gets stopped, this method returns a 0-length array.
        Parameters:
        client - the FTP client to use
        Returns:
        the list of absolute file/directory names
        Throws:
        Exception - if listing fails
      • list

        public String[] list()
        Returns the list of files/directories in the watched directory. In case the execution gets stopped, this method returns a 0-length array.
        Specified by:
        list in interface DirectoryLister
        Returns:
        the list of absolute file/directory names
      • listObjects

        public FtpFileObject[] listObjects()
        Returns the list of files/directories in the watched directory. In case the execution gets stopped, this method returns a 0-length array.
        Specified by:
        listObjects in interface DirectoryLister
        Returns:
        the list of file/directory wrappers
      • protocolCommandSent

        public void protocolCommandSent​(org.apache.commons.net.ProtocolCommandEvent event)
        This method is invoked by a ProtocolCommandEvent source after sending a protocol command to a server.
        Specified by:
        protocolCommandSent in interface org.apache.commons.net.ProtocolCommandListener
        Parameters:
        event - The ProtocolCommandEvent fired.
      • protocolReplyReceived

        public void protocolReplyReceived​(org.apache.commons.net.ProtocolCommandEvent event)
        This method is invoked by a ProtocolCommandEvent source after receiving a reply from a server.
        Specified by:
        protocolReplyReceived in interface org.apache.commons.net.ProtocolCommandListener
        Parameters:
        event - The ProtocolCommandEvent fired.