davsclaus opened a new pull request, #28298:
URL: https://github.com/apache/camel/pull/28298
Stacked on #28291. This group of the catalog body types (CAMEL-24961) takes
the data formats for text and structured messages: 32 of the 56 data formats.
The binary ones (avro, protobuf, the archives, crypto...) come next.
**What the catalog says now**
| Data format | Unmarshal gives | Marshal takes |
|---|---|---|
| bindyCsv, bindyFixed, bindyKvp | an object of the `classType` class for
one record, a List of them for more (always a List with
unwrapSingleInstance=false) | an object of the `classType` class, or a List of
them |
| univocityCsv, univocityFixed, univocityTsv | a List of the rows, each a
List of values, or a Map with asMap; an iterator with lazyLoad | a Map, or a
List of Maps |
| beanio | a List of the beans of the mapping (the one bean with
unmarshalSingleObject) | a bean, or a List of them |
| flatpack | a DataSetList: a List of Maps | a List of Maps |
| gson, jsonb, fastjson | a Map for a JSON object, a List for an array |
`any`, as jackson |
| groovyJson | a Map (LazyMap) or a List | a Map, a Node or a JsonNode; text
as it is |
| groovyXml | a groovy.util.Node | a Node, a GPathResult or a Map; text as
it is |
| jsonApi | the resource object, or no body when the data is null | one
resource object |
| toon | a Map or a List | a Map, a List, a POJO, a value, or JSON text |
| ocsf | an OcsfEvent, or a List with useList | a Map, a List or a POJO |
| base64 | the decoded bytes, as a stream | text, bytes, a stream or a file |
| jaxb | the JAXB object | a JAXB object; text, bytes, a stream or a file as
it is |
| soap | the JAXB object of the SOAP body, or no body for an empty body or a
fault | a JAXB object |
| ubl | the ph-ubl document, such as an InvoiceType | the ph-ubl document |
| fhirJson, fhirXml | the HAPI FHIR resource (IBaseResource) | a HAPI FHIR
resource |
| hl7 | a HAPI Message, or a DOM Document with targetFormat=XML | a Message,
or HL7 as text or bytes |
| swiftMt, swiftMx | the Prowide MT or MX class, or no body for an unknown
type | the Prowide object |
| ical | an ical4j Calendar | a Calendar |
| rss | a ROME SyndFeed | a SyndFeed, or the XML text of a feed |
| syslog | a SyslogMessage | a SyslogMessage, or the text of a message |
| grok | a Map for one match, a List for several, no body for none |
(marshal is not supported) |
| iso8583 | a j8583 IsoMessage | an IsoMessage |
| asn1 | the records in one byte array, or an iterator with usingIterator |
BER bytes, a stream or a file |
| dfdl | the XML infoset as a DOM Document | the XML infoset, as text or a
DOM |
After marshal, the body is the stream cache (a byte array when stream
caching is off), as for the data formats that have body types already.
**The validator** reads the body after unmarshal. gson, jsonb, fastjson,
groovyJson, toon, univocity, beanio and flatpack give parsed data, so the steps
after them are checked as after jackson: for example, a file producer after
`unmarshal: {json: {library: Gson}}` is reported.
`TextBodyFlowTest.testTheOptionsTheBodyDependsOn` used gson as a data format
without body types; it now uses gson with an unmarshalType, which makes the
body unknown.
**Checked at runtime.** About 190 cases run with `camel run` logged the
class of the body after each unmarshal and marshal. Among them:
- **bindy:** one record gives the object and two give a List.
- **univocity:** the default gives Lists of Strings, with the header line as
a row.
- **gson:** numbers come back as Double.
- **toon:** a String body is read as JSON.
- **jaxb:** XML text is written as it is.
- **hl7:** text and bytes are parsed; a stream or a file fails.
- **SWIFT:** the Prowide objects only; text fails with a ClassCastException.
- **grok:** gives a Map, a List or no body.
**Bugs found:**
- CAMEL-25995 (Major): base64 unmarshal of a file fails with "Stream
closed", since 4.9.0.
- CAMEL-25996: univocity asMap fails for one data row without a final
newline.
- CAMEL-25997: bindy marshal writes empty lines for a Map of values or a
String.
- CAMEL-25998: groovyJson and groovyXml cannot marshal a List.
- CAMEL-25999: toon writes bytes as numbers, a stream as nothing and a file
as its path.
- CAMEL-26000 (improvement): jsonApi has no collection documents.
- CAMEL-26001: ical marshal of text gives a NullPointerException.
- CAMEL-26002: iso8583 errors for a missing ISO-Type and a configFile
outside the classpath.
- CAMEL-26003: flatpack marshal of a single Map, and its name "flatback".
**Docs fixed:**
- **bindy:** the unmarshal section said the body is a List of Maps of class
names, which has not been the case since 2011: it is the `classType` objects.
Its examples would throw a ClassCastException.
- **jaxb:** `mustBeJAXBElement` is false by default, so XML text is written
as it is.
- **gson, jsonb, fastjson, jackson2, jackson3:** "all the JSON data formats
do the same" now names the four that do, and a file is one from a consumer.
- **base64:** unmarshal gives a stream, not a byte[].
- **rss:** marshal gives XML, not a String.
- **grok:** the body is a Map for one match, and the examples'
`%{COMBINEDAPACHELOG` lacked its `}`.
- **asn1:** unmarshal gives a byte array, not an OutputStream.
- **dfdl:** the marshal section said unmarshal.
- **swiftMt, swiftMx:** marshal needs the Prowide object.
**Measured.**
- The validator over the 1204 human-written and 1209 model-written route
files gives the same reports as with #28291.
- In the human-written routes, the marshal and unmarshal steps whose data
format has body types go from 86.8% to 95.9% of 295; protobuf, avro and crypto
are left. The share of endpoint uses is unchanged, as data formats are not
endpoints.
**Tests**
- `TextBodyFlowTest.testTheBodyOfTextDataFormats`: gson and univocityCsv
give parsed data that the file producer cannot write, while univocityCsv with
lazyLoad and jaxb say nothing.
- These pass:
- the 287 tests of camel-yaml-dsl-validator;
- the 265 validator and catalog doc tests of camel-jbang-core;
- the builds of camel-yaml-dsl-maven-plugin and
camel-yaml-dsl-deserializers.
- The answers of camel_catalog_doc stay under 18 000 characters: jaxb, the
largest of this group, is 7 629.
_Claude Code on behalf of davsclaus_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]