From 4e3191877126ce5d9acc415a92b34c787e2fefb1 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Sun, 21 Nov 2010 15:56:20 -0500 Subject: [PATCH] INT-1614 changed 'remotePath' property to 'remoteDirectory' - now matches the 'remote-directory' attribute within the schema --- .../AbstractInboundFileSynchronizer.java | 35 +++++++++---------- .../FtpInboundChannelAdapterParser.java | 2 +- ...boundRemoteFileSystemSynchronizerTest.java | 2 +- .../SftpInboundChannelAdapterParser.java | 2 +- ...oundRemoteFileSystemSynchronizerTests.java | 2 +- 5 files changed, 21 insertions(+), 22 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 be3e55af01..ea47957aa6 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 @@ -50,9 +50,9 @@ public abstract class AbstractInboundFileSynchronizer implements InboundFileS protected final Log logger = LogFactory.getLog(this.getClass()); /** - * the path on the remote mount + * the path on the remote mount as a String. */ - private volatile String remotePath; + private volatile String remoteDirectory; /** * the {@link SessionFactory} for acquiring remote file Sessions. @@ -80,8 +80,11 @@ public abstract class AbstractInboundFileSynchronizer implements InboundFileS } - public void setRemotePath(String remotePath) { - this.remotePath = remotePath; + /** + * Specify the full path to the remote directory. + */ + public void setRemoteDirectory(String remoteDirectory) { + this.remoteDirectory = remoteDirectory; } public void setFilter(FileListFilter filter) { @@ -93,7 +96,7 @@ public abstract class AbstractInboundFileSynchronizer implements InboundFileS } public final void afterPropertiesSet() { - Assert.notNull(this.remotePath, "remotePath must not be null"); + Assert.notNull(this.remoteDirectory, "remoteDirectory must not be null"); } protected final List filterFiles(F[] files) { @@ -105,7 +108,15 @@ public abstract class AbstractInboundFileSynchronizer implements InboundFileS try { session = this.sessionFactory.getSession(); Assert.state(session != null, "failed to acquire a Session"); - this.synchronizeToLocalDirectory(this.remotePath, localDirectory, session); + F[] files = session.ls(this.remoteDirectory); + if (!ObjectUtils.isEmpty(files)) { + Collection filteredFiles = this.filterFiles(files); + for (F file : filteredFiles) { + if (file != null) { + this.copyFileToLocalDirectory(this.remoteDirectory, file, localDirectory, session); + } + } + } } catch (IOException e) { throw new MessagingException("Problem occurred while synchronizing remote to local directory", e); @@ -124,18 +135,6 @@ public abstract class AbstractInboundFileSynchronizer implements InboundFileS } } - private void synchronizeToLocalDirectory(String remoteDirectoryPath, File localDirectory, Session session) throws IOException { - F[] files = session.ls(remoteDirectoryPath); - if (!ObjectUtils.isEmpty(files)) { - Collection filteredFiles = this.filterFiles(files); - for (F file : filteredFiles) { - if (file != null) { - this.copyFileToLocalDirectory(remoteDirectoryPath, file, localDirectory, session); - } - } - } - } - protected abstract boolean copyFileToLocalDirectory(String remoteDirectoryPath, F file, File localDirectory, Session session) throws IOException; } 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 70aeda8481..ee97a64c9f 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 @@ -46,7 +46,7 @@ public class FtpInboundChannelAdapterParser extends AbstractPollingInboundChanne BeanDefinitionBuilder synchronizerBuilder = BeanDefinitionBuilder.genericBeanDefinition( "org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer"); synchronizerBuilder.addConstructorArgValue(sessionFactoryBuilder.getBeanDefinition()); - IntegrationNamespaceUtils.setValueIfAttributeDefined(synchronizerBuilder, element, "remote-directory", "remotePath"); + IntegrationNamespaceUtils.setValueIfAttributeDefined(synchronizerBuilder, element, "remote-directory"); // IntegrationNamespaceUtils.setValueIfAttributeDefined(synchronizerBuilder, element, "auto-delete-remote-files-on-sync", "shouldDeleteSourceFile"); String fileNamePattern = element.getAttribute("filename-pattern"); String filter = element.getAttribute("filter"); 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 ebc3055c06..314a4036e8 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 @@ -78,7 +78,7 @@ public class FtpInboundRemoteFileSystemSynchronizerTest { FtpInboundFileSynchronizer synchronizer = spy(new FtpInboundFileSynchronizer(ftpSessionFactory)); synchronizer.setShouldDeleteSourceFile(true); - synchronizer.setRemotePath("remote-test-dir"); + synchronizer.setRemoteDirectory("remote-test-dir"); synchronizer.setFilter(new FtpPatternMatchingFileListFilter(".*\\.test$")); ms.setSynchronizer(synchronizer); 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 70c8daf657..5ce8162225 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 @@ -56,7 +56,7 @@ public class SftpInboundChannelAdapterParser extends AbstractPollingInboundChann BeanDefinitionBuilder synchronizerBuilder = BeanDefinitionBuilder.genericBeanDefinition( "org.springframework.integration.sftp.inbound.SftpInboundFileSynchronizer"); synchronizerBuilder.addConstructorArgReference(sessionPollName); - IntegrationNamespaceUtils.setValueIfAttributeDefined(synchronizerBuilder, element, "remote-directory", "remotePath"); + IntegrationNamespaceUtils.setValueIfAttributeDefined(synchronizerBuilder, element, "remote-directory"); IntegrationNamespaceUtils.setValueIfAttributeDefined(synchronizerBuilder, element, "auto-delete-remote-files-on-sync", "shouldDeleteSourceFile"); IntegrationNamespaceUtils.setReferenceIfAttributeDefined(synchronizerBuilder, element, "filter"); BeanDefinitionBuilder messageSourceBuilder = BeanDefinitionBuilder.rootBeanDefinition( 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 d0dba0f931..820da7df10 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 @@ -57,7 +57,7 @@ public class SftpInboundRemoteFileSystemSynchronizerTests { } SessionFactory sessionFactory = mock(SessionFactory.class); SftpInboundFileSynchronizer syncronizer = new SftpInboundFileSynchronizer(sessionFactory); - syncronizer.setRemotePath("foo/bar"); + syncronizer.setRemoteDirectory("foo/bar"); FileListFilter filter = mock(FileListFilter.class);