Class AbstractBaseFileTransferTransactionalResourceCommand
- java.lang.Object
-
- org.ikasan.connector.base.command.AbstractTransactionalResourceCommand
-
- org.ikasan.connector.basefiletransfer.outbound.command.AbstractBaseFileTransferTransactionalResourceCommand
-
- All Implemented Interfaces:
org.ikasan.connector.base.command.TransactionalResourceCommand,org.ikasan.connector.listener.TransactionCommitFailureObserverable
- Direct Known Subclasses:
ChecksumDeliveredCommand,ChecksumValidatorCommand,CleanupChunksCommand,DeliverBatchCommand,DeliverFileCommand,FileDiscoveryCommand,RenameFileCommand,RetrieveFileCommand
public abstract class AbstractBaseFileTransferTransactionalResourceCommand extends org.ikasan.connector.base.command.AbstractTransactionalResourceCommand implements org.ikasan.connector.listener.TransactionCommitFailureObserverableThis 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
Fields Modifier and Type Field Description protected static java.lang.StringCURRENT_DIRECTORYcurrent directoryprotected static java.lang.StringEOLEOL characterprotected java.lang.StringfileSeparatorThe file separatorprotected java.util.List<org.ikasan.connector.listener.TransactionCommitFailureListener>listeners
-
Constructor Summary
Constructors Constructor Description AbstractBaseFileTransferTransactionalResourceCommand()Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddListener(org.ikasan.connector.listener.TransactionCommitFailureListener listener)protected voidchangeDirectory(java.lang.String path)Execute a change directory on the server to directory passed inprotected voiddeleteDir(java.lang.String directoryPath, boolean recurse)Deletes a remote directoryprotected voiddeleteFile(java.lang.String filename)Deletes a remote fileorg.ikasan.connector.base.command.ExecutionOutputdoExecute(org.ikasan.connector.base.command.TransactionalResource resource)(non-Javadoc)protected ClientListEntryfindFile(java.lang.String filePath)Find a file in the current directory if it existsprotected FileTransferClientgetClient()Return the FileTransferClientprotected java.io.InputStreamgetContentAsStream(ClientListEntry entry)Get the content from the file as an InputStreamprotected BaseFileTransferMappedRecordgetFile(java.lang.String filePath)Get the SFYPMapped record that is a representation of the fileprotected BaseFileTransferMappedRecordgetFile(ClientListEntry entry)Get the Mapped record that is a representation of the fileprotected java.util.List<ClientListEntry>listDirectory(java.lang.String directory)Return a list of ClientListEntry objectsprotected voidlogFileList(java.util.List<ClientListEntry> list, java.lang.String listDescription)Method used to log a list ofClientListEntryentries.protected voidnotifyListeners(org.ikasan.connector.listener.TransactionCommitException exception)protected abstract org.ikasan.connector.base.command.ExecutionOutputperformExecute()execute method for subclasses to implementprotected java.lang.StringprintWorkingDirectoryName()Returns the working directory nameprotected voidputFile(BaseFileTransferMappedRecord file)Put the file givenprotected voidputWithOutputStream(java.lang.String fileName, java.io.InputStream inputStream)Perform a PUT file operation suing an OutputStreamprotected voidrenameFile(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
-
-
-
-
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
-
listeners
protected java.util.List<org.ikasan.connector.listener.TransactionCommitFailureListener> listeners
-
-
Method Detail
-
doExecute
public org.ikasan.connector.base.command.ExecutionOutput doExecute(org.ikasan.connector.base.command.TransactionalResource resource) throws javax.resource.ResourceException(non-Javadoc)- Specified by:
doExecutein classorg.ikasan.connector.base.command.AbstractTransactionalResourceCommand- Throws:
javax.resource.ResourceException- See Also:
AbstractTransactionalResourceCommand.doExecute(org.ikasan.connector.base.command.TransactionalResource)
-
performExecute
protected abstract org.ikasan.connector.base.command.ExecutionOutput performExecute() throws javax.resource.ResourceExceptionexecute method for subclasses to implement- Returns:
- ExecutionOutput
- Throws:
javax.resource.ResourceException- -
-
printWorkingDirectoryName
protected java.lang.String printWorkingDirectoryName() throws javax.resource.ResourceExceptionReturns the working directory name- Returns:
- working directory name
- Throws:
javax.resource.ResourceException- -
-
changeDirectory
protected void changeDirectory(java.lang.String path) throws javax.resource.ResourceExceptionExecute 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 ofClientListEntryentries. The level of detail logged depends on the runtime logging level.- Parameters:
list- - files in directorylistDescription- -
-
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.ResourceExceptionRename the file from oldPath to newPath- Parameters:
oldPath- Original PathnewPath- 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.ResourceExceptionDeletes 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.ResourceExceptionDeletes a remote directory- Parameters:
directoryPath- - directory to be removedrecurse- - 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 downloading a file fails
-
putWithOutputStream
protected void putWithOutputStream(java.lang.String fileName, java.io.InputStream inputStream) throws javax.resource.ResourceExceptionPerform a PUT file operation suing an OutputStream- Parameters:
fileName- - the file nameinputStream- - 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
-
addListener
public void addListener(org.ikasan.connector.listener.TransactionCommitFailureListener listener)
- Specified by:
addListenerin interfaceorg.ikasan.connector.listener.TransactionCommitFailureObserverable
-
notifyListeners
protected void notifyListeners(org.ikasan.connector.listener.TransactionCommitException exception)
-
-