From 01fea93b9f43773ccd92ea66a6872b013f96b920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Gon=C3=A7alves?= Date: Thu, 14 Nov 2024 16:50:02 +0000 Subject: [PATCH 1/2] if newExchange is null, it means there's no remote file to consume --- .../org/assimbly/enrich/zipfile/ZipFileEnrichStrategy.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/enrich/src/main/java/org/assimbly/enrich/zipfile/ZipFileEnrichStrategy.java b/enrich/src/main/java/org/assimbly/enrich/zipfile/ZipFileEnrichStrategy.java index 8165c7f0..1ad564b3 100644 --- a/enrich/src/main/java/org/assimbly/enrich/zipfile/ZipFileEnrichStrategy.java +++ b/enrich/src/main/java/org/assimbly/enrich/zipfile/ZipFileEnrichStrategy.java @@ -26,6 +26,11 @@ public class ZipFileEnrichStrategy implements AggregationStrategy { public Exchange aggregate(Exchange oldExchange, Exchange newExchange) { element_names = new ArrayList<>(); + if (newExchange == null) { + // there’s no remote file to consume + return oldExchange; + } + Message in = oldExchange.getIn(); Message resource = newExchange.getIn(); From ccd5a19bbc5abe138dd8a228f076611aec7b977d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Gon=C3=A7alves?= Date: Wed, 20 Nov 2024 14:59:15 +0000 Subject: [PATCH 2/2] use FILE_NAME_CONSUMED instead of FILE_NAME. convert resource body using camel type conversion framework --- .../org/assimbly/enrich/zipfile/ZipFileEnrichStrategy.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/enrich/src/main/java/org/assimbly/enrich/zipfile/ZipFileEnrichStrategy.java b/enrich/src/main/java/org/assimbly/enrich/zipfile/ZipFileEnrichStrategy.java index 1ad564b3..5c485bf7 100644 --- a/enrich/src/main/java/org/assimbly/enrich/zipfile/ZipFileEnrichStrategy.java +++ b/enrich/src/main/java/org/assimbly/enrich/zipfile/ZipFileEnrichStrategy.java @@ -35,9 +35,9 @@ public Exchange aggregate(Exchange oldExchange, Exchange newExchange) { Message resource = newExchange.getIn(); byte[] sourceZip = in.getBody(byte[].class); - byte[] resourceData = resource.getBody(byte[].class); + byte[] resourceData = newExchange.getContext().getTypeConverter().convertTo(byte[].class, resource.getBody()); - String fileName = resource.getHeader(Exchange.FILE_NAME, String.class); + String fileName = resource.getHeader(Exchange.FILE_NAME_CONSUMED, String.class); ByteArrayOutputStream baos = new ByteArrayOutputStream();