From f448ec93b2709fac5710952902507d10aae71c9b Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Sun, 21 Nov 2010 18:05:18 -0500 Subject: [PATCH] INT-1614 'auto-delete-remote-files-on-sync' is now 'delete-remote-files' --- .../AbstractInboundFileSynchronizer.java | 12 ++++++------ .../ftp/config/FtpInboundChannelAdapterParser.java | 2 +- .../ftp/config/spring-integration-ftp-2.0.xsd | 11 +++++++++-- .../ftp/FtpParserInboundTests-context.xml | 4 ++-- .../ftp/FtpParserInboundTests-fail-context.xml | 2 +- .../FtpInboundChannelAdapterParserTests-context.xml | 4 ++-- .../FtpsInboundChannelAdapterParserTests-context.xml | 4 ++-- .../integration/ftp/ftp-message-history-context.xml | 2 +- .../FtpInboundRemoteFileSystemSynchronizerTest.java | 2 +- .../sftp/config/SftpInboundChannelAdapterParser.java | 2 +- ...SftpInboundRemoteFileSystemSynchronizerTests.java | 2 +- 11 files changed, 27 insertions(+), 20 deletions(-) diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizer.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizer.java index 1229f9c096..4fdfedda32 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizer.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizer.java @@ -68,10 +68,10 @@ public abstract class AbstractInboundFileSynchronizer implements InboundFileS private volatile FileListFilter filter; /** - * Should we delete the source file? For an FTP - * server, for example, this would delete the original FTPFile instance. + * Should we delete the remote source files + * after copying to the local directory? By default this is false. */ - protected boolean shouldDeleteSourceFile; + private boolean deleteRemoteFiles; /** @@ -94,8 +94,8 @@ public abstract class AbstractInboundFileSynchronizer implements InboundFileS this.filter = filter; } - public void setShouldDeleteSourceFile(boolean shouldDeleteSourceFile) { - this.shouldDeleteSourceFile = shouldDeleteSourceFile; + public void setDeleteRemoteFiles(boolean deleteRemoteFiles) { + this.deleteRemoteFiles = deleteRemoteFiles; } public final void afterPropertiesSet() { @@ -182,7 +182,7 @@ public abstract class AbstractInboundFileSynchronizer implements InboundFileS } } if (tempFile.renameTo(localFile)) { - if (this.shouldDeleteSourceFile) { + if (this.deleteRemoteFiles) { session.rm(remoteFilePath); if (logger.isDebugEnabled()) { logger.debug("deleted " + remoteFilePath); diff --git a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpInboundChannelAdapterParser.java b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpInboundChannelAdapterParser.java index 4e4a7a395d..d587beac57 100644 --- a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpInboundChannelAdapterParser.java +++ b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpInboundChannelAdapterParser.java @@ -47,7 +47,7 @@ public class FtpInboundChannelAdapterParser extends AbstractPollingInboundChanne "org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer"); synchronizerBuilder.addConstructorArgValue(sessionFactoryBuilder.getBeanDefinition()); IntegrationNamespaceUtils.setValueIfAttributeDefined(synchronizerBuilder, element, "remote-directory"); -// IntegrationNamespaceUtils.setValueIfAttributeDefined(synchronizerBuilder, element, "auto-delete-remote-files-on-sync", "shouldDeleteSourceFile"); + IntegrationNamespaceUtils.setValueIfAttributeDefined(synchronizerBuilder, element, "delete-remote-files"); String fileNamePattern = element.getAttribute("filename-pattern"); String filter = element.getAttribute("filter"); boolean hasFileNamePattern = StringUtils.hasText(fileNamePattern); diff --git a/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-2.0.xsd b/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-2.0.xsd index 0ddf4c3e05..4265fcc3f8 100644 --- a/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-2.0.xsd +++ b/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-2.0.xsd @@ -55,7 +55,14 @@ - + + + + Specify whether to delete the remote source file after copying. + By default, the remote files will NOT be deleted. + + + @@ -79,7 +86,7 @@ - + diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/FtpParserInboundTests-context.xml b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/FtpParserInboundTests-context.xml index 40a7d4da72..70200a541c 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/FtpParserInboundTests-context.xml +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/FtpParserInboundTests-context.xml @@ -27,7 +27,7 @@ local-directory="target/foo" remote-directory="foo/bar" auto-create-directories="true" - auto-delete-remote-files-on-sync="false"> + delete-remote-files="false"> @@ -39,7 +39,7 @@ local-directory="target" remote-directory="foo/bar" auto-create-directories="true" - auto-delete-remote-files-on-sync="false"> + delete-remote-files="false"> diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/FtpParserInboundTests-fail-context.xml b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/FtpParserInboundTests-fail-context.xml index 2eccf87d90..ea1a7be484 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/FtpParserInboundTests-fail-context.xml +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/FtpParserInboundTests-fail-context.xml @@ -27,7 +27,7 @@ local-directory="file:target/bar" remote-directory="foo/bar" auto-create-directories="false" - auto-delete-remote-files-on-sync="false"> + delete-remote-files="false"> diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpInboundChannelAdapterParserTests-context.xml b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpInboundChannelAdapterParserTests-context.xml index e85e501b01..60e79b0f3e 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpInboundChannelAdapterParserTests-context.xml +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpInboundChannelAdapterParserTests-context.xml @@ -15,7 +15,7 @@ session-factory="ftpSessionFactory" charset="UTF-8" auto-create-directories="true" - auto-delete-remote-files-on-sync="true" + delete-remote-files="true" filename-pattern=".?txt" local-directory="." remote-directory="foo/bar"> @@ -27,7 +27,7 @@ session-factory="ftpSessionFactory" charset="UTF-8" auto-create-directories="true" - auto-delete-remote-files-on-sync="true" + delete-remote-files="true" filter="entryListFilter" local-directory="." remote-directory="foo/bar"> diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpsInboundChannelAdapterParserTests-context.xml b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpsInboundChannelAdapterParserTests-context.xml index 8f4dc3e045..1749bc1b14 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpsInboundChannelAdapterParserTests-context.xml +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpsInboundChannelAdapterParserTests-context.xml @@ -22,7 +22,7 @@ session-factory="ftpSessionFactory" charset="UTF-8" auto-create-directories="true" - auto-delete-remote-files-on-sync="true" + delete-remote-files="true" local-directory="." remote-directory="foo/bar" filter="entryListFilter"> @@ -34,7 +34,7 @@ session-factory="ftpSessionFactory" charset="UTF-8" auto-create-directories="true" - auto-delete-remote-files-on-sync="true" + delete-remote-files="true" filename-pattern=".?txt" local-directory="." remote-directory="foo/bar"> diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/ftp-message-history-context.xml b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/ftp-message-history-context.xml index 90a1324f7f..3fde3fcc77 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/ftp-message-history-context.xml +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/ftp-message-history-context.xml @@ -27,7 +27,7 @@ auto-create-directories="true" local-directory="file:target/foo" remote-directory="foo/bar" - auto-delete-remote-files-on-sync="false"> + delete-remote-files="false"> diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/FtpInboundRemoteFileSystemSynchronizerTest.java b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/FtpInboundRemoteFileSystemSynchronizerTest.java index 314a4036e8..3634856a40 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/FtpInboundRemoteFileSystemSynchronizerTest.java +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/FtpInboundRemoteFileSystemSynchronizerTest.java @@ -77,7 +77,7 @@ public class FtpInboundRemoteFileSystemSynchronizerTest { new FtpInboundFileSynchronizingMessageSource(); FtpInboundFileSynchronizer synchronizer = spy(new FtpInboundFileSynchronizer(ftpSessionFactory)); - synchronizer.setShouldDeleteSourceFile(true); + synchronizer.setDeleteRemoteFiles(true); synchronizer.setRemoteDirectory("remote-test-dir"); synchronizer.setFilter(new FtpPatternMatchingFileListFilter(".*\\.test$")); diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/config/SftpInboundChannelAdapterParser.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/config/SftpInboundChannelAdapterParser.java index 5ce8162225..0847a9b047 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/config/SftpInboundChannelAdapterParser.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/config/SftpInboundChannelAdapterParser.java @@ -57,7 +57,7 @@ public class SftpInboundChannelAdapterParser extends AbstractPollingInboundChann "org.springframework.integration.sftp.inbound.SftpInboundFileSynchronizer"); synchronizerBuilder.addConstructorArgReference(sessionPollName); IntegrationNamespaceUtils.setValueIfAttributeDefined(synchronizerBuilder, element, "remote-directory"); - IntegrationNamespaceUtils.setValueIfAttributeDefined(synchronizerBuilder, element, "auto-delete-remote-files-on-sync", "shouldDeleteSourceFile"); + IntegrationNamespaceUtils.setValueIfAttributeDefined(synchronizerBuilder, element, "delete-remote-files"); IntegrationNamespaceUtils.setReferenceIfAttributeDefined(synchronizerBuilder, element, "filter"); BeanDefinitionBuilder messageSourceBuilder = BeanDefinitionBuilder.rootBeanDefinition( "org.springframework.integration.sftp.inbound.SftpInboundFileSynchronizingMessageSource"); diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizerTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizerTests.java index 820da7df10..6b63e4ab03 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizerTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizerTests.java @@ -88,7 +88,7 @@ public class SftpInboundRemoteFileSystemSynchronizerTests { } }); - syncronizer.setShouldDeleteSourceFile(true); + syncronizer.setDeleteRemoteFiles(true); syncronizer.afterPropertiesSet(); File localDirectory = new File(System.getProperty("java.io.tmpdir"));