Skip to content

Commit

Permalink
Merge pull request DSpace#10209 from dspace-unimr/fix/avoid-inserting…
Browse files Browse the repository at this point in the history
…-null-values-during-version-creation

Avoid IllegalArgumentException thrown during creating a new version in special DSpace settings
  • Loading branch information
tdonohue authored Jan 22, 2025
2 parents 16b9fa7 + 6e0124f commit 5d6ef15
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 5d6ef15

Please sign in to comment.