diff --git a/bin/slubsipbuilderbagit.pl b/bin/slubsipbuilderbagit.pl index ade52e97add484fc4053b3f11f6e6663405489c4..d6308dee04d23a8f63949837db634435898c6b81 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}) {