[
https://issues.apache.org/jira/browse/CAMEL-27112?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on CAMEL-27112 started by Claus Ibsen.
-------------------------------------------
> FileIdempotentRepository and FileStateRepository: accept the file name as a
> plain String, for YAML and low-code beans
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27112
> URL: https://issues.apache.org/jira/browse/CAMEL-27112
> Project: Camel
> Issue Type: Improvement
> Components: camel-core
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 4.24.0
>
>
> FileIdempotentRepository and FileStateRepository keep their data in a file,
> but they take that file only as a java.io.File (setFileStore(File), and the
> static factory methods). When the repository is declared as a bean in YAML,
> in properties or in a low-code tool, the user has a file name, and wants to
> give it as a plain string. That does not work today.
> *Reproducer* (Camel JBang 4.24.0-SNAPSHOT):
> {code:yaml}
> - beans:
> - name: readFiles
> type:
> "#class:org.apache.camel.support.processor.idempotent.FileIdempotentRepository"
> properties:
> fileStore: "/var/data/read-files.dat"
> - route:
> from:
> uri:
> "file:/var/data/in?noop=true&idempotent=true&idempotentRepository=#bean:readFiles"
> steps:
> - log: "${header.CamelFileName}"
> {code}
> fails with:
> {noformat}
> Error binding property (fileStore=/var/data/read-files.dat) ...
> NoTypeConversionAvailableException: No type converter available to convert
> from type: java.lang.String to the required type: java.io.File
> {noformat}
> The same happens with camel.beans.readFiles.fileStore =
> /var/data/read-files.dat.
> Today the only working form is fileStore:
> "#class:java.io.File('/var/data/read-files.dat')". With it, the files are not
> read again after a restart, and a new file is. That form asks the user to
> know the java.io.File API, which people do not expect when they only want to
> name a file.
> *Suggestion:* let both repositories take the file name as a plain String:
> * a String setter (for example an overloaded setFileStore(String), or
> setFileName(String));
> * String variants of the static factory methods, such as
> fileIdempotentRepository(String fileName).
> A general String to File type converter is not wanted. It would also apply to
> message bodies, where a String is the content of a file, not its name, and
> people would confuse the two.
> *Use case:* the FTP, FTPS and SFTP source Kamelets of camel-kamelets read
> every file again after a restart, unless the files are moved or deleted
> (apache/camel-kamelets#3170, #3178). With this change, a user could declare
> the repository in YAML with a plain file name, and pass the bean name to the
> Kamelet.
> _Claude Code on behalf of Claus Ibsen_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)