Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Invalid
-
2.10.0
-
None
-
Windows 7, RedHat Linux 5.x
-
Unknown
Description
We are testing camel sftp with filter options to restrict the source files using a pattern.
We get a NullPointerException when try to use a filter (CustomFilter)
Attached herewith the code snippet
[[CodeSnippet]]
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext xmlns="http://camel.apache.org/schema/spring">
<camel:propertyPlaceholder id="ftpadapterProperty" location="classpath:ftpadapter.properties"/>
<!-- The file filter is to be tested -->
<route>
<from uri="sftp://ftp.user@ftp.host/ftp.remote.dir?password=ftp.pwd&separator=UNIX&recursive=ftp.dir.recursive&binary=true&delete=ftp.deletefiles&stepwise=ftp.stepwise&delay=ftp.pollinginterval&filter=#fileFilter"/>
<to uri="file://local.dir?fileName=${date:now:yyyyMMddhhmmss}_${file:onlyname.noext}.${file:ext}"/>
<log message="Routing message from remote server to target folder with data ${body}" />
</route>
</camelContext>
<bean id="fileFilter" class="org.myapp.ftpadapter.FileFilter"/>
</beans>
FileFilter src:
public class FileFilter<T> implements GenericFileFilter<T> {
private static Logger logger = LoggerFactory.getLogger(FileFilter.class);
/* The purpose of this method is to apply a custom filter based on file pattern
- This enables the ftp adapter to filter files based on the criteria implemented here
- (non-Javadoc)
- @see org.apache.camel.component.file.GenericFileFilter#accept(org.apache.camel.component.file.GenericFile)
*/
public boolean accept(GenericFile<T> file) {
if(logger.isDebugEnabled())
{ logger.debug("IsDirectory=" + file.isDirectory()); logger.debug("FileName="+file.getFileName()); }if(file !=null && file.getFileName() != null)
{ return file.getFileName().endsWith(".xml"); }else
{ return false; }}
}
[[/CodeSnippet]]