diff --git a/src/main/java/io/github/ilri/cgspace/scripts/FixJpgJpgThumbnails.java b/src/main/java/io/github/ilri/cgspace/scripts/FixJpgJpgThumbnails.java index 21eee83..03591b7 100644 --- a/src/main/java/io/github/ilri/cgspace/scripts/FixJpgJpgThumbnails.java +++ b/src/main/java/io/github/ilri/cgspace/scripts/FixJpgJpgThumbnails.java @@ -103,6 +103,12 @@ public class FixJpgJpgThumbnails { List thumbnailBundleBitstreams = thumbnailBundle.getBitstreams(); for (Bitstream thumbnailBitstream : thumbnailBundleBitstreams) { String thumbnailName = thumbnailBitstream.getName(); + String thumbnailDescription = thumbnailBitstream.getDescription(); + + // There is no point continuing if the thumbnail's description is empty or null + if (StringUtils.isEmpty(thumbnailDescription)) { + continue; + } if (thumbnailName.toLowerCase().contains(".jpg.jpg")) { List originalBundles = item.getBundles("ORIGINAL"); @@ -123,7 +129,7 @@ public class FixJpgJpgThumbnails { */ if ( originalName.equalsIgnoreCase(StringUtils.removeEndIgnoreCase(thumbnailName, ".jpg")) - && ("Generated Thumbnail".equals(thumbnailBitstream.getDescription()) || "IM Thumbnail".equals(thumbnailBitstream.getDescription())) + && ("Generated Thumbnail".equals(thumbnailDescription) || "IM Thumbnail".equals(thumbnailDescription)) && originalBitstreamBytes < 100000 ) { System.out.println(item.getHandle() + ": replacing " + thumbnailName + " with " + originalName);