Skip to content

Commit

Permalink
Add check to avoid adding empty array of values to an item.
Browse files Browse the repository at this point in the history
  • Loading branch information
Leano1998 committed Jan 15, 2025
1 parent b2310c8 commit 6e0124f
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,10 @@ void removePreviousVersionDOIsOutOfObject(Context c, Item item, String oldDoi)
if (changed) {
try {
itemService.clearMetadata(c, item, MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, Item.ANY);
itemService.addMetadata(c, item, MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null, newIdentifiers);
// Checks if Array newIdentifiers is empty to avoid adding null values to the metadata field.
if (!newIdentifiers.isEmpty()) {
itemService.addMetadata(c, item, MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null, newIdentifiers);
}
itemService.update(c, item);
} catch (SQLException ex) {
throw new RuntimeException("A problem with the database connection occurred.", ex);
Expand Down

0 comments on commit 6e0124f

Please sign in to comment.