INT-1614 changed 'remotePath' property to 'remoteDirectory' - now matches the 'remote-directory' attribute within the schema
This commit is contained in:
@@ -50,9 +50,9 @@ public abstract class AbstractInboundFileSynchronizer<F> 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<F> 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<F> filter) {
|
||||
@@ -93,7 +96,7 @@ public abstract class AbstractInboundFileSynchronizer<F> 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<F> filterFiles(F[] files) {
|
||||
@@ -105,7 +108,15 @@ public abstract class AbstractInboundFileSynchronizer<F> 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<F> 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<F> implements InboundFileS
|
||||
}
|
||||
}
|
||||
|
||||
private void synchronizeToLocalDirectory(String remoteDirectoryPath, File localDirectory, Session session) throws IOException {
|
||||
F[] files = session.ls(remoteDirectoryPath);
|
||||
if (!ObjectUtils.isEmpty(files)) {
|
||||
Collection<F> 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;
|
||||
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user