This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 547fa27 CAMEL-16663: camel-file - excludeExt and includeExt now
support non-single extensions (#5610)
547fa27 is described below
commit 547fa27eb5b115f59636d004ac609cc56f1abd16
Author: rupigill <[email protected]>
AuthorDate: Wed Jun 2 02:29:38 2021 -0500
CAMEL-16663: camel-file - excludeExt and includeExt now support non-single
extensions (#5610)
For example:
"excludeExt=filepart" would match file "foo.bar.filepart" (previously it
would not)
"excludeExt=gz" would match files "foo.tar.gz" and "foo.gz" (previously
only "foo.gz" would match)
"excludeExt=tar.gz" would match file "foo.tar.gz" but not "foo.gz" (same as
before)
Co-authored-by: Rupinder S. Gill <[email protected]>
---
.../apache/camel/component/file/GenericFileConsumer.java | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git
a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
index f6effa9..a3fa67c 100644
---
a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
+++
b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
@@ -36,7 +36,6 @@ import org.apache.camel.support.EmptyAsyncCallback;
import org.apache.camel.support.ScheduledBatchPollingConsumer;
import org.apache.camel.support.service.ServiceHelper;
import org.apache.camel.util.CastUtils;
-import org.apache.camel.util.FileUtil;
import org.apache.camel.util.StopWatch;
import org.apache.camel.util.StringHelper;
import org.apache.camel.util.TimeUtils;
@@ -72,8 +71,8 @@ public abstract class GenericFileConsumer<T> extends
ScheduledBatchPollingConsum
this.includePattern = endpoint.getIncludePattern();
this.excludePattern = endpoint.getExcludePattern();
- this.includeExt = endpoint.getIncludeExt() != null ?
endpoint.getIncludeExt().split(",") : null;
- this.excludeExt = endpoint.getExcludeExt() != null ?
endpoint.getExcludeExt().split(",") : null;
+ this.includeExt = endpoint.getIncludeExt() != null ?
endpoint.getIncludeExt().toLowerCase().split(",") : null;
+ this.excludeExt = endpoint.getExcludeExt() != null ?
endpoint.getExcludeExt().toLowerCase().split(",") : null;
}
public Processor getCustomProcessor() {
@@ -679,9 +678,9 @@ public abstract class GenericFileConsumer<T> extends
ScheduledBatchPollingConsum
}
}
if (excludeExt != null) {
- String ext = FileUtil.onlyExt(file.getFileName());
+ String fname = file.getFileName().toLowerCase();
for (String exclude : excludeExt) {
- if (exclude.equalsIgnoreCase(ext)) {
+ if (fname.endsWith("." + exclude)) {
return false;
}
}
@@ -692,10 +691,10 @@ public abstract class GenericFileConsumer<T> extends
ScheduledBatchPollingConsum
}
}
if (includeExt != null) {
- String ext = FileUtil.onlyExt(file.getFileName());
+ String fname = file.getFileName().toLowerCase();
boolean any = false;
for (String include : includeExt) {
- any |= include.equalsIgnoreCase(ext);
+ any |= fname.endsWith("." + include);
}
if (!any) {
return false;