org.ikasan.connector.basefiletransfer.outbound.command
Class AbstractBaseFileTransferTransactionalResourceCommand

java.lang.Object
  extended by org.ikasan.connector.base.command.AbstractTransactionalResourceCommand
      extended by org.ikasan.connector.basefiletransfer.outbound.command.AbstractBaseFileTransferTransactionalResourceCommand
All Implemented Interfaces:
TransactionalResourceCommand
Direct Known Subclasses:
ChecksumDeliveredCommand, ChecksumValidatorCommand, CleanupChunksCommand, DeliverBatchCommand, DeliverFileCommand, FileDiscoveryCommand, RenameFileCommand, RetrieveFileCommand

public abstract class AbstractBaseFileTransferTransactionalResourceCommand
extends AbstractTransactionalResourceCommand

This is the base class for all FileTransfer oriented TranasactionalResourceCommands This exists simply to provide access to all common low level File Transfer operations

Author:
Ikasan Development Team

Field Summary
protected static java.lang.String CURRENT_DIRECTORY
          current directory
protected static java.lang.String EOL
          EOL character
protected  java.lang.String fileSeparator
          The file separator
 
Fields inherited from class org.ikasan.connector.base.command.AbstractTransactionalResourceCommand
COMMIT_IN_PROGRESS, COMPLETED_COMMITTING, EXECUTED_STATE, EXECUTION_IN_PROGRESS, executionContext, INITIALISED_STATE, ROLLBACK_IN_PROGRESS, ROLLED_BACK_STATE, transactionalResource
 
Constructor Summary
AbstractBaseFileTransferTransactionalResourceCommand()
          Constructor
 
Method Summary
protected  void changeDirectory(java.lang.String path)
          Execute a change directory on the server to directory passed in
protected  void deleteDir(java.lang.String directoryPath, boolean recurse)
          Deletes a remote directory
protected  void deleteFile(java.lang.String filename)
          Deletes a remote file
 ExecutionOutput doExecute(TransactionalResource resource)
          (non-Javadoc)
protected  ClientListEntry findFile(java.lang.String filePath)
          Find a file in the current directory if it exists
protected  FileTransferClient getClient()
          Return the FileTransferClient
protected  java.io.InputStream getContentAsStream(ClientListEntry entry)
          Get the content from the file as an InputStream
protected  BaseFileTransferMappedRecord getFile(ClientListEntry entry)
          Get the Mapped record that is a representation of the file
protected  BaseFileTransferMappedRecord getFile(java.lang.String filePath)
          Get the SFYPMapped record that is a representation of the file
protected  java.util.List<ClientListEntry> listDirectory(java.lang.String directory)
          Return a list of ClientListEntry objects
protected  void logFileList(java.util.List<ClientListEntry> list, java.lang.String listDescription)
          Method used to log a list of ClientListEntry entries.
protected abstract  ExecutionOutput performExecute()
          execute method for subclasses to implement
protected  java.lang.String printWorkingDirectoryName()
          Returns the working directory name
protected  void putFile(BaseFileTransferMappedRecord file)
          Put the file given
protected  void putWithOutputStream(java.lang.String fileName, java.io.InputStream inputStream)
          Perform a PUT file operation suing an OutputStream
protected  void renameFile(java.lang.String oldPath, java.lang.String newPath)
          Rename the file from oldPath to newPath
 
Methods inherited from class org.ikasan.connector.base.command.AbstractTransactionalResourceCommand
commit, doCommit, doRollback, execute, getBeanFactory, getExecutionTimestamp, getId, getState, getXid, rollback, setBeanFactory, setExecutionContext, setTransactionalResource, setTransactionJournal, setXid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EOL

protected static final java.lang.String EOL
EOL character


CURRENT_DIRECTORY

protected static final java.lang.String CURRENT_DIRECTORY
current directory

See Also:
Constant Field Values

fileSeparator

protected java.lang.String fileSeparator
The file separator

Constructor Detail

AbstractBaseFileTransferTransactionalResourceCommand

public AbstractBaseFileTransferTransactionalResourceCommand()
Constructor

Method Detail

doExecute

public ExecutionOutput doExecute(TransactionalResource resource)
                          throws javax.resource.ResourceException
(non-Javadoc)

Specified by:
doExecute in class AbstractTransactionalResourceCommand
Throws:
javax.resource.ResourceException
See Also:
AbstractTransactionalResourceCommand.doExecute(org.ikasan.connector.base.command.TransactionalResource)

performExecute

protected abstract ExecutionOutput performExecute()
                                           throws javax.resource.ResourceException
execute method for subclasses to implement

Returns:
ExecutionOutput
Throws:
javax.resource.ResourceException - -

printWorkingDirectoryName

protected java.lang.String printWorkingDirectoryName()
                                              throws javax.resource.ResourceException
Returns the working directory name

Returns:
working directory name
Throws:
javax.resource.ResourceException - -

changeDirectory

protected void changeDirectory(java.lang.String path)
                        throws javax.resource.ResourceException
Execute a change directory on the server to directory passed in

Parameters:
path - Path to change directory to
Throws:
javax.resource.ResourceException - -

listDirectory

protected java.util.List<ClientListEntry> listDirectory(java.lang.String directory)
                                                 throws javax.resource.ResourceException
Return a list of ClientListEntry objects

Parameters:
directory - The directory we are listing on
Returns:
A list of ClientListEntry
Throws:
javax.resource.ResourceException - -

logFileList

protected void logFileList(java.util.List<ClientListEntry> list,
                           java.lang.String listDescription)
Method used to log a list of ClientListEntry entries. The level of detail logged depends on the runtime logging level.

Parameters:
list - - files in directory
listDescription - -

getFile

protected BaseFileTransferMappedRecord getFile(ClientListEntry entry)
                                        throws javax.resource.ResourceException
Get the Mapped record that is a representation of the file

Parameters:
entry - A wrapper that holds the information we need to get the file
Returns:
The BaseFileTransferMappedRecord representing the file
Throws:
javax.resource.ResourceException - failure to perform get

getFile

protected BaseFileTransferMappedRecord getFile(java.lang.String filePath)
                                        throws javax.resource.ResourceException
Get the SFYPMapped record that is a representation of the file

Parameters:
filePath - The path to the file
Returns:
The BaseFileTransferMappedRecord representing the file
Throws:
javax.resource.ResourceException - - failure to perform get

renameFile

protected void renameFile(java.lang.String oldPath,
                          java.lang.String newPath)
                   throws javax.resource.ResourceException
Rename the file from oldPath to newPath

Parameters:
oldPath - Original Path
newPath - New Path
Throws:
javax.resource.ResourceException - when renaming a file fails

putFile

protected void putFile(BaseFileTransferMappedRecord file)
                throws javax.resource.ResourceException
Put the file given

Parameters:
file - - the file
Throws:
javax.resource.ResourceException - when sending a file

deleteFile

protected void deleteFile(java.lang.String filename)
                   throws javax.resource.ResourceException
Deletes a remote file

Parameters:
filename - - for file to be deleted
Throws:
javax.resource.ResourceException - when removing a file fails

deleteDir

protected void deleteDir(java.lang.String directoryPath,
                         boolean recurse)
                  throws javax.resource.ResourceException
Deletes a remote directory

Parameters:
directoryPath - - directory to be removed
recurse - - flag to delete directory recursively or not.
Throws:
javax.resource.ResourceException - when deleting a file fails

getContentAsStream

protected java.io.InputStream getContentAsStream(ClientListEntry entry)
                                          throws javax.resource.ResourceException
Get the content from the file as an InputStream

Parameters:
entry - - the file
Returns:
content as an InputStream
Throws:
javax.resource.ResourceException - when downloding a file gails

putWithOutputStream

protected void putWithOutputStream(java.lang.String fileName,
                                   java.io.InputStream inputStream)
                            throws javax.resource.ResourceException
Perform a PUT file operation suing an OutputStream

Parameters:
fileName - - the file name
inputStream - - file content as an input stream
Throws:
javax.resource.ResourceException - when sending a file fails

findFile

protected ClientListEntry findFile(java.lang.String filePath)
                            throws javax.resource.ResourceException
Find a file in the current directory if it exists

Parameters:
filePath - - where to look for file
Returns:
file represented as a ClientListEntry
Throws:
javax.resource.ResourceException - when finding the file fails

getClient

protected FileTransferClient getClient()
Return the FileTransferClient

Returns:
FileTransferClient


Copyright © 2007-2010 Ikasan. All Rights Reserved.