From f0754ab4193dc3809bb0210de2c38188814b563a Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Wed, 5 Oct 2022 21:00:14 +0300 Subject: [PATCH] src: fix npe on null description In FixLowQualityThumbnails we need to make sure that bitstream de- scriptions are not null or empty before trying to evaluate them. --- .../cgspace/scripts/FixLowQualityThumbnails.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/io/github/ilri/cgspace/scripts/FixLowQualityThumbnails.java b/src/main/java/io/github/ilri/cgspace/scripts/FixLowQualityThumbnails.java index f93a93a..3d38929 100644 --- a/src/main/java/io/github/ilri/cgspace/scripts/FixLowQualityThumbnails.java +++ b/src/main/java/io/github/ilri/cgspace/scripts/FixLowQualityThumbnails.java @@ -124,6 +124,10 @@ public class FixLowQualityThumbnails { for (Bitstream thumbnailBitstream : thumbnailBundleBitstreams) { String thumbnailDescription = thumbnailBitstream.getDescription(); + if (StringUtils.isEmpty(thumbnailDescription)) { + continue; + } + // Check if this item has a bitstream in the THUMBNAIL bundle with description "IM // Thumbnail", but only if we haven't already seen one in another iteration for this // bundle. @@ -140,6 +144,10 @@ public class FixLowQualityThumbnails { String thumbnailName = thumbnailBitstream.getName(); String thumbnailDescription = thumbnailBitstream.getDescription(); + if (StringUtils.isEmpty(thumbnailDescription)) { + continue; + } + // If this item has a "Generated Thumbnail" we can remove it, because those // typically come from other JPEGs in the ORIGINAL bundle and we would prefer // the IM Thumbnail generated from a PDF anyway. The DSpace-generated descri- @@ -225,6 +233,10 @@ public class FixLowQualityThumbnails { String originalDescription = originalBitstream.getDescription(); String originalFormat = originalBitstream.getFormat(context).getMIMEType(); + if (StringUtils.isEmpty(originalDescription)) { + continue; + } + /* - check if the bitstream is a JPEG based on its MIME Type - check if the bitstream's name or description is "Thumbnail"