Class RecursiveOperations

java.lang.Object
com.enterprisedt.net.ftp.RecursiveOperations

public class RecursiveOperations extends Object
Performs various recursive FTP operations. Some operations permit a wildcard string to be supplied for matching filenames (directories are not matched against the wildcard). The syntax used is '?' for single chars and '*' for multiple chars, e.g. 'asdf??df*abc' would match 'asdfxydfdsfsjfkj33abc'. On Windows clients, case is ignored.

Note that if there are a large number of files to be transferred, the client or server may run out of sockets, as a new socket is created for each data transfer and each directory listing. TCP's TIME_WAIT means that sockets are not reclaimed immediately. If sleeping is enabled via setSleepEnabled(true), then Thread.sleep() is called after n transfers, where n is set by setCountBeforeSleep(n). The time spent asleep is set via setSleepTime().

Version:
$Revision$
Author:
Bruce Blackshaw
  • Field Details

    • cvsId

      public static String cvsId
      Revision control id
  • Constructor Details

    • RecursiveOperations

      public RecursiveOperations()
  • Method Details

    • getCountBeforeSleep

      public int getCountBeforeSleep()
      Get the number of transfers set before sleeping
      Returns:
      integer
    • setCountBeforeSleep

      public void setCountBeforeSleep(int countBeforeSleep)
      Set the number of transfers required before sleeping
      Parameters:
      countBeforeSleep - maximum transfer count
    • isSleepEnabled

      public boolean isSleepEnabled()
      Is sleeping enabled?
      Returns:
      true if enabled
    • setSleepEnabled

      public void setSleepEnabled(boolean sleepEnabled)
      Set sleeping enabled to be on or off
      Parameters:
      sleepEnabled - if true, sleeping is enabled, otherwise it is switched off
    • getSleepTime

      public int getSleepTime()
      Get the number of seconds spent asleep
      Returns:
      integer
    • setSleepTime

      public void setSleepTime(int sleepTime)
      Set the time spent asleep
      Parameters:
      sleepTime - sleep time in seconds
    • dirDetails

      public FTPFile[] dirDetails(FTPClientInterface ftp, String remoteDir) throws IOException, FTPException, ParseException
      List this entire remote directory and its contents, including children.
      Parameters:
      ftp - the FTP client reference
      remoteDir - name of remote directory
      Throws:
      IOException
      FTPException
      ParseException
    • delete

      public void delete(FTPClientInterface ftp, String remoteDir) throws IOException, FTPException, ParseException
      Delete this entire remote directory and its contents, recursively going through the remote directory name supplied
      Parameters:
      ftp - the FTP client reference
      remoteDir - name of remote directory
      Throws:
      IOException
      FTPException
      ParseException
    • deleteFilesCurrentDir

      public void deleteFilesCurrentDir(FTPClientInterface ftp, FileFilter filter) throws IOException, FTPException, ParseException
      Delete all the files in this directory (not subdirectories) that match the supplied filter. Only files matching the filter are deleted. On Windows clients, case is ignored.
      Parameters:
      ftp - the FTP client reference
      filter - filename filter
      Throws:
      IOException
      FTPException
      ParseException
    • deleteFiles

      public void deleteFiles(FTPClientInterface ftp, String remoteDir, FileFilter filter, boolean recurse) throws IOException, FTPException, ParseException
      Delete all the files in this directory (and its subdirectories if recurse is true) that match the supplied filter, recursively going through the remote directories. No directories are deleted. Only files matching the filter are deleted. On Windows clients, case is ignored.
      Parameters:
      ftp - the FTP client reference
      remoteDir - name of remote directory
      filter - filename filter
      recurse - true if recursing through subdirectories
      Throws:
      IOException
      FTPException
      ParseException
    • deleteFiles

      public void deleteFiles(FTPClientInterface ftp, FileFilter filter, boolean recurse) throws IOException, FTPException, ParseException
      Delete all the files in the current directory (and its subdirectories if indicated) that match the supplied filter, recursively going through the remote directories. No directories are deleted. Only files matching the filter are deleted. On Windows clients, case is ignored.
      Parameters:
      ftp - the FTP client reference
      filter - filename filter
      recurse - true if recursing through subdirectories
      Throws:
      IOException
      FTPException
      ParseException
    • deleteFiles

      public void deleteFiles(FTPClientInterface ftp, String remoteDir, FileFilter filter) throws IOException, FTPException, ParseException
      Delete all the files in this directory (and its subdirectories) that match the supplied filter, recursively going through the remote directories. No directories are deleted. Only files matching the filter are deleted. On Windows clients, case is ignored.
      Parameters:
      ftp - the FTP client reference
      remoteDir - name of remote directory
      filter - filename filter
      Throws:
      IOException
      FTPException
      ParseException
    • deleteFiles

      public void deleteFiles(FTPClientInterface ftp, String remoteDir, String wildcard) throws IOException, FTPException, ParseException
      Delete all the files in this directory (and its subdirectories) that match the supplied wildcard, recursively going through the remote directories. No directories are deleted. Only files matching the wildcard are fetched. On Windows clients, case is ignored.
      Parameters:
      ftp - the FTP client reference
      remoteDir - name of remote directory
      wildcard - wildcard for filename matching
      Throws:
      IOException
      FTPException
      ParseException
    • getFilesFromCurrentDir

      public void getFilesFromCurrentDir(FTPClientInterface ftp, String localDir, FileFilter filter) throws IOException, FTPException, ParseException
      Gets all files matching the supplied filter from current remote directory into supplied local dir. No directories are retrieved.
      Parameters:
      ftp - the FTP client reference
      localDir - name of local directory to get files into
      filter - filename filter
      Throws:
      IOException
      FTPException
      ParseException
    • get

      public void get(FTPClientInterface ftp, String localDir, String remoteDir) throws IOException, FTPException, ParseException
      Gets this entire remote directory and its contents, recursively going through the remote directory name supplied. Gets the directory into the current local directory, into a directory with supplied localDir name
      Parameters:
      ftp - the FTP client reference
      localDir - name of local directory we are transferring into
      remoteDir - name of remote directory
      Throws:
      IOException
      FTPException
      ParseException
    • get

      public void get(FTPClientInterface ftp, String localDir, String remoteDir, FileFilter filter) throws IOException, FTPException, ParseException
      Gets this entire remote directory and its contents, recursively going through the remote directory name supplied. Gets the directory into the current local directory, into a directory with supplied localDir name. Only files matching the filter are fetched. On Windows clients, case is ignored.
      Parameters:
      ftp - the FTP client reference
      localDir - name of local directory we are transferring into
      remoteDir - name of remote directory
      filter - filename filter
      Throws:
      IOException
      FTPException
      ParseException
    • get

      public void get(FTPClientInterface ftp, String localDir, String remoteDir, String wildcard) throws IOException, FTPException, ParseException
      Gets this entire remote directory and its contents, recursively going through the remote directory name supplied. Gets the directory into the current local directory, into a directory with supplied localDir name. Only files matching the wildcard are fetched. On Windows clients, case is ignored.
      Parameters:
      ftp - the FTP client reference
      localDir - name of local directory we are transferring into
      remoteDir - name of remote directory
      wildcard - wildcard for filename matching
      Throws:
      IOException
      FTPException
      ParseException
    • get

      public void get(FTPClientInterface ftp, String localDir, String remoteDir, FileFilter filter, boolean recurse) throws IOException, FTPException, ParseException
      Gets this entire remote directory and its contents, recursively (if recurse is true) going through the remote directory name supplied. Gets the directory into the current local directory, into a directory with supplied localDir name. Only files matching the filter are fetched. On Windows clients, case is ignored.
      Parameters:
      ftp - the FTP client reference
      localDir - name of local directory we are transferring into
      remoteDir - name of remote directory
      filter - filename filter
      recurse - if true recurse through subdirectories
      Throws:
      IOException
      FTPException
      ParseException
    • putFilesIntoCurrentDir

      public void putFilesIntoCurrentDir(FTPClientInterface ftp, String localDir, FileFilter filter) throws FTPException, IOException
      Puts all files from supplied local dir matching the supplied filter into the current remote directory. No directories are put.
      Parameters:
      ftp - the FTP client reference
      localDir - name of local directory
      Throws:
      FTPException
      IOException
    • put

      public void put(FTPClientInterface ftp, String localDir, String remoteDir) throws FTPException, IOException
      Puts this entire directory and its contents, recursively going through the local directory supplied (which can be relative or absolute. Puts the directory into the current remote directory, into a directory with the supplied remoteDir name.
      Parameters:
      ftp - the FTP client reference
      localDir - name of local directory
      remoteDir - name of remote directory
      Throws:
      FTPException
      IOException
    • put

      public void put(FTPClientInterface ftp, String localDir, String remoteDir, FileFilter filter) throws FTPException, IOException
      Puts this entire directory and its contents, recursively going through the local directory supplied (which can be relative or absolute. Puts the directory into the current remote directory, into a directory with the supplied remoteDir name. Only files matching the filter are fetched. On Windows clients, case is ignored.
      Parameters:
      ftp - the FTP client reference
      localDir - name of local directory
      remoteDir - name of remote directory
      filter - filename filter
      Throws:
      FTPException
      IOException
    • put

      public void put(FTPClientInterface ftp, String localDir, String remoteDir, String wildcard) throws FTPException, IOException
      Puts this entire directory and its contents, recursively going through the local directory supplied (which can be relative or absolute. Puts the directory into the current remote directory, into a directory with the supplied remoteDir name. Only files matching the wildcard are fetched. On Windows clients, case is ignored.
      Parameters:
      ftp - the FTP client reference
      localDir - name of local directory
      remoteDir - name of remote directory
      wildcard - wildcard for filename matching
      Throws:
      FTPException
      IOException
    • put

      public void put(FTPClientInterface ftp, String localDir, String remoteDir, FileFilter filter, boolean recurse) throws FTPException, IOException
      Puts this entire directory and its contents. If recurse is true, it recursively goes through the local directory supplied (which can be relative or absolute. Puts the directory into the current remote directory, into a directory with the supplied remoteDir name. Only files matching the filter are fetched. On Windows clients, case is ignored.
      Parameters:
      ftp - the FTP client reference
      localDir - name of local directory
      remoteDir - name of remote directory, or null if the current remote directory
      filter - filename filter
      Throws:
      FTPException
      IOException