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.
This commit is contained in:
Alan Orth 2022-10-05 21:00:14 +03:00
parent 6772145bec
commit f0754ab419
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9

View File

@ -124,6 +124,10 @@ public class FixLowQualityThumbnails {
for (Bitstream thumbnailBitstream : thumbnailBundleBitstreams) { for (Bitstream thumbnailBitstream : thumbnailBundleBitstreams) {
String thumbnailDescription = thumbnailBitstream.getDescription(); String thumbnailDescription = thumbnailBitstream.getDescription();
if (StringUtils.isEmpty(thumbnailDescription)) {
continue;
}
// Check if this item has a bitstream in the THUMBNAIL bundle with description "IM // 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 // Thumbnail", but only if we haven't already seen one in another iteration for this
// bundle. // bundle.
@ -140,6 +144,10 @@ public class FixLowQualityThumbnails {
String thumbnailName = thumbnailBitstream.getName(); String thumbnailName = thumbnailBitstream.getName();
String thumbnailDescription = thumbnailBitstream.getDescription(); String thumbnailDescription = thumbnailBitstream.getDescription();
if (StringUtils.isEmpty(thumbnailDescription)) {
continue;
}
// If this item has a "Generated Thumbnail" we can remove it, because those // 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 // 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- // the IM Thumbnail generated from a PDF anyway. The DSpace-generated descri-
@ -225,6 +233,10 @@ public class FixLowQualityThumbnails {
String originalDescription = originalBitstream.getDescription(); String originalDescription = originalBitstream.getDescription();
String originalFormat = originalBitstream.getFormat(context).getMIMEType(); 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 is a JPEG based on its MIME Type
- check if the bitstream's name or description is "Thumbnail" - check if the bitstream's name or description is "Thumbnail"