camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David R. Hoffman (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CAMEL-11437) Bug using file endpoint probeContentType and preMove attributes together causes Exchange.FILE_CONTENT_TYPE to get dropped. (2.19.0)
Date Fri, 23 Jun 2017 04:57:00 GMT

     [ https://issues.apache.org/jira/browse/CAMEL-11437?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

David R. Hoffman updated CAMEL-11437:
-------------------------------------
    Description: 
We have a route:

{quote}
from("file:inbox?probeContentType=true&preMove=inprogress/${file:name}&renameUsingCopy=true")
        .transacted()
        .bean(MimeTypeParser.class, "populateFileTypeHeaderFields")
        .to("seda:somewhere")
{quote} 
     
The probeContentType executes before preMove & renameUsingCopy and correctly sets the
Exchange.FILE_CONTENT_TYPE header.

The problem happens during the preMove & renameUsingCopy part where GenericFileExpressionRenamer
calls the GenericFile method GenericFile<T> copyFrom(GenericFile<T> source).

This "copy constructor" method does not copy the header Exchange.FILE_CONTENT_TYPE, nor does
it preserve the value of the GenericFile probeContentType field.

The class GenericFileRenameProcessStrategy calls GenericFileExpressionRenamer from the method
begin() which in turn calls GenericFile.bindToExchange(Exchange exchange).

GenericFile.bindToExchange() clears all "CamelFile*" headers and then calls GenericFile.populateHeaders(GenericFileMessage<T>
message) which would call Files.probeContentType(Path path) if the GenericFile probeContentType
field weren't now false.

When our route gets to the MimeTypeParser bean the "CamelFileContentType" header is lost,
and that is what we are looking for.

One work-around is to put something like this between .transacted() and the .bean():
{quote}{{
.process(exchange ->  {
     Path path = exchange.getIn().getBody(File.class).toPath();
     exchange.getIn().setHeader(Exchange.FILE_CONTENT_TYPE, Files.probeContentType(path));
})
}}{quote}

  was:
We have a route:

{quote}
from("file:inbox?probeContentType=true&preMove=inprogress/${file:name}&renameUsingCopy=true")
        .transacted()
        .bean(MimeTypeParser.class, "populateFileTypeHeaderFields")
        .to("seda:somewhere")
{quote} 
     
The probeContentType executes before preMove & renameUsingCopy and correctly sets the
Exchange.FILE_CONTENT_TYPE header.

The problem happens during the preMove & renameUsingCopy part where GenericFileExpressionRenamer
calls the GenericFile method GenericFile<T> copyFrom(GenericFile<T> source).

This "copy constructor" method does not copy the header Exchange.FILE_CONTENT_TYPE, nor does
it preserve the value of the GenericFile probeContentType field.

The class GenericFileRenameProcessStrategy calls GenericFileExpressionRenamer from the method
begin() which in turn calls GenericFile.bindToExchange(Exchange exchange).

GenericFile.bindToExchange() clears all "CamelFile*" headers and then calls GenericFile.populateHeaders(GenericFileMessage<T>
message) which would call Files.probeContentType(Path path) if the GenericFile probeContentType
field weren't now false.

When our route gets to the MimeTypeParser bean the "CamelFileContentType" header is lost,
and that is what we are looking for.

One work-around is to put something like this between .transacted() and the .bean():
{quote}
.process(exchange ->  {
     Path path = exchange.getIn().getBody(File.class).toPath();
     exchange.getIn().setHeader(Exchange.FILE_CONTENT_TYPE, Files.probeContentType(path));
})
{quote}


> Bug using file endpoint probeContentType and preMove attributes together causes Exchange.FILE_CONTENT_TYPE
to get dropped. (2.19.0) 
> ------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-11437
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11437
>             Project: Camel
>          Issue Type: Bug
>    Affects Versions: 2.19.0
>         Environment: {quote}quoted text{quote}
>            Reporter: David R. Hoffman
>
> We have a route:
> {quote}
> from("file:inbox?probeContentType=true&preMove=inprogress/${file:name}&renameUsingCopy=true")
>         .transacted()
>         .bean(MimeTypeParser.class, "populateFileTypeHeaderFields")
>         .to("seda:somewhere")
> {quote} 
>      
> The probeContentType executes before preMove & renameUsingCopy and correctly sets
the Exchange.FILE_CONTENT_TYPE header.
> The problem happens during the preMove & renameUsingCopy part where GenericFileExpressionRenamer
calls the GenericFile method GenericFile<T> copyFrom(GenericFile<T> source).
> This "copy constructor" method does not copy the header Exchange.FILE_CONTENT_TYPE, nor
does it preserve the value of the GenericFile probeContentType field.
> The class GenericFileRenameProcessStrategy calls GenericFileExpressionRenamer from the
method begin() which in turn calls GenericFile.bindToExchange(Exchange exchange).
> GenericFile.bindToExchange() clears all "CamelFile*" headers and then calls GenericFile.populateHeaders(GenericFileMessage<T>
message) which would call Files.probeContentType(Path path) if the GenericFile probeContentType
field weren't now false.
> When our route gets to the MimeTypeParser bean the "CamelFileContentType" header is lost,
and that is what we are looking for.
> One work-around is to put something like this between .transacted() and the .bean():
> {quote}{{
> .process(exchange ->  {
>      Path path = exchange.getIn().getBody(File.class).toPath();
>      exchange.getIn().setHeader(Exchange.FILE_CONTENT_TYPE, Files.probeContentType(path));
> })
> }}{quote}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message