public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReplyProducingMessageHandler
Modifier and Type | Class and Description |
---|---|
static class |
AbstractRemoteFileOutboundGateway.Command
Enumeration of commands supported by the gateways.
|
static class |
AbstractRemoteFileOutboundGateway.Option
Enumeration of options supported by various commands.
|
AbstractReplyProducingMessageHandler.RequestHandler
IntegrationManagement.ManagementOverrides
messagingTemplate
EXPRESSION_PARSER, logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Constructor and Description |
---|
AbstractRemoteFileOutboundGateway(RemoteFileTemplate<F> remoteFileTemplate,
AbstractRemoteFileOutboundGateway.Command command,
String expressionArg)
Construct an instance with the supplied remote file template, a command ('ls',
'get' etc), and an expression to determine the filename.
|
AbstractRemoteFileOutboundGateway(RemoteFileTemplate<F> remoteFileTemplate,
MessageSessionCallback<F,?> messageSessionCallback)
Construct an instance with the supplied remote file template and callback
for performing operations on the session.
|
AbstractRemoteFileOutboundGateway(RemoteFileTemplate<F> remoteFileTemplate,
String command,
String expression)
Construct an instance with the supplied remote file template, a command ('ls',
'get' etc), and an expression to determine the filename.
|
AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory,
AbstractRemoteFileOutboundGateway.Command command,
String expression)
Construct an instance with the supplied session factory, a command ('ls', 'get'
etc), and an expression to determine the filename.
|
AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory,
MessageSessionCallback<F,?> messageSessionCallback)
Construct an instance using the provided session factory and callback for
performing operations on the session.
|
AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory,
String command,
String expression)
Construct an instance with the supplied session factory, a command ('ls', 'get'
etc), and an expression to determine the filename.
|
Modifier and Type | Method and Description |
---|---|
protected abstract List<AbstractFileInfo<F>> |
asFileInfoList(Collection<F> files) |
protected void |
assertRemoteFileTemplateMutability(String propertyName) |
protected void |
doChmod(RemoteFileOperations<F> remoteFileOperations,
String path,
int chmodToSet)
Set the mode on the remote file after transfer; the default implementation does
nothing.
|
protected void |
doInit() |
protected abstract F |
enhanceNameWithSubDirectory(F file,
String directory) |
protected List<F> |
filterFiles(F[] files) |
protected List<File> |
filterMputFiles(File[] files) |
protected File |
get(Message<?> message,
Session<F> session,
String remoteDir,
String remoteFilePath,
String remoteFilename,
F fileInfoParam)
Copy a remote file to the configured local directory.
|
protected abstract String |
getFilename(AbstractFileInfo<F> file) |
protected abstract String |
getFilename(F file) |
protected abstract long |
getModified(F file) |
protected String |
getRemoteFilename(String remoteFilePath) |
protected RemoteFileTemplate<F> |
getRemoteFileTemplate() |
protected Object |
handleRequestMessage(Message<?> requestMessage)
Subclasses must implement this method to handle the request Message.
|
boolean |
isChmodCapable() |
protected abstract boolean |
isDirectory(F file) |
protected abstract boolean |
isLink(F file) |
protected List<?> |
ls(Message<?> message,
Session<F> session,
String dir)
List remote files to local representation.
|
protected List<File> |
mGet(Message<?> message,
Session<F> session,
String remoteDirectory,
String remoteFilename) |
protected List<String> |
mPut(Message<?> message,
Session<F> session,
File localDir)
Put files from the provided directory to the remote server recursively.
|
protected boolean |
mv(Message<?> message,
Session<F> session,
String remoteFilePath,
String remoteFileNewPath)
Move one remote path to another.
|
protected List<String> |
nlst(Message<?> message,
Session<F> session,
String dir)
List remote files names for the provided directory.
|
protected void |
purgeDots(List<F> lsFiles) |
protected void |
purgeLinks(List<F> lsFiles) |
protected String |
put(Message<?> message,
Session<F> session,
String subDirectory)
Put the file based on the message to the remote server.
|
protected void |
remoteFileTemplateExplicitlySet(boolean remoteFileTemplateExplicitlySet) |
protected boolean |
rm(Message<?> message,
Session<F> session,
String remoteFilePath)
Perform remote delete for the provided path.
|
void |
setAutoCreateDirectory(boolean autoCreateDirectory)
Determine whether the remote directory should automatically be created when
sending files to the remote system.
|
void |
setAutoCreateLocalDirectory(boolean autoCreateLocalDirectory)
A
boolean flag to identify if local directory should be created automatically. |
void |
setCharset(String charset)
Set the charset to use when converting String payloads to bytes as the content of the
remote file.
|
void |
setChmod(int chmod)
Set the file permissions after uploading, e.g.
|
void |
setChmodOctal(String chmod)
String setter for Spring XML convenience.
|
void |
setFileExistsMode(FileExistsMode fileExistsMode)
Determine the action to take when using GET and MGET operations when the file
already exists locally, or PUT and MPUT when the file exists on the remote
system.
|
void |
setFileNameExpression(Expression fileNameExpression)
Set the file name expression to determine the full path to the remote file.
|
void |
setFileNameGenerator(FileNameGenerator fileNameGenerator)
Set the file name generator used to generate the remote filename to be used when transferring
files to the remote system.
|
void |
setFilter(FileListFilter<F> filter)
Set a
FileListFilter to filter remote files. |
void |
setLocalDirectory(File localDirectory)
Specify a directory path where remote files will be transferred to.
|
void |
setLocalDirectoryExpression(Expression localDirectoryExpression)
Specify a SpEL expression to evaluate the directory path to which remote files will
be transferred.
|
void |
setLocalDirectoryExpressionString(String localDirectoryExpression)
Specify a SpEL expression to evaluate the directory path to which remote files will
be transferred.
|
void |
setLocalFilenameGeneratorExpression(Expression localFilenameGeneratorExpression)
Specify a SpEL expression for local files renaming after downloading.
|
void |
setLocalFilenameGeneratorExpressionString(String localFilenameGeneratorExpression)
Specify a SpEL expression for local files renaming after downloading.
|
void |
setMputFilter(FileListFilter<File> filter)
A
FileListFilter that runs against the local file system view when
using MPUT command. |
void |
setOption(AbstractRemoteFileOutboundGateway.Option... options)
Specify the array of options for various gateway commands.
|
void |
setOptions(String options)
Specify the options for various gateway commands as a space-delimited string.
|
void |
setRemoteDirectoryExpression(Expression remoteDirectoryExpression)
Set the remote directory expression used to determine the remote directory to which
files will be sent.
|
void |
setRemoteFileSeparator(String remoteFileSeparator)
Set the file separator when dealing with remote files; default '/'.
|
void |
setRenameExpression(Expression renameExpression)
Specify a SpEL expression for files renaming during transfer.
|
void |
setRenameExpressionString(String renameExpression)
Specify a SpEL expression for files renaming during transfer.
|
void |
setTemporaryFileSuffix(String temporaryFileSuffix)
Set the temporary suffix to use when transferring files to the remote system.
|
void |
setTemporaryRemoteDirectoryExpression(Expression temporaryRemoteDirectoryExpression)
Set a temporary remote directory expression; used when transferring files to the remote
system.
|
void |
setUseTemporaryFileName(boolean useTemporaryFileName)
Set whether a temporary file name is used when sending files to the remote system.
|
doInvokeAdvisedRequestHandler, getBeanClassLoader, getIntegrationPatternType, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReply
addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeaders
handleMessage, onComplete, onError, onNext, onSubscribe
buildSendTimer, destroy, getComponentType, getManagedName, getManagedType, getMetricsCaptor, getOrder, getOverrides, isLoggingEnabled, registerMetricsCaptor, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrack
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getThisAs
getBeanName, getComponentName
public AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory, MessageSessionCallback<F,?> messageSessionCallback)
sessionFactory
- the session factory.messageSessionCallback
- the callback.public AbstractRemoteFileOutboundGateway(RemoteFileTemplate<F> remoteFileTemplate, MessageSessionCallback<F,?> messageSessionCallback)
remoteFileTemplate
- the remote file template.messageSessionCallback
- the callback.public AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory, String command, @Nullable String expression)
sessionFactory
- the session factory.command
- the command.expression
- the filename expression.public AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory, AbstractRemoteFileOutboundGateway.Command command, @Nullable String expression)
sessionFactory
- the session factory.command
- the command.expression
- the filename expression.public AbstractRemoteFileOutboundGateway(RemoteFileTemplate<F> remoteFileTemplate, String command, @Nullable String expression)
remoteFileTemplate
- the remote file template.command
- the command.expression
- the filename expression.public AbstractRemoteFileOutboundGateway(RemoteFileTemplate<F> remoteFileTemplate, AbstractRemoteFileOutboundGateway.Command command, @Nullable String expressionArg)
remoteFileTemplate
- the remote file template.command
- the command.expressionArg
- the filename expression.protected final void remoteFileTemplateExplicitlySet(boolean remoteFileTemplateExplicitlySet)
protected void assertRemoteFileTemplateMutability(String propertyName)
public void setOptions(String options)
options
- the options to setAbstractRemoteFileOutboundGateway.Option
public void setOption(AbstractRemoteFileOutboundGateway.Option... options)
options
- the AbstractRemoteFileOutboundGateway.Option
array to use.AbstractRemoteFileOutboundGateway.Option
public void setRemoteFileSeparator(String remoteFileSeparator)
remoteFileSeparator
- the separator.RemoteFileTemplate.setRemoteFileSeparator(String)
public void setLocalDirectory(File localDirectory)
localDirectory
- the localDirectory to setpublic void setLocalDirectoryExpression(Expression localDirectoryExpression)
localDirectoryExpression
- the SpEL to determine the local directory.public void setLocalDirectoryExpressionString(String localDirectoryExpression)
localDirectoryExpression
- the SpEL to determine the local directory.public void setAutoCreateLocalDirectory(boolean autoCreateLocalDirectory)
boolean
flag to identify if local directory should be created automatically.
Defaults to true
.autoCreateLocalDirectory
- the autoCreateLocalDirectory to setpublic void setTemporaryFileSuffix(String temporaryFileSuffix)
.writing
.temporaryFileSuffix
- the temporaryFileSuffix to setRemoteFileTemplate.setTemporaryFileSuffix(String)
public void setAutoCreateDirectory(boolean autoCreateDirectory)
autoCreateDirectory
- true to create the directory.RemoteFileTemplate.setAutoCreateDirectory(boolean)
public void setRemoteDirectoryExpression(Expression remoteDirectoryExpression)
remoteDirectoryExpression
- the remote directory expression.RemoteFileTemplate.setRemoteDirectoryExpression(org.springframework.expression.Expression)
public void setTemporaryRemoteDirectoryExpression(Expression temporaryRemoteDirectoryExpression)
remoteDirectoryExpression
.temporaryRemoteDirectoryExpression
- the temporary remote directory expression.RemoteFileTemplate.setTemporaryRemoteDirectoryExpression(org.springframework.expression.Expression)
public void setFileNameExpression(Expression fileNameExpression)
fileNameExpression
- the file name expression.RemoteFileTemplate.setFileNameExpression(org.springframework.expression.Expression)
public void setUseTemporaryFileName(boolean useTemporaryFileName)
useTemporaryFileName
- true to use a temporary file name.RemoteFileTemplate.setUseTemporaryFileName(boolean)
public void setFileNameGenerator(FileNameGenerator fileNameGenerator)
fileNameGenerator
- the file name generator.RemoteFileTemplate.setFileNameGenerator(org.springframework.integration.file.FileNameGenerator)
public void setCharset(String charset)
UTF-8
.charset
- the charset.RemoteFileTemplate.setCharset(java.lang.String)
public void setFilter(FileListFilter<F> filter)
FileListFilter
to filter remote files.filter
- the filter to setpublic void setMputFilter(FileListFilter<File> filter)
FileListFilter
that runs against the local file system view when
using MPUT
command.filter
- the filter to setpublic void setRenameExpression(Expression renameExpression)
renameExpression
- the expression to use.public void setRenameExpressionString(String renameExpression)
renameExpression
- the String in SpEL syntax.public void setLocalFilenameGeneratorExpression(Expression localFilenameGeneratorExpression)
localFilenameGeneratorExpression
- the expression to use.public void setLocalFilenameGeneratorExpressionString(String localFilenameGeneratorExpression)
localFilenameGeneratorExpression
- the String in SpEL syntax.public void setFileExistsMode(FileExistsMode fileExistsMode)
fileExistsMode
- the fileExistsMode to set.public void setChmodOctal(String chmod)
chmod
- permissions as an octal string e.g "600";setChmod(int)
public void setChmod(int chmod)
chmod
- the permissions.public boolean isChmodCapable()
protected final RemoteFileTemplate<F> getRemoteFileTemplate()
protected void doInit()
doInit
in class AbstractReplyProducingMessageHandler
protected Object handleRequestMessage(Message<?> requestMessage)
AbstractReplyProducingMessageHandler
handleRequestMessage
in class AbstractReplyProducingMessageHandler
requestMessage
- The request message.null
.protected List<String> nlst(Message<?> message, Session<F> session, String dir) throws IOException
message
- the message related to the current requestsession
- the session to perform list file names commanddir
- the remote directory to list file namesIOException
- the IO exception during performing remote commandprotected boolean rm(Message<?> message, Session<F> session, String remoteFilePath) throws IOException
message
- the request message related to the path to removesession
- the remote protocol session to perform remove commandremoteFilePath
- the remote path to removeIOException
- the IO exception during performing remote commandprotected boolean mv(Message<?> message, Session<F> session, String remoteFilePath, String remoteFileNewPath) throws IOException
message
- the request message related to this move commandsession
- the remote protocol session to perform move commandremoteFilePath
- the source remote pathremoteFileNewPath
- the target remote pathIOException
- the IO exception during performing remote commandprotected String put(Message<?> message, Session<F> session, String subDirectory)
message
- the request message related to this put commandsession
- the remote protocol session related to this invocation contextsubDirectory
- the target sub directory to putprotected void doChmod(RemoteFileOperations<F> remoteFileOperations, String path, int chmodToSet)
remoteFileOperations
- the remote file template.path
- the path.chmodToSet
- the chmod to set.protected List<String> mPut(Message<?> message, Session<F> session, File localDir)
message
- the request message related to this mPut commandsession
- the remote protocol session for this invocation contextlocalDir
- the local directory to mput to the serverprotected List<?> ls(Message<?> message, Session<F> session, String dir) throws IOException
message
- the message related to the list requestsession
- the session to perform list commanddir
- the remote directory to list contentIOException
- the IO exception during performing remote commandprotected File get(Message<?> message, Session<F> session, String remoteDir, String remoteFilePath, String remoteFilename, F fileInfoParam) throws IOException
message
- the message.session
- the session.remoteDir
- the remote directory.remoteFilePath
- the remote file path.remoteFilename
- the remote file name.fileInfoParam
- the remote file info; if null we will execute an 'ls' command
first.IOException
- Any IOException.protected List<File> mGet(Message<?> message, Session<F> session, String remoteDirectory, String remoteFilename) throws IOException
IOException
protected String getRemoteFilename(String remoteFilePath)
remoteFilePath
- The remote file path.protected abstract boolean isDirectory(F file)
protected abstract boolean isLink(F file)
protected abstract String getFilename(AbstractFileInfo<F> file)
protected abstract long getModified(F file)
protected abstract List<AbstractFileInfo<F>> asFileInfoList(Collection<F> files)