Merge branch 'master' of git.springsource.org:spring-integration/spring-integration
This commit is contained in:
@@ -71,7 +71,7 @@ public class ClientFactorySupport {
|
||||
return defaultFtpClientFactory;
|
||||
}
|
||||
|
||||
public static DefaultFtpClientFactory ftpClientFactory(String host, int port, String remoteDir, String user, String pw, int clientMode) {
|
||||
public static DefaultFtpClientFactory ftpClientFactory(String host, int port, String remoteDir, String user, String pw, int clientMode, int fileType) {
|
||||
DefaultFtpClientFactory defaultFtpClientFactory = new DefaultFtpClientFactory();
|
||||
defaultFtpClientFactory.setHost(host);
|
||||
defaultFtpClientFactory.setPassword(pw);
|
||||
@@ -79,6 +79,7 @@ public class ClientFactorySupport {
|
||||
defaultFtpClientFactory.setRemoteWorkingDirectory(remoteDir);
|
||||
defaultFtpClientFactory.setUsername(user);
|
||||
defaultFtpClientFactory.setClientMode(clientMode);
|
||||
defaultFtpClientFactory.setFileType( fileType );
|
||||
|
||||
return defaultFtpClientFactory;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,12 @@ public class FtpSendingMessageHandlerFactoryBean extends AbstractFactoryBean<Ftp
|
||||
protected String remoteDirectory;
|
||||
protected int clientMode;
|
||||
|
||||
public void setFileType(int fileType) {
|
||||
this.fileType = fileType;
|
||||
}
|
||||
|
||||
private int fileType ;
|
||||
|
||||
// private vars
|
||||
private ResourceLoader resourceLoader;
|
||||
private ApplicationContext applicationContext;
|
||||
@@ -46,7 +52,7 @@ public class FtpSendingMessageHandlerFactoryBean extends AbstractFactoryBean<Ftp
|
||||
}
|
||||
|
||||
protected AbstractFtpClientFactory clientFactory() {
|
||||
return ClientFactorySupport.ftpClientFactory( this.host, this.port , this.remoteDirectory , this.username , this.password , this.clientMode );
|
||||
return ClientFactorySupport.ftpClientFactory( this.host, this.port , this.remoteDirectory , this.username , this.password , this.clientMode, this.fileType );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,6 +65,7 @@ public class FtpSendingMessageHandlerFactoryBean extends AbstractFactoryBean<Ftp
|
||||
QueuedFtpClientPool queuedFtpClientPool = new QueuedFtpClientPool(15, defaultFtpClientFactory);
|
||||
|
||||
FtpSendingMessageHandler ftpSendingMessageHandler = new FtpSendingMessageHandler(queuedFtpClientPool);
|
||||
|
||||
ftpSendingMessageHandler.afterPropertiesSet();
|
||||
|
||||
return ftpSendingMessageHandler;
|
||||
|
||||
@@ -14,6 +14,9 @@ public class FtpsSendingMessageHandlerFactoryBean extends FtpSendingMessageHandl
|
||||
*/
|
||||
protected volatile String protocol;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* "P"
|
||||
*/
|
||||
|
||||
@@ -38,6 +38,7 @@ public class FtpRemoteFileSystemSynchronizingMessageSourceFactoryBean extends Ab
|
||||
protected volatile int clientMode = FTPClient.ACTIVE_LOCAL_DATA_CONNECTION_MODE;
|
||||
protected volatile int fileType = FTP.BINARY_FILE_TYPE;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void setFileType(int fileType) {
|
||||
this.fileType = fileType;
|
||||
}
|
||||
@@ -61,7 +62,8 @@ public class FtpRemoteFileSystemSynchronizingMessageSourceFactoryBean extends Ab
|
||||
}
|
||||
|
||||
protected AbstractFtpClientFactory defaultClientFactory() throws Exception {
|
||||
return ClientFactorySupport.ftpClientFactory( this.host , Integer.parseInt(this.port) , this.remoteDirectory , this.username ,this.password, this.clientMode );
|
||||
return ClientFactorySupport.ftpClientFactory( this.host , Integer.parseInt(this.port) , this.remoteDirectory ,
|
||||
this.username ,this.password, this.clientMode , this.fileType);
|
||||
}
|
||||
|
||||
protected String defaultFtpInboundFolderName = "ftpInbound";
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
remote-directory="${ftp.remotedir}"
|
||||
channel="ftpOutbound"
|
||||
host="${ftp.host}"
|
||||
file-type="binary-file-type"
|
||||
username="${ftp.username}"
|
||||
password="${ftp.password}" port="2222"
|
||||
client-mode="passive-local-data-connection-mode"
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<ftps:outbound-channel-adapter
|
||||
remote-directory="${ftp.remotedir}"
|
||||
channel="ftpOutbound"
|
||||
file-type="binary-file-type"
|
||||
host="${ftp.host}"
|
||||
username="${ftp.username}"
|
||||
password="${ftp.password}" port="21"
|
||||
|
||||
@@ -68,7 +68,7 @@ public class SftpNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "filter");
|
||||
|
||||
for (String p : "filename-pattern,auto-create-directories,username,password,host,key-file,key-file-password,remote-directory,local-working-directory,auto-delete-remote-files-on-sync".split(",")) {
|
||||
for (String p : "filename-pattern,auto-create-directories,username,password,host,key-file,key-file-password,remote-directory,local-directory-path,auto-delete-remote-files-on-sync".split(",")) {
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, p);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,17 +73,20 @@ public class SftpInboundRemoteFileSystemSynchronizer extends AbstractInboundRemo
|
||||
|
||||
String remoteFqPath = this.remotePath + "/" + entry.getFilename();
|
||||
in = sftpSession.getChannel().get(remoteFqPath);
|
||||
IOUtils.copy(in, fileOutputStream);
|
||||
try {
|
||||
IOUtils.copy(in, fileOutputStream);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(in);
|
||||
IOUtils.closeQuietly(fileOutputStream);
|
||||
}
|
||||
|
||||
if (tmpLocalTarget.renameTo(localFile)) {
|
||||
// last step
|
||||
this.acknowledge(sftpSession, entry);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Throwable th) {
|
||||
IOUtils.closeQuietly(in);
|
||||
IOUtils.closeQuietly(fileOutputStream);
|
||||
logger.error("exception thrown in #copyFromRemoteToLocalDirectory", th);
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
|
||||
@@ -127,7 +127,7 @@ public class SftpRemoteFileSystemSynchronizingMessageSourceFactoryBean extends A
|
||||
sftpMsgSrc.setAutoCreateDirectories(autoCreatDirs);
|
||||
|
||||
// local directories
|
||||
if ((this.localDirectoryResource == null) || !StringUtils.hasText(this.localDirectoryPath)) {
|
||||
if ((this.localDirectoryResource == null) && !StringUtils.hasText(this.localDirectoryPath)) {
|
||||
File tmp = SystemUtils.getJavaIoTmpDir();
|
||||
File sftpTmp = new File(tmp, "sftpInbound");
|
||||
this.localDirectoryPath = "file://" + sftpTmp.getAbsolutePath();
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
|
||||
<xsd:attribute name="username" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="remote-directory" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="local-working-directory" type="xsd:string"/>
|
||||
<xsd:attribute name="local-directory-path" type="xsd:string"/>
|
||||
<xsd:attribute name="host" type="xsd:string" use="required"/>
|
||||
|
||||
<xsd:attribute name="password" type="xsd:string"/>
|
||||
|
||||
Reference in New Issue
Block a user