Author: davsclaus
Date: Fri Mar 15 09:04:41 2013
New Revision: 1456816
URL: http://svn.apache.org/r1456816
Log:
CAMEL-6056: ftp component should use configured path separator when calculating
paths during changing dir operation. Thanks to Robin Lutter for the patch.
Modified:
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
Modified:
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java?rev=1456816&r1=1456815&r2=1456816&view=diff
==============================================================================
---
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
(original)
+++
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
Fri Mar 15 09:04:41 2013
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.file.remote;
+import java.io.File;
import java.util.Map;
import org.apache.camel.FailedToCreateConsumerException;
@@ -23,6 +24,7 @@ import org.apache.camel.FailedToCreatePr
import org.apache.camel.Processor;
import org.apache.camel.component.file.GenericFileConfiguration;
import org.apache.camel.component.file.GenericFileProducer;
+import
org.apache.camel.component.file.remote.RemoteFileConfiguration.PathSeparator;
import org.apache.camel.util.IntrospectionSupport;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPClientConfig;
@@ -190,4 +192,21 @@ public class FtpEndpoint<T extends FTPFi
public void setSoTimeout(int soTimeout) {
this.soTimeout = soTimeout;
}
+
+ @Override
+ public char getFileSeparator() {
+ // the regular ftp component should use the configured separator
+ // as FTP servers may require you to use windows or unix style
+ // and therefore you need to be able to control that
+ PathSeparator pathSeparator = getConfiguration().getSeparator();
+ switch (pathSeparator) {
+ case Windows:
+ return '\\';
+ case UNIX:
+ return '/';
+ default:
+ // use the OS specific separator
+ return File.separatorChar;
+ }
+ }
}
Modified:
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java?rev=1456816&r1=1456815&r2=1456816&view=diff
==============================================================================
---
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
(original)
+++
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
Fri Mar 15 09:04:41 2013
@@ -696,7 +696,12 @@ public class FtpOperations implements Re
}
// must compact path so FTP server can traverse correctly
- path = FileUtil.compactPath(path);
+ String before = path;
+ char separatorChar = endpoint.getFileSeparator();
+ path = FileUtil.compactPath(path, separatorChar);
+ if (log.isTraceEnabled()) {
+ log.trace("Compacted path: {} -> {} using separator: {}", new
Object[]{before, path, separatorChar});
+ }
// not stepwise should change directory in one operation
if (!endpoint.getConfiguration().isStepwise()) {
Modified:
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java?rev=1456816&r1=1456815&r2=1456816&view=diff
==============================================================================
---
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
(original)
+++
camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
Fri Mar 15 09:04:41 2013
@@ -389,7 +389,12 @@ public class SftpOperations implements R
// must compact path so SFTP server can traverse correctly, make use
of the '/'
// separator because JSch expects this as the file separator even on
Windows
- path = FileUtil.compactPath(path, '/');
+ String before = path;
+ char separatorChar = '/';
+ path = FileUtil.compactPath(path, separatorChar);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Compacted path: {} -> {} using separator: {}", new
Object[]{before, path, separatorChar});
+ }
// not stepwise should change directory in one operation
if (!endpoint.getConfiguration().isStepwise()) {