From c3ab2a1dfa5f2cd9747b09041be2a99bbffc0ea9 Mon Sep 17 00:00:00 2001 From: frabacche Date: Mon, 4 Mar 2024 11:47:54 +0100 Subject: [PATCH] check item linked to ldnMessage before storing a new solr document --- .../indexobject/LDNMessageEntityIndexFactoryImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dspace-api/src/main/java/org/dspace/discovery/indexobject/LDNMessageEntityIndexFactoryImpl.java b/dspace-api/src/main/java/org/dspace/discovery/indexobject/LDNMessageEntityIndexFactoryImpl.java index 7edb9438ada9..60312e1b3bb8 100644 --- a/dspace-api/src/main/java/org/dspace/discovery/indexobject/LDNMessageEntityIndexFactoryImpl.java +++ b/dspace-api/src/main/java/org/dspace/discovery/indexobject/LDNMessageEntityIndexFactoryImpl.java @@ -89,6 +89,9 @@ public SolrInputDocument buildDocument(Context context, IndexableLDNNotification doc.addField("queue_status_s", LDNMessageEntity.getQueueStatus(ldnMessage)); addFacetIndex(doc, "queue_status", String.valueOf(ldnMessage.getQueueStatus()), LDNMessageEntity.getQueueStatus(ldnMessage)); + if (ldnMessage.getObject() == null || ldnMessage.getObject().getID() == null) { + throw new SQLException("ldnMessage " + ldnMessage.getID() + " is linked to no Item."); + } Item item = itemService.findByIdOrLegacyId(context, ldnMessage.getObject().getID().toString()); if (item != null) { addFacetIndex(doc, "object", item.getID().toString(), itemService.getMetadata(item, "dc.title"));