From 4f9825e183824910f310bc8573f619def9ee6e5e Mon Sep 17 00:00:00 2001 From: bolkun <bolkun@BDV092.slub-dresden.de> Date: Fri, 30 Apr 2021 13:41:34 +0200 Subject: [PATCH] Replace die() with exit 1 --- bin/slubsipbuilderbagit.pl | 46 +++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/bin/slubsipbuilderbagit.pl b/bin/slubsipbuilderbagit.pl index b26ea61..ebfc8ac 100644 --- a/bin/slubsipbuilderbagit.pl +++ b/bin/slubsipbuilderbagit.pl @@ -612,67 +612,67 @@ if ($man) { pod2usage(-exitval => 0, -verbose => 2); } # save if (!defined $save || $save eq "") { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: you need to specify a --save_option, available <replace> or <copy> or <move>", "", "red"); - die(); + exit 1; } # ieDirectory if (!defined $ieDirectory || $ieDirectory eq "") { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: you need to specify an --IE_directory, which needs to be archived", "", "red"); - die(); + exit 1; } if (! -d $ieDirectory) { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: you need to specify a valid --IE_directory, status: is not a directory", "", "red"); - die(); + exit 1; } # outputPath if (!defined $outputPath && ($save eq "copy" || $save eq "move")) { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: you need to specify an --SIP_output_path, where the SIP will be stored", "", "red"); - die(); + exit 1; } if (defined $outputPath && $outputPath eq "" && ($save eq "copy" || $save eq "move")) { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: you need to specify an --SIP_output_path, where the SIP will be stored", "", "red"); - die(); + exit 1; } # ppn, noppn if (defined $ppn && defined $noppn) { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: you can only specify either --ppn or --noppn", "", "red"); - die(); + exit 1; } if ((!defined $ppn && !defined $noppn) || (!defined $ppn && $noppn eq "") || (!defined $noppn && $ppn eq "")) { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: you need to specify a PPN with --ppn or use --noppn", "", "red"); - die(); + exit 1; } #########################################################> bag-info.txt <############################################################################### # sipversion if (!defined $sipVersion || $sipVersion eq "") { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: you need to specify --SIP_version, current tool supports <v2020.1>", "", "red"); - die(); + exit 1; } if ($sipVersion ne "v2020.1") { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: not valid --SIP_version, current tool supports <v2020.1>", "", "red"); - die(); + exit 1; } utf8::decode($sipVersion); push @addBagInfo, {'SLUBArchiv-sipVersion' => $sipVersion}; # externalWorkflow if (!defined $externalWorkflow || $externalWorkflow eq "") { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: you need to specify external workflow", "", "red"); - die(); + exit 1; } if ($externalWorkflow !~ m#^[a-z0-9_-]+$#) { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: you need to specify a valid --external_workflow (^[a-z0-9_-]+\$)", "", "red"); - die(); + exit 1; } utf8::decode($externalWorkflow); push @addBagInfo, {'SLUBArchiv-externalWorkflow' => $externalWorkflow}; # externalId if (!defined $externalId || $externalId eq "") { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: you need to specify external ID", "", "red"); - die(); + exit 1; } if ($externalId !~ m#^[a-z0-9_-]+$#) { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: you need to specify a valid --external_id (^[a-z0-9_-]+\$)", "", "red"); - die(); + exit 1; } utf8::decode($externalId); push @addBagInfo, {'SLUBArchiv-externalId' => $externalId}; @@ -695,18 +695,18 @@ push @addBagInfo, {'SLUBArchiv-hasConservationReason' => $hasConservationReason} # archivalValueDescription if (!defined $archivalValueDescription || $archivalValueDescription eq "") { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: you need to specify an --external_value_descr (reason for archiving)", "", "red"); - die(); + exit 1; } utf8::decode($archivalValueDescription); push @addBagInfo, {'SLUBArchiv-archivalValueDescription' => $archivalValueDescription}; # rightsVersion if (!defined $rightsVersion || $rightsVersion eq "") { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: you need to specify --rights_version", "", "red"); - die(); + exit 1; } if($rightsVersion ne "1.0") { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: invalid --rights_version, supported version <1.0>", "", "red"); - die(); + exit 1; } utf8::decode($rightsVersion); push @addBagInfo, {'SLUBArchiv-rightsVersion' => $rightsVersion}; @@ -715,7 +715,7 @@ if (@addKeyValue) { foreach my $zeile(@addKeyValue) { if($zeile !~ m#^.*:.*$#) { # : must be minimum once present SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", 'ERROR: wrong construct in --add_key_value="' . $zeile . '", expected --add_key_value="key:value", regexp to match is (^[^:]+:[^:]+$)', "", "red"); - die(); + exit 1; } utf8::decode($zeile); my @keyvalue = split(/:/, $zeile, 2); # split on first : @@ -731,17 +731,17 @@ if (@addKeyValue) { $key eq 'SLUBArchiv-rightsVersion'){ SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: duplicate key $key present at --add_key_value. Notice: $key is reserved by SLUB Dresden.", "", "red"); SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "INFO: Read Docu for more information at https://slubarchiv.slub-dresden.de/technische-standards-fuer-die-ablieferung-von-digitalen-dokumenten/", "", "white"); - die(); + exit 1; } if($key eq 'Bag-Count'){ SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: $key present at --add_key_value. This key is not available due to SLUB spesification.", "", "red"); SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "INFO: Read Docu for more information at https://slubarchiv.slub-dresden.de/technische-standards-fuer-die-ablieferung-von-digitalen-dokumenten/", "", "white"); - die(); + exit 1; } if($key eq 'Bag-Group-Identifier'){ SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: $key present at --add_key_value. This key is not available due to SLUB spesification.", "", "red"); SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "INFO: Read Docu for more information at https://slubarchiv.slub-dresden.de/technische-standards-fuer-die-ablieferung-von-digitalen-dokumenten/", "", "white"); - die(); + exit 1; } push @addBagInfo, {$key => $value}; } @@ -751,18 +751,18 @@ if (@addKeyValue) { # rightsFilePath if (!defined $rightsFilePath || $rightsFilePath eq "") { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: you need to specify --rights_xml file, which needs to be added", "", "red"); - die(); + exit 1; } if (! -f $rightsFilePath) { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: you need to specify --rights_xml file, status: is not a file", "", "red"); - die(); + exit 1; } # addMetaFile if (@addMetaFile) { foreach my $file(@addMetaFile) { if(! -f $file) { SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: file $file at --add_meta_file, is not a file or could not be found", "", "red"); - die(); + exit 1; } } } -- GitLab