Skip to content

Commit

Permalink
Prevent saving a broken METS file (kitodo#5883)
Browse files Browse the repository at this point in the history
Throw an illegal argument exception if either side of the pair is null
  • Loading branch information
matthias-ronge authored Feb 21, 2024
1 parent 0e0dcf8 commit 5764cac
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,12 @@ private DivType generatePhysicalStructMapRecursive(PhysicalDivision physicalDivi
private StructLink createStructLink(LinkedList<Pair<String, String>> smLinkData) {
StructLink structLink = new StructLink();
structLink.getSmLinkOrSmLinkGrp().addAll(smLinkData.parallelStream().map(entry -> {
if (Objects.isNull(entry.getLeft())) {
throw new IllegalArgumentException("smLinkData.entry[?].left must not be null");
}
if (Objects.isNull(entry.getRight())) {
throw new IllegalArgumentException("smLinkData.entry[?].right must not be null");
}
SmLink smLink = new SmLink();
smLink.setFrom(entry.getLeft());
smLink.setTo(entry.getRight());
Expand Down

0 comments on commit 5764cac

Please sign in to comment.