org.apache.commons.pipeline.stage
Class FtpFileDownloadStage

java.lang.Object
  extended by org.apache.commons.pipeline.stage.BaseStage
      extended by org.apache.commons.pipeline.stage.FtpFileDownloadStage
All Implemented Interfaces:
Stage

public class FtpFileDownloadStage
extends BaseStage

This Stage provides the functionality needed to retrieve data from an FTP URL. Multipart responses are not yet supported.


Nested Class Summary
static interface FtpFileDownloadStage.Criterion
          This class is used to specify a criterion that the downloaded file must satisfy.
static class FtpFileDownloadStage.FileDateMatchCriterion
          Matches files by matching their filesystem timestamp to a date range.
static class FtpFileDownloadStage.FileNameMatchCriterion
          Matches file names based upon the Java regex supplied in the constructor.
static class FtpFileDownloadStage.FileSpec
          This class is used to specify a path and pattern of file for the FtpFileDownload to retrieve.
 
Field Summary
 
Fields inherited from class org.apache.commons.pipeline.stage.BaseStage
context
 
Constructor Summary
FtpFileDownloadStage()
          Default constructor - creates work directory in /tmp
FtpFileDownloadStage(String workDir)
          Constructor specifying work directory.
 
Method Summary
 String getHost()
          Getter for property host.
 int getPort()
          Getter for property port.
 String getUser()
          Getter for property user.
 String getWorkDir()
          Returns the name of the file download directory.
 void preprocess()
          Creates the download directory workDir uf it does not exist and makes a connection to the remote FTP server.
 void process(Object obj)
          Retrieves files that match the specified FileSpec from the FTP server and stores them in the work directory.
 void release()
          Disconnects from FTP server.
 void setHost(String host)
          Setter for property host.
 void setPassword(String password)
          Setter for property password.
 void setPort(int port)
          Setter for property port.
 void setUser(String user)
          Setter for property user.
 void setWorkDir(String workDir)
          Sets the working directory for the file download.
 
Methods inherited from class org.apache.commons.pipeline.stage.BaseStage
emit, emit, init, postprocess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FtpFileDownloadStage

public FtpFileDownloadStage()
Default constructor - creates work directory in /tmp


FtpFileDownloadStage

public FtpFileDownloadStage(String workDir)
Constructor specifying work directory.

Parameters:
workDir - local directory in which to store downloaded files
Method Detail

preprocess

public void preprocess()
                throws StageException
Creates the download directory workDir uf it does not exist and makes a connection to the remote FTP server.

Specified by:
preprocess in interface Stage
Overrides:
preprocess in class BaseStage
Throws:
StageException - if a connection to the remote FTP server cannot be established, or the login to the remote system fails
See Also:
Stage.preprocess()

process

public void process(Object obj)
             throws StageException
Retrieves files that match the specified FileSpec from the FTP server and stores them in the work directory.

Specified by:
process in interface Stage
Overrides:
process in class BaseStage
Parameters:
obj - incoming FtpFileDownloadStage.FileSpec that indicates the file to download along with some flags to control the download behavior
Throws:
StageException - if there are errors navigating the remote directory structure or file download fails

release

public void release()
Disconnects from FTP server. Errors are logged.

Specified by:
release in interface Stage
Overrides:
release in class BaseStage
See Also:
Stage.release()

setWorkDir

public void setWorkDir(String workDir)
Sets the working directory for the file download. If the directory does not already exist, it will be created during the preprocess() step.

Parameters:
workDir - local directory to receive file downloads

getWorkDir

public String getWorkDir()
Returns the name of the file download directory.

Returns:
the string containing the local working directory

getHost

public String getHost()
Getter for property host.

Returns:
Value of property host.

setHost

public void setHost(String host)
Setter for property host.

Parameters:
host - New value of property host.

getUser

public String getUser()
Getter for property user.

Returns:
Value of property user.

setUser

public void setUser(String user)
Setter for property user.

Parameters:
user - New value of property user.

setPassword

public void setPassword(String password)
Setter for property password.

Parameters:
password - New value of property password.

getPort

public int getPort()
Getter for property port.

Returns:
Value of property port.

setPort

public void setPort(int port)
Setter for property port.

Parameters:
port - New value of property port.


Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.