INT-1614 changed the 'auto-create-directories' attribute to 'auto-create-local-directory' since it only affects the local directory

This commit is contained in:
Mark Fisher
2010-11-22 01:00:58 -05:00
parent ad485e9124
commit bcc919fed7
15 changed files with 45 additions and 37 deletions

View File

@@ -74,7 +74,7 @@ public abstract class AbstractRemoteFileInboundChannelAdapterParser extends Abst
BeanDefinitionBuilder messageSourceBuilder = BeanDefinitionBuilder.genericBeanDefinition(this.getMessageSourceClassname());
messageSourceBuilder.addConstructorArgValue(synchronizerBuilder.getBeanDefinition());
IntegrationNamespaceUtils.setValueIfAttributeDefined(messageSourceBuilder, element, "local-directory");
IntegrationNamespaceUtils.setValueIfAttributeDefined(messageSourceBuilder, element, "auto-create-directories");
IntegrationNamespaceUtils.setValueIfAttributeDefined(messageSourceBuilder, element, "auto-create-local-directory");
return messageSourceBuilder.getBeanDefinition();
}

View File

@@ -55,9 +55,9 @@ import org.springframework.util.Assert;
public abstract class AbstractInboundFileSynchronizingMessageSource<F> extends MessageProducerSupport implements MessageSource<File> {
/**
* Should the endpoint attempt to create the local directory?
* Should the endpoint attempt to create the local directory? True by default.
*/
private volatile boolean autoCreateDirectories = true;
private volatile boolean autoCreateLocalDirectory = true;
/**
* An implementation that will handle the chores of actually connecting to and synchronizing
@@ -82,8 +82,8 @@ public abstract class AbstractInboundFileSynchronizingMessageSource<F> extends M
}
public void setAutoCreateDirectories(boolean autoCreateDirectories) {
this.autoCreateDirectories = autoCreateDirectories;
public void setAutoCreateLocalDirectory(boolean autoCreateLocalDirectory) {
this.autoCreateLocalDirectory = autoCreateLocalDirectory;
}
public void setLocalDirectory(File localDirectory) {
@@ -92,9 +92,10 @@ public abstract class AbstractInboundFileSynchronizingMessageSource<F> extends M
@Override
protected void onInit() {
Assert.notNull(this.localDirectory, "localDirectory must not be null");
try {
if (this.localDirectory != null && !this.localDirectory.exists()) {
if (this.autoCreateDirectories) {
if (!this.localDirectory.exists()) {
if (this.autoCreateLocalDirectory) {
if (logger.isDebugEnabled()) {
logger.debug("The '" + this.localDirectory + "' directory doesn't exist; Will create.");
}

View File

@@ -54,15 +54,6 @@
<xsd:sequence>
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="auto-create-directories" type="xsd:boolean"/>
<xsd:attribute name="delete-remote-files" type="xsd:boolean">
<xsd:annotation>
<xsd:documentation>
Specify whether to delete the remote source file after copying.
By default, the remote files will NOT be deleted.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="filename-pattern" type="xsd:string"/>
<xsd:attribute name="filter" type="xsd:string">
<xsd:annotation>
@@ -75,6 +66,15 @@
</xsd:attribute>
<xsd:attribute name="remote-directory" type="xsd:string" use="required"/>
<xsd:attribute name="local-directory" type="xsd:string" use="required"/>
<xsd:attribute name="auto-create-local-directory" type="xsd:boolean"/>
<xsd:attribute name="delete-remote-files" type="xsd:boolean">
<xsd:annotation>
<xsd:documentation>
Specify whether to delete the remote source file after copying.
By default, the remote files will NOT be deleted.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

View File

@@ -26,7 +26,7 @@
filename-pattern="foo"
local-directory="target/foo"
remote-directory="foo/bar"
auto-create-directories="true"
auto-create-local-directory="true"
delete-remote-files="false">
<int:poller fixed-rate="1000"/>
</ftp:inbound-channel-adapter>
@@ -38,7 +38,7 @@
filter="filter"
local-directory="target"
remote-directory="foo/bar"
auto-create-directories="true"
auto-create-local-directory="true"
delete-remote-files="false">
<int:poller fixed-rate="1000"/>
</ftp:inbound-channel-adapter>

View File

@@ -26,7 +26,7 @@
filter="filter"
local-directory="file:target/bar"
remote-directory="foo/bar"
auto-create-directories="false"
auto-create-local-directory="false"
delete-remote-files="false">
<int:poller fixed-rate="1000"/>
</ftp:inbound-channel-adapter>

View File

@@ -14,7 +14,7 @@
channel="ftpChannel"
session-factory="ftpSessionFactory"
charset="UTF-8"
auto-create-directories="true"
auto-create-local-directory="true"
delete-remote-files="true"
filename-pattern=".?txt"
local-directory="."
@@ -26,7 +26,7 @@
channel="ftpChannel"
session-factory="ftpSessionFactory"
charset="UTF-8"
auto-create-directories="true"
auto-create-local-directory="true"
delete-remote-files="true"
filter="entryListFilter"
local-directory="."

View File

@@ -21,7 +21,7 @@
channel="ftpChannel"
session-factory="ftpSessionFactory"
charset="UTF-8"
auto-create-directories="true"
auto-create-local-directory="true"
delete-remote-files="true"
local-directory="."
remote-directory="foo/bar"
@@ -33,7 +33,7 @@
channel="ftpChannel"
session-factory="ftpSessionFactory"
charset="UTF-8"
auto-create-directories="true"
auto-create-local-directory="true"
delete-remote-files="true"
filename-pattern=".?txt"
local-directory="."

View File

@@ -24,7 +24,7 @@
<ftp:inbound-channel-adapter id="adapterFtp"
session-factory="ftpSessionFactory"
channel="ftpIn"
auto-create-directories="true"
auto-create-local-directory="true"
local-directory="file:target/foo"
remote-directory="foo/bar"
delete-remote-files="false">

View File

@@ -79,8 +79,8 @@ public class FtpInboundRemoteFileSystemSynchronizerTest {
synchronizer.setFilter(new FtpRegexPatternFileListFilter(".*\\.test$"));
FtpInboundFileSynchronizingMessageSource ms =
new FtpInboundFileSynchronizingMessageSource(synchronizer);
ms.setAutoCreateDirectories(true);
new FtpInboundFileSynchronizingMessageSource(synchronizer);
ms.setAutoCreateLocalDirectory(true);
ms.setLocalDirectory(localDirectoy);
ms.afterPropertiesSet();

View File

@@ -109,8 +109,15 @@
<xsd:attribute name="filename-pattern" type="xsd:string"/>
<xsd:attribute name="remote-directory" type="xsd:string" use="required"/>
<xsd:attribute name="local-directory" type="xsd:string" use="required"/>
<xsd:attribute name="auto-create-directories" type="xsd:boolean"/>
<xsd:attribute name="delete-remote-files" type="xsd:boolean"/>
<xsd:attribute name="auto-create-local-directory" type="xsd:boolean"/>
<xsd:attribute name="delete-remote-files" type="xsd:boolean">
<xsd:annotation>
<xsd:documentation>
Specify whether to delete the remote source file after copying.
By default, the remote files will NOT be deleted.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>

View File

@@ -36,7 +36,7 @@
filter="filter"
remote-directory="/foo"
local-directory="file:foo"
auto-create-directories="false"
auto-create-local-directory="false"
delete-remote-files="false">
<poller fixed-rate="1000"/>
</sftp:inbound-channel-adapter>

View File

@@ -37,7 +37,7 @@
filename-pattern="."
remote-directory="/foo"
local-directory="file:local-test-dir"
auto-create-directories="false"
auto-create-local-directory="false"
auto-delete-remote-files-on-sync="false">
<poller fixed-rate="1000"/>
</sftp:inbound-channel-adapter>

View File

@@ -41,7 +41,7 @@
filename-pattern="foo.txt"
remote-directory="/foo"
local-directory="file:local-test-dir"
auto-create-directories="false"
auto-create-local-directory="false"
delete-remote-files="false">
<poller fixed-rate="1000"/>
</sftp:inbound-channel-adapter>
@@ -52,7 +52,7 @@
filter="filter"
remote-directory="/foo"
local-directory="file:local-test-dir"
auto-create-directories="true"
auto-create-local-directory="true"
delete-remote-files="false">
<poller fixed-rate="1000"/>
</sftp:inbound-channel-adapter>
@@ -63,7 +63,7 @@
filename-pattern="pattern"
remote-directory="/foo"
local-directory="file:local-test-dir"
auto-create-directories="false"
auto-create-local-directory="false"
delete-remote-files="false">
<poller fixed-rate="1000"/>
</sftp:inbound-channel-adapter>
@@ -74,7 +74,7 @@
filename-pattern="pattern"
remote-directory="/foo"
local-directory="file:foo"
auto-create-directories="true"
auto-create-local-directory="true"
delete-remote-files="false">
<poller fixed-rate="1000"/>
</sftp:inbound-channel-adapter>

View File

@@ -36,7 +36,7 @@
local-directory="file:local-test-dir"
channel="inboundFilesChannel"
filename-pattern=".*?jpg"
auto-create-directories="true"
auto-create-local-directory="true"
delete-remote-files="true">
<poller fixed-rate="1000" />
</sftp:inbound-channel-adapter>

View File

@@ -81,8 +81,8 @@ public class SftpInboundRemoteFileSystemSynchronizerTests {
synchronizer.setFilter(new SftpRegexPatternFileListFilter(".*\\.test$"));
SftpInboundFileSynchronizingMessageSource ms =
new SftpInboundFileSynchronizingMessageSource(synchronizer);
ms.setAutoCreateDirectories(true);
new SftpInboundFileSynchronizingMessageSource(synchronizer);
ms.setAutoCreateLocalDirectory(true);
ms.setLocalDirectory(localDirectoy);
ms.afterPropertiesSet();
Message<File> atestFile = ms.receive();