org.mule.tck.util.ftp
Class FtpClient

java.lang.Object
  extended by org.mule.tck.util.ftp.FtpClient

public class FtpClient
extends Object

Ftp client wrapper for working with an FTP server.


Field Summary
protected  Log logger
           
static int TIMEOUT
           
 
Constructor Summary
FtpClient(String server, int port, String user, String password)
           
 
Method Summary
protected  void connect()
          Initiate a connection to the ftp server
 boolean deleteDir(String dir)
          Delete a directory
 boolean deleteFile(String name)
          Delete a single file.
 boolean dirExists(String path)
          Check if a directory exists by trying to go to it
 void disconnect()
          Disconnect the ftp client
 boolean expectFileCount(String directory, int count, long timeout)
          Verify that a number of files exist on the ftp server
 boolean fileExists(String file)
          Check if a file exists on the ftp server
 String[] getFileList(String path)
          Get a list of file names in a given directory for admin
 boolean isConnected()
          Check if the ftp client is connected
 boolean makeDir(String dir)
          Create a directory
 boolean putFile(String fileName, String targetDir)
          Upload a file to the ftp server
 boolean putFile(String fileName, String targetDir, String fileContent)
          Upload a file to the ftp server
 void recursiveDelete(String path)
          Delete all files and subdirectories.
 boolean testConnection()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final transient Log logger

TIMEOUT

public static final int TIMEOUT
See Also:
Constant Field Values
Constructor Detail

FtpClient

public FtpClient(String server,
                 int port,
                 String user,
                 String password)
Method Detail

testConnection

public boolean testConnection()
                       throws IOException
Throws:
IOException

getFileList

public String[] getFileList(String path)
                     throws IOException
Get a list of file names in a given directory for admin

Returns:
List of files/directories
Throws:
IOException

makeDir

public boolean makeDir(String dir)
                throws IOException
Create a directory

Parameters:
dir -
Returns:
true if successful, false if not
Throws:
IOException

deleteDir

public boolean deleteDir(String dir)
                  throws IOException
Delete a directory

Parameters:
dir - The directory to delete
Returns:
true if successful, false if not
Throws:
IOException

putFile

public boolean putFile(String fileName,
                       String targetDir)
                throws IOException
Upload a file to the ftp server

Parameters:
fileName - The file to upload
Returns:
true if successful, false if not
Throws:
IOException

putFile

public boolean putFile(String fileName,
                       String targetDir,
                       String fileContent)
                throws IOException
Upload a file to the ftp server

Parameters:
fileName - The file to upload
Returns:
true if successful, false if not
Throws:
IOException

dirExists

public boolean dirExists(String path)
                  throws IOException
Check if a directory exists by trying to go to it

Parameters:
path - The directory to try
Returns:
True if the directory exists, false if not
Throws:
IOException

recursiveDelete

public void recursiveDelete(String path)
                     throws IOException
Delete all files and subdirectories. Note: extra slashes are ignored by the ftp server, so I didn't bother to filter them out

Throws:
IOException

connect

protected void connect()
                throws IOException
Initiate a connection to the ftp server

Throws:
IOException

isConnected

public boolean isConnected()
Check if the ftp client is connected

Returns:
true if connected, false if not

disconnect

public void disconnect()
                throws IOException
Disconnect the ftp client

Throws:
IOException

fileExists

public boolean fileExists(String file)
                   throws IOException
Check if a file exists on the ftp server

Parameters:
file - The name of the file to check
Returns:
true if file exists, false if not
Throws:
IOException

deleteFile

public boolean deleteFile(String name)
                   throws IOException
Delete a single file.

Parameters:
name - The file to delete
Returns:
true if successful, false if not
Throws:
IOException

expectFileCount

public boolean expectFileCount(String directory,
                               int count,
                               long timeout)
                        throws InterruptedException,
                               IOException
Verify that a number of files exist on the ftp server

Parameters:
directory - The remote directory to check
timeout - The max time to wait
Returns:
true if the file count matches before the timeout, false if not
Throws:
InterruptedException
IOException


Copyright © 2003-2014 MuleSoft, Inc.. All Rights Reserved.