diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/handler/FileTransferringMessageHandler.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/handler/FileTransferringMessageHandler.java index 94642ff3fe..92c98a7335 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/handler/FileTransferringMessageHandler.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/handler/FileTransferringMessageHandler.java @@ -255,11 +255,11 @@ public class FileTransferringMessageHandler extends AbstractMessageHandler { break; } else { - pathsToCreate.add(pathSegment); + pathsToCreate.add(0, pathSegment); nextSeparatorIndex = pathSegment.lastIndexOf(remoteFileSeparator); } } - Collections.reverse(pathsToCreate); + for (String pathToCreate : pathsToCreate) { if (logger.isDebugEnabled()){ logger.debug("Creating '" + pathToCreate + "'"); diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/CachingSessionFactory.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/CachingSessionFactory.java index 56ec47e639..38b352df01 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/CachingSessionFactory.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/CachingSessionFactory.java @@ -155,8 +155,8 @@ public class CachingSessionFactory implements SessionFactory, DisposableBe this.targetSession.rename(pathFrom, pathTo); } - public void mkdir(String directory) throws IOException { - this.targetSession.mkdir(directory); + public boolean mkdir(String directory) throws IOException { + return this.targetSession.mkdir(directory); } public boolean exists(String path) throws IOException{ diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/Session.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/Session.java index 62f6da68a2..a6a6cd6eb9 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/Session.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/Session.java @@ -39,7 +39,7 @@ public interface Session { void write(InputStream inputStream, String destination) throws IOException; - void mkdir(String directory) throws IOException; + boolean mkdir(String directory) throws IOException; void rename(String pathFrom, String pathTo) throws IOException; diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java index 691fb25ee8..c4d72604f0 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java @@ -262,7 +262,8 @@ public class RemoteFileOutboundGatewayTests { public void write(InputStream inputStream, String destination) throws IOException { } - public void mkdir(String directory) throws IOException { + public boolean mkdir(String directory) throws IOException { + return true; } public void rename(String pathFrom, String pathTo) throws IOException { @@ -320,7 +321,8 @@ public class RemoteFileOutboundGatewayTests { public void write(InputStream inputStream, String destination) throws IOException { } - public void mkdir(String directory) throws IOException { + public boolean mkdir(String directory) throws IOException { + return true; } public void rename(String pathFrom, String pathTo) throws IOException { @@ -375,7 +377,8 @@ public class RemoteFileOutboundGatewayTests { public void write(InputStream inputStream, String destination) throws IOException { } - public void mkdir(String directory) throws IOException { + public boolean mkdir(String directory) throws IOException { + return true; } public void rename(String pathFrom, String pathTo) throws IOException { diff --git a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/session/FtpSession.java b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/session/FtpSession.java index 67d3d34c43..dc0ef9d39a 100644 --- a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/session/FtpSession.java +++ b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/session/FtpSession.java @@ -119,8 +119,8 @@ class FtpSession implements Session { } } - public void mkdir(String remoteDirectory) throws IOException { - this.client.makeDirectory(remoteDirectory); + public boolean mkdir(String remoteDirectory) throws IOException { + return this.client.makeDirectory(remoteDirectory); } public boolean exists(String path) throws IOException{ diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/SftpSession.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/SftpSession.java index 60d12378c6..92e49a688a 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/SftpSession.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/SftpSession.java @@ -151,13 +151,14 @@ class SftpSession implements Session { } } - public void mkdir(String remoteDirectory) throws IOException { + public boolean mkdir(String remoteDirectory) throws IOException { try { this.channel.mkdir(remoteDirectory); } catch (SftpException e) { throw new NestedIOException("failed to create remote directory '" + remoteDirectory + "'.", e); } + return true; } public boolean exists(String path) {