camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Raghavan (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-7752) filter with camel sftp is returnin NullPointerException
Date Wed, 27 Aug 2014 07:46:57 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-7752?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14111996#comment-14111996
] 

Raghavan commented on CAMEL-7752:
---------------------------------

Thanks Claus. Using getFileNameOnly() fixed the issue related to files

However with filter in place, even with recursive=true, the files under subDirectories are
not read in the filter.
For e.g.
/home/user1
                   > a.xml                          [processed successfully]
                   > b.txt                            [ignored as expected]
                   > folder1/c.xml              [not read]
                   > folder2/d.xml              [not read] 

> filter with camel sftp is returnin NullPointerException
> -------------------------------------------------------
>
>                 Key: CAMEL-7752
>                 URL: https://issues.apache.org/jira/browse/CAMEL-7752
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-ftp
>    Affects Versions: 2.10.0
>         Environment: Windows 7, RedHat Linux 5.x
>            Reporter: Raghavan
>              Labels: GenericFile, camel-ftp, filter, ftp
>
> 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}}&amp;separator=UNIX&amp;recursive={{ftp.dir.recursive}}&amp;binary=true&amp;delete={{ftp.deletefiles}}&amp;stepwise={{ftp.stepwise}}&amp;delay={{ftp.pollinginterval}}&amp;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]]



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message