diff --git a/bin/slubsipbuilderbagit.pl b/bin/slubsipbuilderbagit.pl index cb80ae81981c0bd674a2f6ea0395d8a0e67b27ca..96805aebfffea4192e212c4919a3c1f276a1e5b8 100644 --- a/bin/slubsipbuilderbagit.pl +++ b/bin/slubsipbuilderbagit.pl @@ -61,7 +61,8 @@ package SLUB::LZA::SIPBuilderBagIt; my $marc_mods_url = 'http://www.loc.gov/standards/mods/v3/MARC21slim2MODS3-6.xsl'; my $marc_utils_url = 'http://www.loc.gov/standards/marcxml/xslt/MARC21slimUtils.xsl'; my $swb_url = 'https://sru.bsz-bw.de/swb'; - my $searchkey = 'pica.all'; + my $searchkey_swb = 'pica.swn'; + my $searchkey_k10p = 'pica.ppn'; my $recordschema = 'marcxmlvbos'; our $with_debug = 0; @@ -85,7 +86,20 @@ MODS if(! defined $_[0]){ croak "ppn not defined!"; } my $ppn = shift; - my $mods = SLUB::LZA::SIPBuilderBagIt::get_mods_from($swb_url, $ppn, $searchkey, $recordschema); + my $mods; + eval { + $mods = SLUB::LZA::SIPBuilderBagIt::get_mods_from($swb_url, $ppn, $searchkey_swb, $recordschema); + }; + # Fallback to K10plus PPN + if ($@ =~ m#ERROR: Did not get any <recordData/> for PPN#) { + print_scalar_data("", "WARNING: '$ppn' not a SWB PPN, fallback to K10plus", "", "yellow"); + $mods = SLUB::LZA::SIPBuilderBagIt::get_mods_from($swb_url, $ppn, $searchkey_k10p, $recordschema); + } + else { + die $@; # throw exception again + } + print_scalar_data("", "INFO: Found metadata for PPN '$ppn'", "", "white"); + if($with_debug){ SLUB::LZA::SIPBuilderBagIt::write_file("DEBUG_${ppn}_mods.xml", $mods);