From 7f25f058a24581d458aa0473ed87b309f91a8105 Mon Sep 17 00:00:00 2001 From: Jens Steidl <Jens.Steidl@slub-dresden.de> Date: Wed, 17 Mar 2021 13:17:52 +0100 Subject: [PATCH] - updated/added parameter checks --- bin/slubsipbuilderbagit.pl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/slubsipbuilderbagit.pl b/bin/slubsipbuilderbagit.pl index ade52e9..d6308de 100644 --- a/bin/slubsipbuilderbagit.pl +++ b/bin/slubsipbuilderbagit.pl @@ -96,7 +96,7 @@ package SLUB::LZA::SIPBuilderBagIt; ]; sub add_metadata($$$$) { - if(! defined $_[0]) { croak "array of hashes not defined for bag-info.txt!"; } + if(ref($_[0]) ne 'ARRAY') { croak "array of hashes not defined for bag-info.txt!"; } my $refAddBagInfo = $_[0]; # ref to array of hashes my $ppn = $_[1]; @@ -116,6 +116,9 @@ package SLUB::LZA::SIPBuilderBagIt; } sub get_marc21_text_node($$) { + if(! $_[0]) { croak "empty marc21!"; } + if(ref($_[1]) ne 'HASH') { croak "not a mapping hash!"; } + my $marc21 = $_[0]; my $mapping = $_[1]; @@ -130,9 +133,9 @@ package SLUB::LZA::SIPBuilderBagIt; } sub get_marc21_from_catalogue($){ - if(! defined $_[0]){ croak "ppn not defined!"; } + if(! $_[0]){ croak "ppn not defined!"; } - my $ppn = shift; + my $ppn = $_[0]; my $marc21; my $use_fallback; @@ -678,7 +681,10 @@ PATCH } sub checkForTitle($){ - my $key_hash_list_aref = shift; + if(ref($_[0]) ne 'ARRAY') { croak "no array of hashes with bag-info.txt key values given!"; } + + my $key_hash_list_aref = $_[0]; + # collect all bag-info keys for easy check my @keys; for my $hash (@{$key_hash_list_aref}) { -- GitLab