diff --git a/bin/slubsipbuilderbagit.pl b/bin/slubsipbuilderbagit.pl index b56c702903f715824a1b866b14ffc6f5b719ede1..bf52e09b1feb6da85c6f361354f2037088f6d9dc 100644 --- a/bin/slubsipbuilderbagit.pl +++ b/bin/slubsipbuilderbagit.pl @@ -650,38 +650,35 @@ if ((!defined $ppn && !defined $noppn) || (!defined $ppn && $noppn eq "") || (!d 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(); -} else { - if ($sipVersion ne "v2020.1") { - SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: not valid --SIP_version, current tool supports <v2020.1>", "", "red"); - die(); - } - utf8::decode($sipVersion); - push @addBagInfo, {'SLUBArchiv-sipVersion' => $sipVersion}; } +if ($sipVersion ne "v2020.1") { + SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: not valid --SIP_version, current tool supports <v2020.1>", "", "red"); + die(); +} +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(); -} else { - 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(); - } - utf8::decode($externalWorkflow); - push @addBagInfo, {'SLUBArchiv-externalWorkflow' => $externalWorkflow}; } +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(); +} +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(); -} else { - 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(); - } - utf8::decode($externalId); - push @addBagInfo, {'SLUBArchiv-externalId' => $externalId}; } +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(); +} +utf8::decode($externalId); +push @addBagInfo, {'SLUBArchiv-externalId' => $externalId}; # externalIsilId if (defined $externalIsilId && $externalIsilId ne "") { utf8::decode($externalIsilId); @@ -702,57 +699,54 @@ push @addBagInfo, {'SLUBArchiv-hasConservationReason' => $hasConservationReason} 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(); -} else { - utf8::decode($archivalValueDescription); - push @addBagInfo, {'SLUBArchiv-archivalValueDescription' => $archivalValueDescription}; } +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(); -} else { - if($rightsVersion ne "1.0") { - SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: invalid --rights_version, supported version <1.0>", "", "red"); - die(); - } - utf8::decode($rightsVersion); - push @addBagInfo, {'SLUBArchiv-rightsVersion' => $rightsVersion}; } +if($rightsVersion ne "1.0") { + SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "ERROR: invalid --rights_version, supported version <1.0>", "", "red"); + die(); +} +utf8::decode($rightsVersion); +push @addBagInfo, {'SLUBArchiv-rightsVersion' => $rightsVersion}; # addKeyValue 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(); - } else { - utf8::decode($zeile); - my @keyvalue = split(/:/, $zeile, 2); # split on first : - my $key = $keyvalue[0]; - my $value = $keyvalue[1]; - if($key eq 'SLUBArchiv-sipVersion' || - $key eq 'SLUBArchiv-externalWorkflow' || - $key eq 'SLUBArchiv-externalId' || - $key eq 'SLUBArchiv-externalIsilId' || - $key eq 'SLUBArchiv-exportToArchiveDate' || - $key eq 'SLUBArchiv-hasConservationReason' || - $key eq 'SLUBArchiv-archivalValueDescription' || - $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(); - } - 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(); - } - 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(); - } - push @addBagInfo, {$key => $value}; } + utf8::decode($zeile); + my @keyvalue = split(/:/, $zeile, 2); # split on first : + my $key = $keyvalue[0]; + my $value = $keyvalue[1]; + if($key eq 'SLUBArchiv-sipVersion' || + $key eq 'SLUBArchiv-externalWorkflow' || + $key eq 'SLUBArchiv-externalId' || + $key eq 'SLUBArchiv-externalIsilId' || + $key eq 'SLUBArchiv-exportToArchiveDate' || + $key eq 'SLUBArchiv-hasConservationReason' || + $key eq 'SLUBArchiv-archivalValueDescription' || + $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(); + } + 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(); + } + 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(); + } + push @addBagInfo, {$key => $value}; } } ##########################################################################################################################################################