This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 1cc8257  CAMEL-12126: camel-ftp - Add option for resume download.
1cc8257 is described below

commit 1cc8257ed8cfa6091dba6ef27b809688c0d9c09c
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Wed Jan 10 09:30:50 2018 +0100

    CAMEL-12126: camel-ftp - Add option for resume download.
---
 components/camel-ftp/src/main/docs/ftp-component.adoc              | 2 +-
 components/camel-ftp/src/main/docs/ftps-component.adoc             | 2 +-
 .../java/org/apache/camel/component/file/remote/FtpEndpoint.java   | 7 +++++--
 .../java/org/apache/camel/component/file/remote/FtpOperations.java | 5 -----
 .../camel/component/file/remote/FtpConsumerResumeDownloadTest.java | 2 +-
 5 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/components/camel-ftp/src/main/docs/ftp-component.adoc 
b/components/camel-ftp/src/main/docs/ftp-component.adoc
index 0148e28..fed7ccd 100644
--- a/components/camel-ftp/src/main/docs/ftp-component.adoc
+++ b/components/camel-ftp/src/main/docs/ftp-component.adoc
@@ -120,7 +120,7 @@ with the following path and query parameters:
 | *preMove* (consumer) | Expression (such as File Language) used to 
dynamically set the filename when moving it before processing. For example to 
move in-progress files into the order directory set this value to order. |  | 
String
 | *preSort* (consumer) | When pre-sort is enabled then the consumer will sort 
the file and directory names during polling that was retrieved from the file 
system. You may want to do this in case you need to operate on the files in a 
sorted order. The pre-sort is executed before the consumer starts to filter and 
accept files to process by Camel. This option is default=false meaning 
disabled. | false | boolean
 | *recursive* (consumer) | If a directory will look for files in all the 
sub-directories as well. | false | boolean
-| *resumeDownload* (consumer) | Configures whether resume download is enabled. 
This must be supported by the FTP server (almost all FTP servers support it). 
In addition the option localWorkDirectory must be configured so downloaded 
files are stored in a local directory which is required to support resuming of 
downloads. | false | boolean
+| *resumeDownload* (consumer) | Configures whether resume download is enabled. 
This must be supported by the FTP server (almost all FTP servers support it). 
In addition the options localWorkDirectory must be configured so downloaded 
files are stored in a local directory and the option binary must be enabled 
which is required to support resuming of downloads. | false | boolean
 | *sendEmptyMessageWhenIdle* (consumer) | If the polling consumer did not poll 
any files you can enable this option to send an empty message (no body) 
instead. | false | boolean
 | *streamDownload* (consumer) | Sets the download method to use when not using 
a local working directory. If set to true the remote files are streamed to the 
route as they are read. When set to false the remote files are loaded into 
memory before being sent into the route. | false | boolean
 | *directoryMustExist* (consumer) | Similar to startingDirectoryMustExist but 
this applies during polling recursive sub directories. | false | boolean
diff --git a/components/camel-ftp/src/main/docs/ftps-component.adoc 
b/components/camel-ftp/src/main/docs/ftps-component.adoc
index 80af0c1..2640dc9 100644
--- a/components/camel-ftp/src/main/docs/ftps-component.adoc
+++ b/components/camel-ftp/src/main/docs/ftps-component.adoc
@@ -80,7 +80,7 @@ with the following path and query parameters:
 | *preMove* (consumer) | Expression (such as File Language) used to 
dynamically set the filename when moving it before processing. For example to 
move in-progress files into the order directory set this value to order. |  | 
String
 | *preSort* (consumer) | When pre-sort is enabled then the consumer will sort 
the file and directory names during polling that was retrieved from the file 
system. You may want to do this in case you need to operate on the files in a 
sorted order. The pre-sort is executed before the consumer starts to filter and 
accept files to process by Camel. This option is default=false meaning 
disabled. | false | boolean
 | *recursive* (consumer) | If a directory will look for files in all the 
sub-directories as well. | false | boolean
-| *resumeDownload* (consumer) | Configures whether resume download is enabled. 
This must be supported by the FTP server (almost all FTP servers support it). 
In addition the option localWorkDirectory must be configured so downloaded 
files are stored in a local directory which is required to support resuming of 
downloads. | false | boolean
+| *resumeDownload* (consumer) | Configures whether resume download is enabled. 
This must be supported by the FTP server (almost all FTP servers support it). 
In addition the options localWorkDirectory must be configured so downloaded 
files are stored in a local directory and the option binary must be enabled 
which is required to support resuming of downloads. | false | boolean
 | *sendEmptyMessageWhenIdle* (consumer) | If the polling consumer did not poll 
any files you can enable this option to send an empty message (no body) 
instead. | false | boolean
 | *streamDownload* (consumer) | Sets the download method to use when not using 
a local working directory. If set to true the remote files are streamed to the 
route as they are read. When set to false the remote files are loaded into 
memory before being sent into the route. | false | boolean
 | *directoryMustExist* (consumer) | Similar to startingDirectoryMustExist but 
this applies during polling recursive sub directories. | false | boolean
diff --git 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
index 2d332a8..2bce128 100644
--- 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
+++ 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
@@ -85,6 +85,9 @@ public class FtpEndpoint<T extends FTPFile> extends 
RemoteFileEndpoint<FTPFile>
         if (isResumeDownload() && 
ObjectHelper.isEmpty(getLocalWorkDirectory())) {
             throw new IllegalArgumentException("The option localWorkDirectory 
must be configured when resumeDownload=true");
         }
+        if (isResumeDownload() && !getConfiguration().isBinary()) {
+            throw new IllegalArgumentException("The option binary must be 
enabled when resumeDownload=true");
+        }
         return super.createConsumer(processor);
     }
 
@@ -327,8 +330,8 @@ public class FtpEndpoint<T extends FTPFile> extends 
RemoteFileEndpoint<FTPFile>
 
     /**
      * Configures whether resume download is enabled. This must be supported 
by the FTP server (almost all FTP servers support it).
-     * In addition the option <tt>localWorkDirectory</tt> must be configured 
so downloaded files are stored in a local directory,
-     * which is required to support resuming of downloads.
+     * In addition the options <tt>localWorkDirectory</tt> must be configured 
so downloaded files are stored in a local directory,
+     * and the option <tt>binary</tt> must be enabled, which is required to 
support resuming of downloads.
      */
     public void setResumeDownload(boolean resumeDownload) {
         this.resumeDownload = resumeDownload;
diff --git 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
index 9c47896..36a7c5d 100644
--- 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
+++ 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
@@ -527,11 +527,6 @@ public class FtpOperations implements 
RemoteFileOperations<FTPFile> {
                 
clientActivityListener.onResumeDownloading(endpoint.getConfiguration().remoteServerInformation(),
 name, existingSize);
                 log.trace("Client restartOffset: {}", existingSize);
                 log.debug("Resuming download of file: {} at position: {}", 
remoteName, existingSize);
-                // use binary for resume downloads as FTP servers would expect 
that
-                if (!endpoint.getConfiguration().isBinary()) {
-                    log.debug("Resume download requires file type binary 
mode");
-                    client.setFileType(FTP.BINARY_FILE_TYPE);
-                }
                 client.setRestartOffset(existingSize);
             }
             log.trace("Client retrieveFile: {}", remoteName);
diff --git 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerResumeDownloadTest.java
 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerResumeDownloadTest.java
index 6ef0e5f..fd09718 100644
--- 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerResumeDownloadTest.java
+++ 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerResumeDownloadTest.java
@@ -33,7 +33,7 @@ public class FtpConsumerResumeDownloadTest extends 
FtpServerTestSupport {
 
     protected String getFtpUrl() {
         return "ftp://admin@localhost:"; + getPort()
-               + 
"/myserver/?password=admin&localWorkDirectory=target/lwd&resumeDownload=true";
+               + 
"/myserver/?password=admin&localWorkDirectory=target/lwd&resumeDownload=true&binary=true";
     }
 
     @Override

-- 
To stop receiving notification emails like this one, please contact
['"commits@camel.apache.org" <commits@camel.apache.org>'].

Reply via email to