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
Modifier and Type | Field and Description |
---|---|
protected AbstractRemoteFileOutboundGateway.Command |
command |
protected java.util.Set<AbstractRemoteFileOutboundGateway.Option> |
options |
protected RemoteFileTemplate<F> |
remoteFileTemplate |
messagingTemplate
EXPRESSION_PARSER, logger
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Constructor and Description |
---|
AbstractRemoteFileOutboundGateway(RemoteFileTemplate<F> remoteFileTemplate,
AbstractRemoteFileOutboundGateway.Command command,
java.lang.String expression)
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,
java.lang.String command,
java.lang.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,
java.lang.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,
java.lang.String command,
java.lang.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 java.util.List<AbstractFileInfo<F>> |
asFileInfoList(java.util.Collection<F> files) |
protected void |
doChmod(RemoteFileOperations<F> remoteFileOperations,
java.lang.String path,
int chmod)
Set the mode on the remote file after transfer; the default implementation does
nothing.
|
protected void |
doInit() |
protected abstract F |
enhanceNameWithSubDirectory(F file,
java.lang.String directory) |
protected java.util.List<F> |
filterFiles(F[] files) |
protected java.util.List<java.io.File> |
filterMputFiles(java.io.File[] files) |
protected java.io.File |
get(org.springframework.messaging.Message<?> message,
Session<F> session,
java.lang.String remoteDir,
java.lang.String remoteFilePath,
java.lang.String remoteFilename,
F fileInfoParam)
Copy a remote file to the configured local directory.
|
protected abstract java.lang.String |
getFilename(AbstractFileInfo<F> file) |
protected abstract java.lang.String |
getFilename(F file) |
protected abstract long |
getModified(F file) |
protected java.lang.String |
getRemoteFilename(java.lang.String remoteFilePath) |
protected java.lang.Object |
handleRequestMessage(org.springframework.messaging.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 java.util.List<?> |
ls(org.springframework.messaging.Message<?> message,
Session<F> session,
java.lang.String dir)
List remote files to local representation.
|
protected java.util.List<java.io.File> |
mGet(org.springframework.messaging.Message<?> message,
Session<F> session,
java.lang.String remoteDirectory,
java.lang.String remoteFilename) |
protected java.util.List<java.lang.String> |
mPut(org.springframework.messaging.Message<?> message,
Session<F> session,
java.io.File localDir)
Put files from the provided directory to the remote server recursively.
|
protected boolean |
mv(org.springframework.messaging.Message<?> message,
Session<F> session,
java.lang.String remoteFilePath,
java.lang.String remoteFileNewPath)
Move one remote path to another.
|
protected java.util.List<java.lang.String> |
nlst(org.springframework.messaging.Message<?> message,
Session<F> session,
java.lang.String dir)
List remote files names for the provided directory.
|
protected void |
purgeDots(java.util.List<F> lsFiles) |
protected void |
purgeLinks(java.util.List<F> lsFiles) |
protected java.lang.String |
put(org.springframework.messaging.Message<?> message,
Session<F> session,
java.lang.String subDirectory)
Put the file based on the message to the remote server.
|
protected boolean |
rm(org.springframework.messaging.Message<?> message,
Session<F> session,
java.lang.String remoteFilePath)
Perform remote delete for the provided path.
|
void |
setAutoCreateLocalDirectory(boolean autoCreateLocalDirectory)
A
boolean flag to identify if local directory should be created automatically. |
void |
setChmod(int chmod)
Set the file permissions after uploading, e.g.
|
void |
setChmodOctal(java.lang.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 |
setFilter(FileListFilter<F> filter)
Set a
FileListFilter to filter remote files. |
void |
setLocalDirectory(java.io.File localDirectory)
Specify a directory path where remote files will be transferred to.
|
void |
setLocalDirectoryExpression(org.springframework.expression.Expression localDirectoryExpression)
Specify a SpEL expression to evaluate the directory path to which remote files will
be transferred.
|
void |
setLocalDirectoryExpressionString(java.lang.String localDirectoryExpression)
Specify a SpEL expression to evaluate the directory path to which remote files will
be transferred.
|
void |
setLocalFilenameGeneratorExpression(org.springframework.expression.Expression localFilenameGeneratorExpression)
Specify a SpEL expression for local files renaming after downloading.
|
void |
setLocalFilenameGeneratorExpressionString(java.lang.String localFilenameGeneratorExpression)
Specify a SpEL expression for local files renaming after downloading.
|
void |
setMputFilter(FileListFilter<java.io.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(java.lang.String options)
Specify the options for various gateway commands as a space-delimited string.
|
void |
setRemoteFileSeparator(java.lang.String remoteFileSeparator)
Set the file separator when dealing with remote files; default '/'.
|
void |
setRenameExpression(org.springframework.expression.Expression renameExpression)
Specify a SpEL expression for files renaming during transfer.
|
void |
setRenameExpressionString(java.lang.String renameExpression)
Specify a SpEL expression for files renaming during transfer.
|
void |
setTemporaryFileSuffix(java.lang.String temporaryFileSuffix)
Set the temporary suffix to use when transferring files to the remote system.
|
doInvokeAdvisedRequestHandler, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReply
addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeaders
configureMetrics, getActiveCount, getActiveCountLong, getComponentType, getDuration, getErrorCount, getErrorCountLong, getHandleCount, getHandleCountLong, getManagedName, getManagedType, getMaxDuration, getMeanDuration, getMinDuration, getOrder, getOverrides, getStandardDeviationDuration, handleMessage, isCountsEnabled, isLoggingEnabled, isStatsEnabled, onComplete, onError, onNext, onSubscribe, registerMetricsCaptor, reset, setCountsEnabled, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, setStatsEnabled
afterPropertiesSet, extractTypeIfPossible, getApplicationContext, getApplicationContextId, getBeanFactory, 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
getComponentName
protected final RemoteFileTemplate<F> remoteFileTemplate
protected final AbstractRemoteFileOutboundGateway.Command command
protected final java.util.Set<AbstractRemoteFileOutboundGateway.Option> options
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, java.lang.String command, java.lang.String expression)
sessionFactory
- the session factory.command
- the command.expression
- the filename expression.public AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory, AbstractRemoteFileOutboundGateway.Command command, java.lang.String expression)
sessionFactory
- the session factory.command
- the command.expression
- the filename expression.public AbstractRemoteFileOutboundGateway(RemoteFileTemplate<F> remoteFileTemplate, java.lang.String command, java.lang.String expression)
remoteFileTemplate
- the remote file template.command
- the command.expression
- the filename expression.public AbstractRemoteFileOutboundGateway(RemoteFileTemplate<F> remoteFileTemplate, AbstractRemoteFileOutboundGateway.Command command, java.lang.String expression)
remoteFileTemplate
- the remote file template.command
- the command.expression
- the filename expression.public void setOptions(java.lang.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(java.lang.String remoteFileSeparator)
remoteFileSeparator
- the separator.RemoteFileTemplate.setRemoteFileSeparator(String)
public void setLocalDirectory(java.io.File localDirectory)
localDirectory
- the localDirectory to setpublic void setLocalDirectoryExpression(org.springframework.expression.Expression localDirectoryExpression)
localDirectoryExpression
- the SpEL to determine the local directory.public void setLocalDirectoryExpressionString(java.lang.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(java.lang.String temporaryFileSuffix)
.writing
.temporaryFileSuffix
- the temporaryFileSuffix to setRemoteFileTemplate.setTemporaryFileSuffix(String)
public void setFilter(FileListFilter<F> filter)
FileListFilter
to filter remote files.filter
- the filter to setpublic void setMputFilter(FileListFilter<java.io.File> filter)
FileListFilter
that runs against the local file system view when
using MPUT
command.filter
- the filter to setpublic void setRenameExpression(org.springframework.expression.Expression renameExpression)
renameExpression
- the expression to use.public void setRenameExpressionString(java.lang.String renameExpression)
renameExpression
- the String in SpEL syntax.public void setLocalFilenameGeneratorExpression(org.springframework.expression.Expression localFilenameGeneratorExpression)
localFilenameGeneratorExpression
- the expression to use.public void setLocalFilenameGeneratorExpressionString(java.lang.String localFilenameGeneratorExpression)
localFilenameGeneratorExpression
- the String in SpEL syntax.public void setFileExistsMode(FileExistsMode fileExistsMode)
fileExistsMode
- the fileExistsMode to set.public void setChmodOctal(java.lang.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 void doInit()
doInit
in class AbstractReplyProducingMessageHandler
protected java.lang.Object handleRequestMessage(org.springframework.messaging.Message<?> requestMessage)
AbstractReplyProducingMessageHandler
handleRequestMessage
in class AbstractReplyProducingMessageHandler
requestMessage
- The request message.null
.protected java.util.List<java.lang.String> nlst(org.springframework.messaging.Message<?> message, Session<F> session, java.lang.String dir) throws java.io.IOException
message
- the message related to the current requestsession
- the session to perform list file names commanddir
- the remote directory to list file namesjava.io.IOException
- the IO exception during performing remote commandprotected boolean rm(org.springframework.messaging.Message<?> message, Session<F> session, java.lang.String remoteFilePath) throws java.io.IOException
message
- the request message related to the path to removesession
- the remote protocol session to perform remove commandremoteFilePath
- the remote path to removejava.io.IOException
- the IO exception during performing remote commandprotected boolean mv(org.springframework.messaging.Message<?> message, Session<F> session, java.lang.String remoteFilePath, java.lang.String remoteFileNewPath) throws java.io.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 pathjava.io.IOException
- the IO exception during performing remote commandprotected java.lang.String put(org.springframework.messaging.Message<?> message, Session<F> session, java.lang.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, java.lang.String path, int chmod)
remoteFileOperations
- the remote file template.path
- the path.chmod
- the chmod to set.protected java.util.List<java.lang.String> mPut(org.springframework.messaging.Message<?> message, Session<F> session, java.io.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 java.util.List<?> ls(org.springframework.messaging.Message<?> message, Session<F> session, java.lang.String dir) throws java.io.IOException
message
- the message related to the list requestsession
- the session to perform list commanddir
- the remote directory to list contentjava.io.IOException
- the IO exception during performing remote commandprotected final java.util.List<java.io.File> filterMputFiles(java.io.File[] files)
protected void purgeLinks(java.util.List<F> lsFiles)
protected void purgeDots(java.util.List<F> lsFiles)
protected java.io.File get(org.springframework.messaging.Message<?> message, Session<F> session, java.lang.String remoteDir, java.lang.String remoteFilePath, java.lang.String remoteFilename, F fileInfoParam) throws java.io.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.java.io.IOException
- Any IOException.protected java.util.List<java.io.File> mGet(org.springframework.messaging.Message<?> message, Session<F> session, java.lang.String remoteDirectory, java.lang.String remoteFilename) throws java.io.IOException
java.io.IOException
protected java.lang.String getRemoteFilename(java.lang.String remoteFilePath)
remoteFilePath
- The remote file path.protected abstract boolean isDirectory(F file)
protected abstract boolean isLink(F file)
protected abstract java.lang.String getFilename(F file)
protected abstract java.lang.String getFilename(AbstractFileInfo<F> file)
protected abstract long getModified(F file)
protected abstract java.util.List<AbstractFileInfo<F>> asFileInfoList(java.util.Collection<F> files)