From 5fcd9fbe5a9cf0b9c7a91b92390d478b55bbc28d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Lindo?= Date: Wed, 6 Dec 2023 10:05:42 +0000 Subject: [PATCH] Getting reports list from storage (#3025) --- .../base/notifications/EmailIngestNotification.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/roda-core/roda-core/src/main/java/org/roda/core/plugins/base/notifications/EmailIngestNotification.java b/roda-core/roda-core/src/main/java/org/roda/core/plugins/base/notifications/EmailIngestNotification.java index 066a6e5a32..f1ab5714fc 100644 --- a/roda-core/roda-core/src/main/java/org/roda/core/plugins/base/notifications/EmailIngestNotification.java +++ b/roda-core/roda-core/src/main/java/org/roda/core/plugins/base/notifications/EmailIngestNotification.java @@ -23,6 +23,7 @@ import org.roda.core.data.common.RodaConstants; import org.roda.core.data.exceptions.AuthorizationDeniedException; import org.roda.core.data.exceptions.GenericException; +import org.roda.core.data.exceptions.NotFoundException; import org.roda.core.data.exceptions.NotificationException; import org.roda.core.data.exceptions.RequestNotValidException; import org.roda.core.data.v2.index.filter.Filter; @@ -94,13 +95,18 @@ public void notify(ModelService model, IndexService index, Job job, JobStats job StringBuilder builder = new StringBuilder(); for (IndexedReport report : reports) { - Report last = report.getReports().get(report.getReports().size() - 1); - builder.append(last.getPluginDetails()).append("\n\n"); + List reportsList = model.retrieveJobReport(report.getJobId(), report.getId()).getReports(); + if (reportsList != null && !reportsList.isEmpty()) { + Report last = reportsList.get(reportsList.size() - 1); + builder.append(last.getPluginDetails()).append("\n\n"); + } } scopes.put("failures", new Handlebars.SafeString(builder.toString())); } catch (IOException e) { LOGGER.error("Error getting failed reports", e); + } catch (NotFoundException e) { + LOGGER.error("Error getting reports list", e); } }