You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Sergey Zhemzhitsky (JIRA)" <ji...@apache.org> on 2011/08/23 08:17:29 UTC

[jira] [Created] (CAMEL-4370) It's hardly possible to use all expression of the Simple language to create file names in the file component

It's hardly possible to use all expression of the Simple language to create file names in the file component
------------------------------------------------------------------------------------------------------------

                 Key: CAMEL-4370
                 URL: https://issues.apache.org/jira/browse/CAMEL-4370
             Project: Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 2.7.1
            Reporter: Sergey Zhemzhitsky


Sometimes it can be necessary to use custom headers to create a file name.

For example, I declare my file endpoint in the following manner:

{code}
<route id="fileReader">
    <from uri="file://rootFolder?move=.backup&amp;moveFailed=.error/${header.CustomHeader}" />
    <to uri="file://out"/>
</route>
{code}

The header "CustomHeader" cannot be read because of the following snippets of code in the org.apache.camel.component.file.GenericFile

{code}
/**
 * Bind this GenericFile to an Exchange
 */
public void bindToExchange(Exchange exchange) {
    exchange.setProperty(FileComponent.FILE_EXCHANGE_FILE, this);
    GenericFileMessage<T> in = new GenericFileMessage<T>(this);
    exchange.setIn(in);
    populateHeaders(in);
}

/**
 * Populates the {@link GenericFileMessage} relevant headers
 *
 * @param message the message to populate with headers
 */
public void populateHeaders(GenericFileMessage<T> message) {
    if (message != null) {
        message.setHeader(Exchange.FILE_NAME_ONLY, getFileNameOnly());
        message.setHeader(Exchange.FILE_NAME, getFileName());
        message.setHeader("CamelFileAbsolute", isAbsolute());
        message.setHeader("CamelFileAbsolutePath", getAbsoluteFilePath());

        if (isAbsolute()) {
            message.setHeader(Exchange.FILE_PATH, getAbsoluteFilePath());
        } else {
            // we must normalize path according to protocol if we build our own paths
            String path = normalizePathToProtocol(getEndpointPath() + File.separator + getRelativeFilePath());
            message.setHeader(Exchange.FILE_PATH, path);
        }

        message.setHeader("CamelFileRelativePath", getRelativeFilePath());
        message.setHeader(Exchange.FILE_PARENT, getParent());

        if (getFileLength() >= 0) {
            message.setHeader("CamelFileLength", getFileLength());
        }
        if (getLastModified() > 0) {
            message.setHeader(Exchange.FILE_LAST_MODIFIED, new Date(getLastModified()));
        }
    }
}
{code}

As you can see a new "in" message is created and not all the headers from the original message are copied to it.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (CAMEL-4370) It's hardly possible to use all expression of the Simple language to create file names in the file component

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

Claus Ibsen reassigned CAMEL-4370:
----------------------------------

    Assignee: Claus Ibsen

> It's hardly possible to use all expression of the Simple language to create file names in the file component
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-4370
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4370
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.7.1
>            Reporter: Sergey Zhemzhitsky
>            Assignee: Claus Ibsen
>              Labels: camel-file
>
> Sometimes it can be necessary to use custom headers to create a file name.
> For example, I declare my file endpoint in the following manner:
> {code}
> <route id="fileReader">
>     <from uri="file://rootFolder?move=.backup&amp;moveFailed=.error/${header.CustomHeader}" />
>     <to uri="file://out"/>
> </route>
> {code}
> The header "CustomHeader" cannot be read because of the following snippets of code in the org.apache.camel.component.file.GenericFile
> {code}
> /**
>  * Bind this GenericFile to an Exchange
>  */
> public void bindToExchange(Exchange exchange) {
>     exchange.setProperty(FileComponent.FILE_EXCHANGE_FILE, this);
>     GenericFileMessage<T> in = new GenericFileMessage<T>(this);
>     exchange.setIn(in);
>     populateHeaders(in);
> }
> /**
>  * Populates the {@link GenericFileMessage} relevant headers
>  *
>  * @param message the message to populate with headers
>  */
> public void populateHeaders(GenericFileMessage<T> message) {
>     if (message != null) {
>         message.setHeader(Exchange.FILE_NAME_ONLY, getFileNameOnly());
>         message.setHeader(Exchange.FILE_NAME, getFileName());
>         message.setHeader("CamelFileAbsolute", isAbsolute());
>         message.setHeader("CamelFileAbsolutePath", getAbsoluteFilePath());
>         if (isAbsolute()) {
>             message.setHeader(Exchange.FILE_PATH, getAbsoluteFilePath());
>         } else {
>             // we must normalize path according to protocol if we build our own paths
>             String path = normalizePathToProtocol(getEndpointPath() + File.separator + getRelativeFilePath());
>             message.setHeader(Exchange.FILE_PATH, path);
>         }
>         message.setHeader("CamelFileRelativePath", getRelativeFilePath());
>         message.setHeader(Exchange.FILE_PARENT, getParent());
>         if (getFileLength() >= 0) {
>             message.setHeader("CamelFileLength", getFileLength());
>         }
>         if (getLastModified() > 0) {
>             message.setHeader(Exchange.FILE_LAST_MODIFIED, new Date(getLastModified()));
>         }
>     }
> }
> {code}
> As you can see a new "in" message is created and not all the headers from the original message are copied to it.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (CAMEL-4370) It's hardly possible to use all expression of the Simple language to create file names in the file component

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

Claus Ibsen resolved CAMEL-4370.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 2.9.0
                   2.8.1

Thanks for reporting.

> It's hardly possible to use all expression of the Simple language to create file names in the file component
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-4370
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4370
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.7.1
>            Reporter: Sergey Zhemzhitsky
>            Assignee: Claus Ibsen
>              Labels: camel-file
>             Fix For: 2.8.1, 2.9.0
>
>
> Sometimes it can be necessary to use custom headers to create a file name.
> For example, I declare my file endpoint in the following manner:
> {code}
> <route id="fileReader">
>     <from uri="file://rootFolder?move=.backup&amp;moveFailed=.error/${header.CustomHeader}" />
>     <to uri="file://out"/>
> </route>
> {code}
> The header "CustomHeader" cannot be read because of the following snippets of code in the org.apache.camel.component.file.GenericFile
> {code}
> /**
>  * Bind this GenericFile to an Exchange
>  */
> public void bindToExchange(Exchange exchange) {
>     exchange.setProperty(FileComponent.FILE_EXCHANGE_FILE, this);
>     GenericFileMessage<T> in = new GenericFileMessage<T>(this);
>     exchange.setIn(in);
>     populateHeaders(in);
> }
> /**
>  * Populates the {@link GenericFileMessage} relevant headers
>  *
>  * @param message the message to populate with headers
>  */
> public void populateHeaders(GenericFileMessage<T> message) {
>     if (message != null) {
>         message.setHeader(Exchange.FILE_NAME_ONLY, getFileNameOnly());
>         message.setHeader(Exchange.FILE_NAME, getFileName());
>         message.setHeader("CamelFileAbsolute", isAbsolute());
>         message.setHeader("CamelFileAbsolutePath", getAbsoluteFilePath());
>         if (isAbsolute()) {
>             message.setHeader(Exchange.FILE_PATH, getAbsoluteFilePath());
>         } else {
>             // we must normalize path according to protocol if we build our own paths
>             String path = normalizePathToProtocol(getEndpointPath() + File.separator + getRelativeFilePath());
>             message.setHeader(Exchange.FILE_PATH, path);
>         }
>         message.setHeader("CamelFileRelativePath", getRelativeFilePath());
>         message.setHeader(Exchange.FILE_PARENT, getParent());
>         if (getFileLength() >= 0) {
>             message.setHeader("CamelFileLength", getFileLength());
>         }
>         if (getLastModified() > 0) {
>             message.setHeader(Exchange.FILE_LAST_MODIFIED, new Date(getLastModified()));
>         }
>     }
> }
> {code}
> As you can see a new "in" message is created and not all the headers from the original message are copied to it.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira