You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Bruno Borges (JIRA)" <ji...@apache.org> on 2010/09/16 21:18:40 UTC

[jira] Created: (CAMEL-3131) FileOperations should expect body to be convertible to File

FileOperations should expect body to be convertible to File
-----------------------------------------------------------

                 Key: CAMEL-3131
                 URL: https://issues.apache.org/activemq/browse/CAMEL-3131
             Project: Apache Camel
          Issue Type: Improvement
          Components: camel-core
            Reporter: Bruno Borges


The FileOperations class used by FileComponent and others related to file management and processing, should expect that body message is convertible to a File object.

In lines 170, the class tests the body to be either instance of File or GenericFile, but some custom-user messages might have wrapped the File object and written a Converter (our case).

I suggest to modify the referenced code to test if converted result for File.class is not null than compare instanceof.

            // is the body file based
            File source = exchange.getIn().getBody(File.class);
            // if (exchange.getIn().getBody(File.class) instanceof File || exchange.getIn().getBody() instanceof GenericFile) {
            //     source = exchange.getIn().getBody(File.class);
            // }


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


[jira] Commented: (CAMEL-3131) FileOperations should expect body to be convertible to File

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=61887#action_61887 ] 

Claus Ibsen commented on CAMEL-3131:
------------------------------------

Can you post more details about your use-case.
You can always use .convertBodyTo(File.class) yourself before sending the message to the file producer.

And also posting patches with unit tests is a better way to have improvements accepted into the code base.

> FileOperations should expect body to be convertible to File
> -----------------------------------------------------------
>
>                 Key: CAMEL-3131
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3131
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Bruno Borges
>
> The FileOperations class used by FileComponent and others related to file management and processing, should expect that body message is convertible to a File object.
> In lines 170, the class tests the body to be either instance of File or GenericFile, but some custom-user messages might have wrapped the File object and written a Converter (our case).
> I suggest to modify the referenced code to test if converted result for File.class is not null than compare instanceof.
>             // is the body file based
>             File source = exchange.getIn().getBody(File.class);
>             // if (exchange.getIn().getBody(File.class) instanceof File || exchange.getIn().getBody() instanceof GenericFile) {
>             //     source = exchange.getIn().getBody(File.class);
>             // }

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


[jira] Resolved: (CAMEL-3131) FileOperations should expect body to be convertible to File

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3131?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-3131.
--------------------------------

    Fix Version/s: 2.5.0
       Resolution: Fixed

Willem have commtited this

> FileOperations should expect body to be convertible to File
> -----------------------------------------------------------
>
>                 Key: CAMEL-3131
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3131
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Bruno Borges
>            Assignee: Willem Jiang
>             Fix For: 2.5.0
>
>
> The FileOperations class used by FileComponent and others related to file management and processing, should expect that body message is convertible to a File object.
> In lines 170, the class tests the body to be either instance of File or GenericFile, but some custom-user messages might have wrapped the File object and written a Converter (our case).
> I suggest to modify the referenced code to test if converted result for File.class is not null than compare instanceof.
>             // is the body file based
>             File source = exchange.getIn().getBody(File.class);
>             // if (exchange.getIn().getBody(File.class) instanceof File || exchange.getIn().getBody() instanceof GenericFile) {
>             //     source = exchange.getIn().getBody(File.class);
>             // }

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


[jira] Commented: (CAMEL-3131) FileOperations should expect body to be convertible to File

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=61918#action_61918 ] 

Claus Ibsen commented on CAMEL-3131:
------------------------------------

Yes

> FileOperations should expect body to be convertible to File
> -----------------------------------------------------------
>
>                 Key: CAMEL-3131
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3131
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Bruno Borges
>            Assignee: Willem Jiang
>
> The FileOperations class used by FileComponent and others related to file management and processing, should expect that body message is convertible to a File object.
> In lines 170, the class tests the body to be either instance of File or GenericFile, but some custom-user messages might have wrapped the File object and written a Converter (our case).
> I suggest to modify the referenced code to test if converted result for File.class is not null than compare instanceof.
>             // is the body file based
>             File source = exchange.getIn().getBody(File.class);
>             // if (exchange.getIn().getBody(File.class) instanceof File || exchange.getIn().getBody() instanceof GenericFile) {
>             //     source = exchange.getIn().getBody(File.class);
>             // }

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


[jira] Commented: (CAMEL-3131) FileOperations should expect body to be convertible to File

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=61900#action_61900 ] 

Claus Ibsen commented on CAMEL-3131:
------------------------------------

Willem there is also a similar check in camel-jms, in case you route files to JMS queues. So you should make the same changes in there as well.

> FileOperations should expect body to be convertible to File
> -----------------------------------------------------------
>
>                 Key: CAMEL-3131
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3131
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Bruno Borges
>            Assignee: Willem Jiang
>
> The FileOperations class used by FileComponent and others related to file management and processing, should expect that body message is convertible to a File object.
> In lines 170, the class tests the body to be either instance of File or GenericFile, but some custom-user messages might have wrapped the File object and written a Converter (our case).
> I suggest to modify the referenced code to test if converted result for File.class is not null than compare instanceof.
>             // is the body file based
>             File source = exchange.getIn().getBody(File.class);
>             // if (exchange.getIn().getBody(File.class) instanceof File || exchange.getIn().getBody() instanceof GenericFile) {
>             //     source = exchange.getIn().getBody(File.class);
>             // }

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


[jira] Commented: (CAMEL-3131) FileOperations should expect body to be convertible to File

Posted by "Willem Jiang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=61917#action_61917 ] 

Willem Jiang commented on CAMEL-3131:
-------------------------------------

@Claus
I only find the code of camel-jms in the jmsBinding.getJMSMessageTypeForBody() like this,  do you mean that ?
{code}
protected JmsMessageType getJMSMessageTypeForBody(Exchange exchange, Object body, Map<String, Object> headers, Session session, CamelContext context) {
    JmsMessageType type = null;

        // let body determine the type
        if (body instanceof Node || body instanceof String) {
            type = Text;
        } else if (body instanceof byte[] || body instanceof GenericFile || body instanceof File || body instanceof Reader
                || body instanceof InputStream || body instanceof ByteBuffer || body instanceof StreamCache) {
            type = Bytes;
        }
{code}

> FileOperations should expect body to be convertible to File
> -----------------------------------------------------------
>
>                 Key: CAMEL-3131
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3131
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Bruno Borges
>            Assignee: Willem Jiang
>
> The FileOperations class used by FileComponent and others related to file management and processing, should expect that body message is convertible to a File object.
> In lines 170, the class tests the body to be either instance of File or GenericFile, but some custom-user messages might have wrapped the File object and written a Converter (our case).
> I suggest to modify the referenced code to test if converted result for File.class is not null than compare instanceof.
>             // is the body file based
>             File source = exchange.getIn().getBody(File.class);
>             // if (exchange.getIn().getBody(File.class) instanceof File || exchange.getIn().getBody() instanceof GenericFile) {
>             //     source = exchange.getIn().getBody(File.class);
>             // }

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


[jira] Commented: (CAMEL-3131) FileOperations should expect body to be convertible to File

Posted by "Bruno Borges (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=61895#action_61895 ] 

Bruno Borges commented on CAMEL-3131:
-------------------------------------

We develop a Camel component for the Accord Odette FTP library.

It is similar to the FTP component, but we cannot use GenericFileEndpoint or any related class directly, due to the design of OFTP protocol. For example, there's no listing of files or directories.

This component exchanges messages wrapping a VirtualFile that represents a File in the OFTP server. Usually, users will route messages between this component and the File component, to send/receive files.

We think it wouldn't be smart to always require users to .convertBodyTo. It should work like the FTP component on design of routes.

And yes, I'm trying to submit patches with Unit Tests, but still the trunk for some reason is not compiling in here. I'll try checking out a tag version.

> FileOperations should expect body to be convertible to File
> -----------------------------------------------------------
>
>                 Key: CAMEL-3131
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3131
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Bruno Borges
>            Assignee: Willem Jiang
>
> The FileOperations class used by FileComponent and others related to file management and processing, should expect that body message is convertible to a File object.
> In lines 170, the class tests the body to be either instance of File or GenericFile, but some custom-user messages might have wrapped the File object and written a Converter (our case).
> I suggest to modify the referenced code to test if converted result for File.class is not null than compare instanceof.
>             // is the body file based
>             File source = exchange.getIn().getBody(File.class);
>             // if (exchange.getIn().getBody(File.class) instanceof File || exchange.getIn().getBody() instanceof GenericFile) {
>             //     source = exchange.getIn().getBody(File.class);
>             // }

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


[jira] Assigned: (CAMEL-3131) FileOperations should expect body to be convertible to File

Posted by "Willem Jiang (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3131?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Willem Jiang reassigned CAMEL-3131:
-----------------------------------

    Assignee: Willem Jiang

> FileOperations should expect body to be convertible to File
> -----------------------------------------------------------
>
>                 Key: CAMEL-3131
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3131
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Bruno Borges
>            Assignee: Willem Jiang
>
> The FileOperations class used by FileComponent and others related to file management and processing, should expect that body message is convertible to a File object.
> In lines 170, the class tests the body to be either instance of File or GenericFile, but some custom-user messages might have wrapped the File object and written a Converter (our case).
> I suggest to modify the referenced code to test if converted result for File.class is not null than compare instanceof.
>             // is the body file based
>             File source = exchange.getIn().getBody(File.class);
>             // if (exchange.getIn().getBody(File.class) instanceof File || exchange.getIn().getBody() instanceof GenericFile) {
>             //     source = exchange.getIn().getBody(File.class);
>             // }

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