骆驼:GenericFileFilter 和 Recursive 不能一起工作

Camel: GenericFileFilter and Recursive not working together

我正在尝试使用 camel 从 FTP 服务器下载几个文件。

我正在使用 recursive=true 选项和 include=..xlsx|..xlsm选项。

我的端点是这样的:

from(FTP_OPTION + "?include=.*.xlsx|.*.xlsm&recursive=true")
.to(ANOTHER_ENDPOINT);

这工作正常,但现在我需要一个更强大的过滤器,所以我正在使用 GenericFileFilter

我的过滤器看起来像这样:

public class MyFilter <T> implements GenericFileFilter<T>{
    @Override
    public boolean accept(GenericFile<T> file) {    
        String name = file.getFileName();
        final String regex = "[\w,\s-ñÑ]+\.(xlsx|xlsm)";
        return name.matches(regex);
    }
}

我的新端点是:

from(FTP_OPTION + "?filter=#myFilter&recursive=true")
.to(ANOTHER_ENDPOINT);

问题是当我使用这个端点时,只从根级别获取文件而不在子目录中查找文件。

Filter 和 Recursive 之间是否存在某种不兼容?或者我缺少其他选项?

谢谢!

AFAIR 通用过滤器也用于目录,因此您需要检查这个和 return true 以接受哪些目录。有一个 isDirectory 方法可以用来知道,如果你只想要所有目录,那么 return true。