124579: If no ORIGINAL bundle exists, end the process gracefully instead of throwing NPE

(cherry picked from commit 046c1b5d05)
This commit is contained in:
Jens Vannerum
2025-01-22 13:33:58 +01:00
committed by github-actions[bot]
parent 6bf4d142a4
commit 6b4c7a773d

View File

@@ -19,6 +19,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.collections4.ListUtils;
import org.dspace.authorize.AuthorizeException;
import org.dspace.content.Bitstream;
import org.dspace.content.Bundle;
@@ -99,7 +100,12 @@ public class ClamScan extends AbstractCurationTask {
}
try {
Bundle bundle = itemService.getBundles(item, "ORIGINAL").get(0);
List<Bundle> bundles = itemService.getBundles(item, "ORIGINAL");
if (ListUtils.emptyIfNull(bundles).isEmpty()) {
setResult("No ORIGINAL bundle found for item: " + getItemHandle(item));
return Curator.CURATE_SKIP;
}
Bundle bundle = bundles.get(0);
results = new ArrayList<String>();
for (Bitstream bitstream : bundle.getBitstreams()) {
InputStream inputstream = bitstreamService.retrieve(Curator.curationContext(), bitstream);