Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.7.1
-
Unknown
Description
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:
<route id="fileReader"> <from uri="file://rootFolder?move=.backup&moveFailed=.error/${header.CustomHeader}" /> <to uri="file://out"/> </route>
The header "CustomHeader" cannot be read because of the following snippets of code in the org.apache.camel.component.file.GenericFile
/** * 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())); } } }
As you can see a new "in" message is created and not all the headers from the original message are copied to it.