Migration guide from smooks 1.7 to smooks version 2

330 views
Skip to first unread message

Stefan Dietl

unread,
Jun 19, 2023, 6:27:40 AM6/19/23
to Smooks Users
Hello all,

I am trying to migrate smooks due to many vulnerability issues from 1.7 to 2. Is there any migration guide I can use?

It's not clear e..g what to replace D96AInterchangeFactory and UNEdifactInterchange41 with. In version 2 there is only a class org.smooks.edifact.binding.d96a Interchange. But where to specify the version?

Same for class UNEdifactMessage41. There was a method getMessage(). But in org.smooks.edifact.binding.d96a Message there is none. So no need to do validations like this anymore?

if (unEdifactMessage.getMessage() instanceof ORDRSP ordrsp) {...}
if (unEdifactInterchange instanceof UNEdifactInterchange41 interchange41) {...}

Best regards


Stefan Dietl

unread,
Jun 19, 2023, 2:08:01 PM6/19/23
to Smooks Users
One additional question:
In 1.7 it was unEdifactMessage.getMessage() and now it is message.getContent. Before it was an object and now it is a list of objects. Can someone please explain why the structure changed and how to cope with it.

Claude Mamo

unread,
Jun 25, 2023, 5:26:43 AM6/25/23
to smook...@googlegroups.com
Hello Stefan,

I am trying to migrate smooks due to many vulnerability issues from 1.7 to 2. Is there any migration guide I can use?

You can find it here but we need to add a migration note for EDIFACT Java bindings. The best guide for migrating Smooks from v1.7 to v2 are the online examples. To get started, compare the v1.7 examples with the v2.0.0-RC2 examples. There's also an example for turning EDIFACT POJOs into XML.

It's not clear e..g what to replace D96AInterchangeFactory and UNEdifactInterchange41 with. In version 2 there is only a class org.smooks.edifact.binding.d96a Interchange. But where to specify the version?

The syntax version doesn't need to be specified anymore since it's read from the interchange header. Note that currently only versions 3 and 4 are supported.

Same for class UNEdifactMessage41. There was a method getMessage(). But in org.smooks.edifact.binding.d96a Message there is none. So no need to do validations like this anymore?

The counterpart of getMessage() in v2 is org.smooks.edifact.binding.[release].Message.getContent(). Your example would look like this in v2 assuming the interchange has only a single message that is not within a functional group:

       for (Object c : interchange.getMessage().get(0).getContent()) {
            if (((JAXBElement) c).getDeclaredType().equals(ORDRSP.class)) {
                ...
            }
        }

In 1.7 it was unEdifactMessage.getMessage() and now it is message.getContent. Before it was an object and now it is a list of objects. Can someone please explain why the structure changed and how to cope with it.

The structure has changed because the underlying technologies for modelling EDIFACT and generating the Java bindings have completely been overhauled. We're now using DFDL to model EDIFACT directories and JAXB to generate Java POJO classes. The motivation behind this standards-based approach is to strenghten EDIFACT support and reduce the amount of code we need to maintain. getContent() returns a list of objects because among the objects you'll have are the message header (i.e., UNH), the message body (i.e., ORDRSP), and the message trailer (i.e., UNT).

Claude


Adresse: Conrad Electronic SE, Klaus-Conrad-Str. 1, 92240 Hirschau


Geschäftsführende Direktoren: Ralf Bühler (Vorsitzender), Jürgen Groth, Dr. Sebastian Dehnen

Handelsregister: Amtsgericht Amberg HRB 3896


Diese E-Mail kann (streng) vertrauliche und damit rechtlich geschützte Informationen enthalten. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

--
You received this message because you are subscribed to the Google Groups "Smooks Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smooks-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/smooks-user/f81745fb-6a57-4195-b6ba-fe2e04fd55b8n%40googlegroups.com.

Stefan Dietl

unread,
Jun 27, 2023, 2:03:34 PM6/27/23
to Smooks Users
Thanks for the detailed response Claude,

I still have one question about the new smooks version. Before I parsed edifact files into java objects like this

var normalizedMessageContent = StreamUtils.normalizeLines(messageContent, true);
var d96AInterchangeFactory = D96AInterchangeFactory.getInstance();
UNEdifactInterchange interchange = d96AInterchangeFactory.fromUNEdifact(IOUtils.toInputStream(normalizedMessageContent, StandardCharsets.UTF_8));

Now I try it like that since no factory exists anymore I guess

var normalizedMessageContent = StreamUtils.normalizeLines(messageContent, true);
var javaResult = new JavaResult();
var streamSource = new StreamSource(IOUtils.toInputStream(normalizedMessageContent, StandardCharsets.UTF_8));
smooks.filterSource(streamSource, javaResult);
Interchange interchange =  javaResult.getBean(Interchange.class);

But the variable "interchange" is always null. What am I missing here?

Thanks for any help,
Stefan

Stefan Dietl

unread,
Jun 27, 2023, 2:32:52 PM6/27/23
to Smooks Users
Maybe one additional info: The javaResult contains:

PTIME:
<null/>

PUUID:
<null/>

I am using java 11 and smooks version 2.0.0-RC2

Stefan Dietl

unread,
Jun 29, 2023, 8:36:41 AM6/29/23
to Smooks Users
I recognized one difference between old version and new one. Before I had three dependencies and now only two. Does the mappings dependency not exist anymore? Can this cause my problem when parsing edifact to Interchange object?

old:
org.milyn:milyn-smooks-edi:1.7.1.Final
org.milyn.edi.unedifact:d96a-mapping:1.7.1.0
org.milyn.edi.unedifact:d96a-binding:1.7.1.0

new:
org.smooks.cartridges.edi:smooks-edifact-cartridge:2.0.0-RC2
org.smooks.cartridges.edi:d96a-edifact-binding:2.0.0-RC2

Claude Mamo

unread,
Jul 4, 2023, 4:10:48 AM7/4/23
to smook...@googlegroups.com
Now I try it like that since no factory exists anymore I guess

Indeed. The factory was removed in favour of JAXB.

But the variable "interchange" is always null. What am I missing here?

I can't really say because I don't have your Smooks config. I've realised that we don't have this use case documented so I've added a code example that demonstrates how to bind an EDIFACT doc to a POJO.

I recognized one difference between old version and new one. Before I had three dependencies and now only two. Does the mappings dependency not exist anymore? Can this cause my problem when parsing edifact to Interchange object?

The counterpart of org.milyn.edi.unedifact:d96a-mapping:1.7.1.0 in v2 is org.smooks.cartridges.edi:edifact-schemas:d96a:2.0.0-RC2

Claude

Stefan Dietl

unread,
Jul 17, 2023, 4:38:09 AM7/17/23
to Smooks Users
Thanks for the support Claude. The new code example helped to fix the problems. It's working as expected now.
Reply all
Reply to author
Forward
0 new messages