Class FTPConnectionImpl

  • All Implemented Interfaces:
    javax.resource.cci.Connection, org.ikasan.connector.BaseFileTransferConnection, org.ikasan.connector.listener.TransactionCommitFailureObserverable

    public class FTPConnectionImpl
    extends org.ikasan.connector.basefiletransfer.outbound.BaseFileTransferConnectionImpl
    This class implements the virtual connection to the FTP server.
    An instance of this class is returned to the clients via the getConnection() method called on
    FTPConnectionFactory by the Application Server. All functionality for the FTP virtual connection is defined in the interface and implemented within this class. In reality much of the work is passed onto the FTPManagedConnection as that does the 'physical work' of talking to the FTP Server
    Author:
    Ikasan Development Team
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected FTPManagedConnection managedConnection
      The managed connection, overrides the definition in the EISConnectionImpl so that we don't have to cast back all of the time
      • Fields inherited from class org.ikasan.connector.basefiletransfer.outbound.BaseFileTransferConnectionImpl

        jaxbContext, listeners, marshaller, REFERENCE_PAYLOAD_ATTRIBUTE, unmarshaller
    • Constructor Summary

      Constructors 
      Constructor Description
      FTPConnectionImpl​(FTPManagedConnection mc, org.ikasan.connector.util.chunking.model.dao.FileChunkDao fileChunkDao, org.ikasan.connector.basefiletransfer.outbound.persistence.BaseFileTransferDao baseFileTransferDao)
      Constructor which takes ManagedConnection as a parameter
      FTPConnectionImpl​(FTPManagedConnection mc, org.ikasan.connector.util.chunking.model.dao.FileChunkDao fileChunkDao, org.ikasan.connector.basefiletransfer.outbound.persistence.BaseFileTransferDao baseFileTransferDao, com.google.common.cache.Cache<java.lang.String,​java.lang.Boolean> duplicateFilesCache)
      Constructor which takes ManagedConnection as a parameter
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Clients call this to indicate that they have finished with a connection.
      void deliverPayload​(org.ikasan.filetransfer.Payload payload, java.lang.String outputDir, java.util.Map<java.lang.String,​java.lang.String> outputTargets, boolean overwrite, java.lang.String renameExtension, boolean checksumDelivered, boolean unzip, boolean cleanup)
      Delivers the content of this Payload using a File Transfer client for chunking use only
      protected org.ikasan.connector.base.command.ExecutionOutput executeCommand​(org.ikasan.connector.base.command.TransactionalResourceCommand command, org.ikasan.connector.base.command.ExecutionContext executionContext)
      Executes a command with a given ExecutionContext
      org.ikasan.filetransfer.Payload getDiscoveredFile​(java.lang.String sourceDir, java.lang.String filenamePattern, boolean renameOnSuccess, java.lang.String renameOnSuccessExtension, boolean moveOnSuccess, java.lang.String moveOnSuccessNewPath, boolean chunking, int chunkSize, boolean checksum, long minAge, boolean destructive, boolean filterDuplicates, boolean filterOnFilename, boolean filterOnLastModifiedDate, boolean chronological, boolean isRecursive, boolean provideRelativePath)  
      org.ikasan.connector.base.command.TransactionalCommandConnection getManagedConnection()
      getManagedConnection is called by the FTPManagedConnection when the application server wants to re-associate a virtual connection with a new manager.
      void housekeep​(int maxRows, int ageOfFiles)
      TODO Non trivial change but this too can go up one level to BaseFileTransferConnectionImpl
      void setManagedConnection​(org.ikasan.connector.base.command.TransactionalCommandConnection managedConnection)
      setManagedConnection is called by the FTPManagedConnection when the application server wants to re-associate a virtual connection with a new manager.
      • Methods inherited from class org.ikasan.connector.basefiletransfer.outbound.BaseFileTransferConnectionImpl

        addListener, addListenersToCommand, createInteraction, deliverInputStream, fileChunkHeaderToPayload, getLocalTransaction, getMetaData, getResultSetInfo, isChunkReference
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • managedConnection

        protected FTPManagedConnection managedConnection
        The managed connection, overrides the definition in the EISConnectionImpl so that we don't have to cast back all of the time
    • Constructor Detail

      • FTPConnectionImpl

        public FTPConnectionImpl​(FTPManagedConnection mc,
                                 org.ikasan.connector.util.chunking.model.dao.FileChunkDao fileChunkDao,
                                 org.ikasan.connector.basefiletransfer.outbound.persistence.BaseFileTransferDao baseFileTransferDao)
        Constructor which takes ManagedConnection as a parameter
        Parameters:
        mc -
        fileChunkDao -
        baseFileTransferDao -
      • FTPConnectionImpl

        public FTPConnectionImpl​(FTPManagedConnection mc,
                                 org.ikasan.connector.util.chunking.model.dao.FileChunkDao fileChunkDao,
                                 org.ikasan.connector.basefiletransfer.outbound.persistence.BaseFileTransferDao baseFileTransferDao,
                                 com.google.common.cache.Cache<java.lang.String,​java.lang.Boolean> duplicateFilesCache)
        Constructor which takes ManagedConnection as a parameter
        Parameters:
        mc -
        fileChunkDao -
        baseFileTransferDao -
        duplicateFilesCache -
    • Method Detail

      • getManagedConnection

        public org.ikasan.connector.base.command.TransactionalCommandConnection getManagedConnection()
        getManagedConnection is called by the FTPManagedConnection when the application server wants to re-associate a virtual connection with a new manager.
      • setManagedConnection

        public void setManagedConnection​(org.ikasan.connector.base.command.TransactionalCommandConnection managedConnection)
        setManagedConnection is called by the FTPManagedConnection when the application server wants to re-associate a virtual connection with a new manager.
        Parameters:
        managedConnection - - The managed connection
      • close

        public void close()
        Clients call this to indicate that they have finished with a connection. Of course, we aren't really going to close anything, we will simply indicate to the manager of this virtual connection that it is now defunct.
      • getDiscoveredFile

        public org.ikasan.filetransfer.Payload getDiscoveredFile​(java.lang.String sourceDir,
                                                                 java.lang.String filenamePattern,
                                                                 boolean renameOnSuccess,
                                                                 java.lang.String renameOnSuccessExtension,
                                                                 boolean moveOnSuccess,
                                                                 java.lang.String moveOnSuccessNewPath,
                                                                 boolean chunking,
                                                                 int chunkSize,
                                                                 boolean checksum,
                                                                 long minAge,
                                                                 boolean destructive,
                                                                 boolean filterDuplicates,
                                                                 boolean filterOnFilename,
                                                                 boolean filterOnLastModifiedDate,
                                                                 boolean chronological,
                                                                 boolean isRecursive,
                                                                 boolean provideRelativePath)
                                                          throws javax.resource.ResourceException
        Throws:
        javax.resource.ResourceException
      • deliverPayload

        public void deliverPayload​(org.ikasan.filetransfer.Payload payload,
                                   java.lang.String outputDir,
                                   java.util.Map<java.lang.String,​java.lang.String> outputTargets,
                                   boolean overwrite,
                                   java.lang.String renameExtension,
                                   boolean checksumDelivered,
                                   boolean unzip,
                                   boolean cleanup)
                            throws javax.resource.ResourceException
        Delivers the content of this Payload using a File Transfer client for chunking use only
        Parameters:
        payload - Payload either containing, or refering to the file content
        outputDir - dir path on remote system to deliver the file or files
        outputTargets - map of output subdirectories for file delivery keyed by regular expression matches on the delivered file name
        overwrite - overwrite any existing files of the same name(s)
        renameExtension - temporary extension to use whilst delivering single file
        checksumDelivered - if true, attempt to reload the delivered file to compare the checksum value
        unzip - if true, attempt to unzip the payload
        cleanup - if true, cleans up any chunked data
        Throws:
        javax.resource.ResourceException - -
      • executeCommand

        protected org.ikasan.connector.base.command.ExecutionOutput executeCommand​(org.ikasan.connector.base.command.TransactionalResourceCommand command,
                                                                                   org.ikasan.connector.base.command.ExecutionContext executionContext)
                                                                            throws javax.resource.ResourceException
        Executes a command with a given ExecutionContext
        Specified by:
        executeCommand in class org.ikasan.connector.basefiletransfer.outbound.BaseFileTransferConnectionImpl
        Parameters:
        command - - The command to execute
        executionContext - - The context of execution
        Returns:
        ExecutionOutput - The output from executing the command
        Throws:
        javax.resource.ResourceException - - Exception from the FTP connector
      • housekeep

        public void housekeep​(int maxRows,
                              int ageOfFiles)
                       throws javax.resource.ResourceException
        TODO Non trivial change but this too can go up one level to BaseFileTransferConnectionImpl
        Parameters:
        maxRows - The maximum amount of rows to housekeep
        ageOfFiles - The age of the files to housekeep
        Throws:
        javax.resource.ResourceException - Exception thrown by the FTP Connector