Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to filter files by extensions using include parameter in Camel component File2

I need the simplest filter by extension: f.e. file 20120523.173227.CustomerMaster05092012.QWERTY.xml route:

<from uri="file://{{fdr.folder.working.url}}&amp;include=*.xml"/>

doesn't work:

Dangling meta character '*' near index 0

WARN - file://root_folder/working/) [FileConsumer] Consumer Consumer[file://root_folder/working/?delay=1000&delete=true&idempotent=false&include=*.xml&initialDelay=1000&readLock=changed] failed polling endpoint: Endpoint[file://root_folder/working/?delay=1000&delete=true&idempotent=false&include=*.xml&initialDelay=1000&readLock=changed]. Will try again at next poll. Caused by: [java.util.regex.PatternSyntaxException - Dangling meta character '*' near index 0
*.xml
^]
java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0
*.xml
^
    at java.util.regex.Pattern.error(Pattern.java:1713)
    at java.util.regex.Pattern.sequence(Pattern.java:1878)
    at java.util.regex.Pattern.expr(Pattern.java:1752)
    at java.util.regex.Pattern.compile(Pattern.java:1460)
    at java.util.regex.Pattern.<init>(Pattern.java:1133)
    at java.util.regex.Pattern.compile(Pattern.java:823)
    at java.util.regex.Pattern.matches(Pattern.java:928)
    at java.lang.String.matches(String.java:2090)
    at org.apache.camel.component.file.GenericFileConsumer.isMatched(GenericFileConsumer.java:458)
    at org.apache.camel.component.file.GenericFileConsumer.isValidFile(GenericFileConsumer.java:395)
    at org.apache.camel.component.file.FileConsumer.pollDirectory(FileConsumer.java:94)
    at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:107)
    at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:142)
    at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:92)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

ok maybe my bad. I put whole file to include:

<from uri="file://{{fdr.folder.working.url}}&amp;include=20120523.173227.CustomerMaster05092012.QWERTY.xml"/>

Whole file is OK. Let's try put * in the middle of file name

<from uri="file://{{fdr.folder.working.url}}&amp;include=20120523.*.xml"/>

and again it is OK. Let's put only one digit in file name

<from uri="file://{{fdr.folder.working.url}}&amp;include=2*.xml"/>

noup, camel didn't find such files I tried escaped asterisk but it did't help.

<from uri="file://{{fdr.folder.working.url}}&amp;include=\*.xml"/>
and
<from uri="file://{{fdr.folder.working.url}}&amp;include=\\*.xml"/>

File was just ignored. so question 1: how to use asterisk?

and question 2: how to use multimple file extensions, like include=.xml;.zip

thks

like image 204
Dmitrii Borovoi Avatar asked Feb 25 '13 04:02

Dmitrii Borovoi


2 Answers

damn, good thinking comes after, using brute force I found out correct value for include:

.*.xml|.*.zip
like image 197
Dmitrii Borovoi Avatar answered Oct 26 '22 10:10

Dmitrii Borovoi


(?i).*.xml|.*.zip

If you want case insensitive file extension matching.

like image 25
Simon Avatar answered Oct 26 '22 10:10

Simon