mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 22:43:12 +00:00
Merge pull request #8955 from amgciadev/fix-8954-b
Prevent NPE during indexing if bitstream is null
This commit is contained in:
@@ -76,14 +76,19 @@ public class FullTextContentStreams extends ContentStreamBase {
|
|||||||
if (StringUtils.equals(FULLTEXT_BUNDLE, myBundle.getName())) {
|
if (StringUtils.equals(FULLTEXT_BUNDLE, myBundle.getName())) {
|
||||||
// a-ha! grab the text out of the bitstreams
|
// a-ha! grab the text out of the bitstreams
|
||||||
List<Bitstream> bitstreams = myBundle.getBitstreams();
|
List<Bitstream> bitstreams = myBundle.getBitstreams();
|
||||||
|
log.debug("Processing full-text bitstreams. Item handle: " + sourceInfo);
|
||||||
|
|
||||||
for (Bitstream fulltextBitstream : emptyIfNull(bitstreams)) {
|
for (Bitstream fulltextBitstream : emptyIfNull(bitstreams)) {
|
||||||
fullTextStreams.add(new FullTextBitstream(sourceInfo, fulltextBitstream));
|
fullTextStreams.add(new FullTextBitstream(sourceInfo, fulltextBitstream));
|
||||||
|
|
||||||
|
if (fulltextBitstream != null) {
|
||||||
log.debug("Added BitStream: "
|
log.debug("Added BitStream: "
|
||||||
+ fulltextBitstream.getStoreNumber() + " "
|
+ fulltextBitstream.getStoreNumber() + " "
|
||||||
+ fulltextBitstream.getSequenceID() + " "
|
+ fulltextBitstream.getSequenceID() + " "
|
||||||
+ fulltextBitstream.getName());
|
+ fulltextBitstream.getName());
|
||||||
|
} else {
|
||||||
|
log.error("Found a NULL bitstream when processing full-text files: item handle:" + sourceInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,16 +163,16 @@ public class FullTextContentStreams extends ContentStreamBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getContentType(final Context context) throws SQLException {
|
public String getContentType(final Context context) throws SQLException {
|
||||||
BitstreamFormat format = bitstream.getFormat(context);
|
BitstreamFormat format = bitstream != null ? bitstream.getFormat(context) : null;
|
||||||
return format == null ? null : StringUtils.trimToEmpty(format.getMIMEType());
|
return format == null ? null : StringUtils.trimToEmpty(format.getMIMEType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
return StringUtils.trimToEmpty(bitstream.getName());
|
return bitstream != null ? StringUtils.trimToEmpty(bitstream.getName()) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getSize() {
|
public long getSize() {
|
||||||
return bitstream.getSizeBytes();
|
return bitstream != null ? bitstream.getSizeBytes() : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream getInputStream() throws SQLException, IOException, AuthorizeException {
|
public InputStream getInputStream() throws SQLException, IOException, AuthorizeException {
|
||||||
|
@@ -103,6 +103,11 @@ public class ItemUtils {
|
|||||||
bundle.getElement().add(bitstreams);
|
bundle.getElement().add(bitstreams);
|
||||||
List<Bitstream> bits = b.getBitstreams();
|
List<Bitstream> bits = b.getBitstreams();
|
||||||
for (Bitstream bit : bits) {
|
for (Bitstream bit : bits) {
|
||||||
|
// Check if bitstream is null and log the error
|
||||||
|
if (bit == null) {
|
||||||
|
log.error("Null bitstream found, check item uuid: " + item.getID());
|
||||||
|
break;
|
||||||
|
}
|
||||||
Element bitstream = create("bitstream");
|
Element bitstream = create("bitstream");
|
||||||
bitstreams.getElement().add(bitstream);
|
bitstreams.getElement().add(bitstream);
|
||||||
String url = "";
|
String url = "";
|
||||||
|
Reference in New Issue
Block a user