diff --git a/bin/slubsipbuilder.pl b/bin/slubsipbuilder.pl index 9a5d94fce7f9a266f17d355fcc9c4adfff118d30..447d7db873eff2ec1b1a4ea555ae26871f5c0798 100755 --- a/bin/slubsipbuilder.pl +++ b/bin/slubsipbuilder.pl @@ -31,6 +31,7 @@ use File::Basename; use File::Copy qw(cp); use File::Find; use File::Path; +use Path::Tiny; use Getopt::Long; use LWP::UserAgent; # to get MARC data use MARC::Record; @@ -81,7 +82,7 @@ if ((!defined $ppn) && (!defined $noppn)) { confess("you need to specify a PPN if (!defined $output) { confess("you need to specify an output path, where the SIP will be stored"); } if (!defined $external_conservation_flag) { $external_conservation_flag="false"; } else { $external_conservation_flag="true"; } if (! -d $directory) { confess("you need to specify an IE directory, which needs to be archived, $!"); } -if ($directory !~ m#^/#) { $directory = abs_path($directory); } +$directory = abs_path($directory); if ($external_id !~ m#^[a-z0-9]+$#) { confess("you need to specify a valid external ID (^[a-z0-9]+\$)"); } if ($external_workflow !~ m#^[a-z0-9]+$#) { confess("you need to specify a valid external workflow (^[a-z0-9]+\$)"); } if (!$external_value_descr) { confess("you need to specify an external value description (reason for archiving)"); } @@ -238,9 +239,9 @@ sub get_mods_from ($$$$) { # $mods = ($url, $ppn, $searchkey, $recordschema) say "write DEBUG_${ppn}_response.xml"; write_file("DEBUG_${ppn}_response.xml", $record->decoded_content); } - my $marcblob = $parser->parse_string( - $xp->findnodes_as_string('/*[local-name()="searchRetrieveResponse"]/*[local-name()="records"]/*[local-name()="record"]/*[local-name()="recordData"]/*') - ); + my $recordData = $xp->findnodes_as_string('/*[local-name()="searchRetrieveResponse"]/*[local-name()="records"]/*[local-name()="record"]/*[local-name()="recordData"]/*'); + if (!$recordData) { die("ERROR: Did not get any <recordData/> for PPN '$ppn' using '$sru'"); } + my $marcblob = $parser->parse_string( $recordData ); my $marcblob_patched = patch_marc_response( $marcblob ); if ($with_debug) { say "write DEBUG_${ppn}_marc_unpatched.xml";