Class FtpConsumerImpl

All Implemented Interfaces:
AdaptrisComponent, AdaptrisMessageConsumer, AdaptrisMessageWorker, ComponentLifecycle, ComponentLifecycleExtension, MessageEventGenerator, StateManagedComponent
Direct Known Subclasses:
FtpConsumer, RelaxedFtpConsumer

public abstract class FtpConsumerImpl extends AdaptrisPollingConsumer
Abstract FTP Implementation of the AdaptrisMessageConsumer implementation.
  • Field Details

  • Constructor Details

    • FtpConsumerImpl

      public FtpConsumerImpl()
  • Method Details

    • init

      public void init() throws CoreException
      Description copied from interface: ComponentLifecycle
      Initialises the component.

      Component initialisation includes config verification, creation of connections etc.

      Specified by:
      init in interface ComponentLifecycle
      Overrides:
      init in class AdaptrisPollingConsumer
      Throws:
      CoreException - wrapping any underlying Exceptions
      See Also:
    • additionalDebug

      protected boolean additionalDebug()
    • oldEnough

      protected boolean oldEnough(String fullPath) throws FileTransferException, IOException
      Throws:
      FileTransferException
      IOException
    • addStandardMetadata

      protected AdaptrisMessage addStandardMetadata(AdaptrisMessage msg, String filename, String dir)
    • processMessages

      protected int processMessages()
      Description copied from class: AdaptrisPollingConsumer

      Implemented by protocol-specific sub-classes.

      Specified by:
      processMessages in class AdaptrisPollingConsumer
    • handle

      protected boolean handle(String fileToGet)
    • fetchAndProcess

      protected abstract boolean fetchAndProcess(String fullPath) throws Exception
      Throws:
      Exception
    • configureWorkDir

      protected String configureWorkDir(String path)
    • accept

      protected boolean accept(String path) throws Exception
      Throws:
      Exception
    • prepareConsumer

      protected void prepareConsumer() throws CoreException
      Specified by:
      prepareConsumer in class AdaptrisPollingConsumer
      Throws:
      CoreException
    • ftpURL

      protected String ftpURL()
    • filterExpression

      protected String filterExpression()
    • fileFilterImp

      protected String fileFilterImp()
    • olderThanMs

      protected long olderThanMs()
    • getQuietInterval

      public TimeInterval getQuietInterval()
    • setQuietInterval

      public void setQuietInterval(TimeInterval interval)
      Specify the time in which a file has been untouched before it is deemed safe to be processed.

      The purpose of this is to delay processing of files that may be currently being written to by another process. On certain platforms (e.g. most Unix) it is still possible to obtain an exclusive lock on the file even though it is being written to by another process.

      Note: your mileage may vary when using this setting. The FTP Server and the FTP Client will almost certainly have to time-synchronized. Depending on the FTP Server implementation in question, you may need to additionally specify the server's timezone in order to get accurate information.Additionally, the remote FTP server needs to support support the MDTM command.

      Parameters:
      interval - the quietPeriod to set (default to 0)
      See Also:
    • consumeLocationKey

      public String consumeLocationKey()
      Provides the metadata key '"fsConsumeDir"' that contains the directory (if not null) where the file was read from.
      Returns:
      the metadata key;
      Since:
      3.9.0
    • getFileFilterImp

      public String getFileFilterImp()
      Set the filename filter implementation that will be used for filtering files.

      The file filter implementation that is used in conjunction with the getFilterExpression(), if not specified, then the default is org.apache.commons.io.filefilter.RegexFileFilter which uses the java.util regular expressions to perform filtering

      The expression that is used to filter messages is derived from getFilterExpression().

      Note that because we working against a remote server, support for additional file attributes such as size (e.g. via SizeGreaterThan) or last modified may not be supported. We encourage you to stick with filtering by filename only.

      See Also:
    • setFileFilterImp

      public void setFileFilterImp(String fileFilterImp)
      Set the filename filter implementation that will be used for filtering files.

      The file filter implementation that is used in conjunction with the getFilterExpression(), if not specified, then the default is org.apache.commons.io.filefilter.RegexFileFilter which uses the java.util regular expressions to perform filtering

      The expression that is used to filter messages is derived from getFilterExpression().

      Note that because we working against a remote server, support for additional file attributes such as size (e.g. via SizeGreaterThan) or last modified may not be supported. We encourage you to stick with filtering by filename only.

      See Also:
    • getFtpEndpoint

      public String getFtpEndpoint()
      The FTP endpoint where we will retrieve files files.

      Although nominally a URL, you can configure the following styles

      • Just the server name / IP Address (e.g. 10.0.0.1) in which case the username and password from the corresponding FileTransferConnection will be used to supply the username and password. You will be working off directly off the perceived root filesystem which will be a problem if you aren't in a chroot jail.
      • A FTP style URL ftp://10.0.0.1/path/to/dir, the username and password will be taken from the corresponding connection. The working directory start with /path/to/dir
      • A FTP style URL with a username/password ftp://user:password@10.0.0.1/path/to/dir. The working directory will start with /path/to/dir
    • setFtpEndpoint

      public void setFtpEndpoint(String ftpEndpoint)
      The FTP endpoint where we will retrieve files files.

      Although nominally a URL, you can configure the following styles

      • Just the server name / IP Address (e.g. 10.0.0.1) in which case the username and password from the corresponding FileTransferConnection will be used to supply the username and password. You will be working off directly off the perceived root filesystem which will be a problem if you aren't in a chroot jail.
      • A FTP style URL ftp://10.0.0.1/path/to/dir, the username and password will be taken from the corresponding connection. The working directory start with /path/to/dir
      • A FTP style URL with a username/password ftp://user:password@10.0.0.1/path/to/dir. The working directory will start with /path/to/dir
    • getFilterExpression

      public String getFilterExpression()
      The filter expression to use when listing files.

      If not specified then will default in a file filter that matches all files.

    • setFilterExpression

      public void setFilterExpression(String filterExpression)
      The filter expression to use when listing files.

      If not specified then will default in a file filter that matches all files.