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

Paddy Daly commented on CAMEL-1428:
-----------------------------------

move=${file:parent}/.done/${file:name}

{Code}

        getContext().addInterceptStrategy(new Tracer());
        from(getSftpEndPoint())
                
                .process(new Processor() {
                        public void process(final Exchange exchange) throws 
Exception {
                                Message message =  exchange.getIn();
                                log.info("message " + message);
                                String filename = 
message.getHeader(Exchange.FILE_NAME_ONLY, String.class);
                                
                                message.setHeader(Exchange.FILE_NAME, filename);
                                log.info("filename " + filename);
                                exchange.getOut().setHeader(
                                                                
Exchange.FILE_NAME,
                                                                filename);
                        }
                }). 
                to(getFileRepository())
                .setHeader(
                                "filename", 
groovy("in.headers.filename")).setBody(constant(null)).to("activemq:queue:print");
                                
{code}


{code}
[le.remote.sftpcompon...@1321f5] SftpEndpoint                   DEBUG Using 
Generic file process strategy: 
org.apache.camel.component.file.strategy.genericfilerenameprocessstrat...@e7d53
[le.remote.sftpcompon...@1321f5] SftpOperations                 DEBUG Renaming 
file: temp/incoming/file.txt to: temp/incoming/file.txt.camelExclusiveReadLock
[le.remote.sftpcompon...@1321f5] SftpOperations                 DEBUG Renaming 
file: temp/incoming/file.txt.camelExclusiveReadLock to: temp/incoming/file.txt
[le.remote.sftpcompon...@1321f5] SftpConsumer                   DEBUG About to 
process file: GenericFile[temp/incoming/file.txt] using exchange: 
Exchange[GenericFileMessage: GenericFile[temp/incoming/file.txt]]
[le.remote.sftpcompon...@1321f5] TraceInterceptor               INFO  
ID-DELLPD-2715-1236598778931-2-0 >>> 
sftp://[email protected]?password=pass&readLock=rename&binary=true&recursive=true&delay=10000&initialDelay=2000&move=${file:parent}/.done/${file:name}&knownHostsFile=c://known_host&filter=#myAntFilter
 --> process(com.xxx.xxx.router.routercomponen...@cd4544), Pattern:InOnly, 
Headers:{CamelFileBatchSize=1, CamelFileNameOnly=file.txt, 
CamelFileBatchIndex=0, CamelFileLastModified=Mon Mar 09 11:34:06 GMT 2009, 
CamelFileRelativePath=temp/incoming/file.txt, 
CamelFileAbsolutePath=temp/incoming/file.txt, CamelFileName=null, 
CamelFilePath=\temp/incoming/file.txt, CamelFileParent=temp/incoming, 
CamelFileHost=192.168.51.5, CamelFileAbsolute=false}, 
BodyType:org.apache.camel.component.file.remote.RemoteFile, Body:
[le.remote.sftpcompon...@1321f5] RouterComponent                INFO  message 
GenericFileMessage: GenericFile[temp/incoming/file.txt]
[le.remote.sftpcompon...@1321f5] RouterComponent                INFO  filename 
file.txt
[le.remote.sftpcompon...@1321f5] TraceInterceptor               INFO  
ID-DELLPD-2715-1236598778931-2-0 >>> 
process(com.xxx.xxx.router.routercomponen...@cd4544) --> 
to(file://c://fileserver), Pattern:InOnly, Headers:{CamelFileNameOnly=file.txt, 
CamelFileLastModified=Mon Mar 09 11:34:06 GMT 2009, 
CamelFileRelativePath=temp/incoming/file.txt, 
CamelFileAbsolutePath=temp/incoming/file.txt, CamelFileName=file.txt, 
CamelFilePath=\temp/incoming/file.txt, CamelFileParent=temp/incoming, 
CamelFileAbsolute=false}, BodyType:java.io.ByteArrayOutputStream, Body:
[le.remote.sftpcompon...@1321f5] GenericFileProducer            DEBUG Wrote 
[c:\fileserver\file.txt] to [Endpoint[file://c://fileserver]]
[le.remote.sftpcompon...@1321f5] TraceInterceptor               INFO  
ID-DELLPD-2715-1236598778931-2-0 >>> to(file://c://fileserver) --> 
setHeader(groovy: in.headers.filename), Pattern:InOnly, 
Headers:{CamelFileNameOnly=file.txt, CamelFileLastModified=Mon Mar 09 11:34:06 
GMT 2009, CamelFileRelativePath=temp/incoming/file.txt, 
CamelFileAbsolutePath=temp/incoming/file.txt, CamelFileName=file.txt, 
CamelFilePath=\temp/incoming/file.txt, CamelFileParent=temp/incoming, 
CamelFileNameProduced=c:\fileserver\file.txt, CamelFileAbsolute=false}, 
BodyType:java.io.ByteArrayOutputStream, Body:
[le.remote.sftpcompon...@1321f5] TraceInterceptor               INFO  
ID-DELLPD-2715-1236598778931-2-0 >>> setHeader(groovy: in.headers.filename) --> 
setBody(null), Pattern:InOnly, Headers:{CamelFileNameOnly=file.txt, 
CamelFileLastModified=Mon Mar 09 11:34:06 GMT 2009, 
CamelFileRelativePath=temp/incoming/file.txt, 
CamelFileAbsolutePath=temp/incoming/file.txt, CamelFileName=file.txt, 
CamelFilePath=\temp/incoming/file.txt, CamelFileParent=temp/incoming, 
filename=null, CamelFileNameProduced=c:\fileserver\file.txt, 
CamelFileAbsolute=false}, BodyType:java.io.ByteArrayOutputStream, Body:
[le.remote.sftpcompon...@1321f5] TraceInterceptor               INFO  
ID-DELLPD-2715-1236598778931-2-0 >>> setBody(null) --> 
to(activemq:queue:print), Pattern:InOnly, Headers:{CamelFileNameOnly=file.txt, 
CamelFileLastModified=Mon Mar 09 11:34:06 GMT 2009, 
CamelFileRelativePath=temp/incoming/file.txt, 
CamelFileAbsolutePath=temp/incoming/file.txt, CamelFileName=file.txt, 
CamelFilePath=\temp/incoming/file.txt, CamelFileParent=temp/incoming, 
filename=null, CamelFileNameProduced=c:\fileserver\file.txt, 
CamelFileAbsolute=false}, BodyType:java.io.ByteArrayOutputStream, Body:
[le.remote.sftpcompon...@1321f5] ObjectHelper                   WARN  Cannot 
find class: org.apache.xalan.xsltc.trax.DOM2SAX
[le.remote.sftpcompon...@1321f5] SftpConsumer                   DEBUG Done 
processing file: GenericFile[temp/incoming/file.txt]. Status is: processed OK
[le.remote.sftpcompon...@1321f5] SftpConsumer                   DEBUG 
Committing remote file strategy: 
org.apache.camel.component.file.strategy.genericfilerenameprocessstrat...@e7d53 
for file: GenericFile[temp/incoming/file.txt]
[le.remote.sftpcompon...@1321f5] SftpOperations                 DEBUG Deleteing 
file: temp/incoming/file.txt
[le.remote.sftpcompon...@1321f5] nericFileRenameProcessStrategy DEBUG Renaming 
file: GenericFile[temp/incoming/file.txt] to: 
GenericFile[temp/incoming/file.txt]
[le.remote.sftpcompon...@1321f5] SftpOperations                 DEBUG Renaming 
file: temp/incoming/file.txt to: temp/incoming/file.txt
[le.remote.sftpcompon...@1321f5] SftpConsumer                   WARN  Error 
committing remote file strategy: 
org.apache.camel.component.file.strategy.genericfilerenameprocessstrat...@e7d53
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot 
rename file from: temp/incoming/file.txt to: temp/incoming/file.txt
        at 
org.apache.camel.component.file.remote.SftpOperations.renameFile(SftpOperations.java:167)
        at 
org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.renameFile(GenericFileRenameProcessStrategy.java:80)
        at 
org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.commit(GenericFileRenameProcessStrategy.java:58)
        at 
org.apache.camel.component.file.GenericFileConsumer.processStrategyCommit(GenericFileConsumer.java:226)
        at 
org.apache.camel.component.file.GenericFileConsumer$1.done(GenericFileConsumer.java:180)
        at 
org.apache.camel.processor.UnitOfWorkProcessor$1.done(UnitOfWorkProcessor.java:57)
        at 
org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:96)

{code}

> SftpConsumer : GenericFileRenameProcessStrategy - String index out of bounds
> ----------------------------------------------------------------------------
>
>                 Key: CAMEL-1428
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1428
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-ftp
>    Affects Versions: 2.0.0
>         Environment: Windows XP
>            Reporter: Paddy Daly
>            Assignee: Claus Ibsen
>             Fix For: 2.0-M1
>
>         Attachments: camel-error.txt, camel-error2.txt, camel-error3.txt, 
> camel-error4.txt
>
>
> While trying to consume a file via SFTP and using the moveExpression to move 
> the file into a done folder a renameException is thrown.
> In GenericFile the relativeFileName reads something like the following.   
> /incoming/test/file1.txt
> When it tries to call this code and exception is thrown because 
> File.separator is '\' in a windows environment.
> String relative = relativeFileName.substring(0, 
> relativeFileName.lastIndexOf(File.separator));

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to