INT-4302: Add fileExistsMode() to Java DSL
JIRA: https://jira.spring.io/browse/INT-4302 Add `RemoteFileOutboundGatewaySpec#fileExistsMode()`
This commit is contained in:
committed by
Gary Russell
parent
171d169748
commit
4679c9bdbe
@@ -32,6 +32,7 @@ import org.springframework.integration.file.filters.FileListFilter;
|
||||
import org.springframework.integration.file.filters.RegexPatternFileListFilter;
|
||||
import org.springframework.integration.file.filters.SimplePatternFileListFilter;
|
||||
import org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway;
|
||||
import org.springframework.integration.file.support.FileExistsMode;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
@@ -338,6 +339,19 @@ public abstract class RemoteFileOutboundGatewaySpec<F, S extends RemoteFileOutbo
|
||||
return _this();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param fileExistsMode the fileExistsMode to set.
|
||||
* @return the current Spec
|
||||
*/
|
||||
public S fileExistsMode(FileExistsMode fileExistsMode) {
|
||||
this.target.setFileExistsMode(fileExistsMode);
|
||||
return _this();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<Object, String> getComponentsToRegister() {
|
||||
Map<Object, String> componentsToRegister = new LinkedHashMap<>();
|
||||
@@ -351,7 +365,6 @@ public abstract class RemoteFileOutboundGatewaySpec<F, S extends RemoteFileOutbo
|
||||
return componentsToRegister;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specify a simple pattern to match remote files (e.g. '*.txt').
|
||||
* @param pattern the pattern.
|
||||
|
||||
@@ -62,6 +62,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@@ -170,6 +171,7 @@ public class FtpTests extends FtpTestSupport {
|
||||
.handle(Ftp.outboundGateway(sessionFactory(),
|
||||
AbstractRemoteFileOutboundGateway.Command.MGET, "payload")
|
||||
.options(AbstractRemoteFileOutboundGateway.Option.RECURSIVE)
|
||||
.fileExistsMode(FileExistsMode.IGNORE)
|
||||
.filterExpression("name matches 'subFtpSource|.*1.txt'")
|
||||
.localDirectoryExpression("'" + getTargetLocalDirectoryName() + "' + #remoteDirectory")
|
||||
.localFilenameExpression("#remoteFileName.replaceFirst('ftpSource', 'localTarget')"))
|
||||
|
||||
Reference in New Issue
Block a user