Skip to content
Snippets Groups Projects
Verified Commit 53563a97 authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- path mapping added

parent 9f74b321
Branches
Tags
No related merge requests found
......@@ -152,16 +152,35 @@ sub validate_args { ## no critic (CognitiveComplexity::ProhibitExcessCognitiveCo
return 1;
}
sub _check_aip ($sample) {
sub _check_aip ($sample, $opt) {
my $path = $sample->{filePath};
my $is_valid=0;
if (-d $path) {
my $bag = Archive::BagIt::Fast->new($path);
$bag->use_plugins('Archive::BagIt::Plugin::Algorithm::SHA512');
$is_valid = $bag->verify_bag( {report_all_errors => 1} );
if (! $is_valid) {$is_valid=0;}
}
my $prefix_permanent = '/var/archivematica/sharedDirectory/www/AIPsStore';
my $line;
my $tries = 0;
foreach my $current_permanent (@{$SLUB::LZA::TA::config{permanent_volume}}) {
(my $remapped = $path) =~ s#^$prefix_permanent#$current_permanent#;
if ($opt->{debug}) {
say STDERR "try remap $path to $remapped";
}
if ($tries == 0) {
$line->{localPath} = $remapped;
} else {
$line->{"localPath$tries"} = $remapped;
}
if (-d $remapped) {
my $bag = Archive::BagIt::Fast->new($remapped);
$bag->use_plugins('Archive::BagIt::Plugin::Algorithm::SHA512');
$is_valid = $bag->verify_bag({ report_all_errors => 1 });
if (!$is_valid) {$is_valid = 0;}
last;
} else {
$is_valid = -1;
}
$tries++;
}
$line->{aipid}=$sample->{uuid};
$line->{filePath}=$sample->{filePath};
$line->{lzaid}=$sample->{transferMetadata}->[0]->{'bim:bag-info_dict'}->{'bim:SLUBArchiv-lzaId'};
......@@ -200,7 +219,7 @@ sub _execute {
}
# select first sample size aips
my @sample_set = sort {$a->{uuid} cmp $b->{uuid}} List::Util::sample $sample_size, map {$_->{'_source'} } @{ $aips_response->{hits}->{hits} };
my @result = map { _check_aip($_) } @sample_set;
my @result = map { _check_aip($_, $opt) } @sample_set;
return \@result;
}
......@@ -237,10 +256,16 @@ sub _print_aip($line) {
my $isvalid=($line->{isvalid}?"valid":"invalid");
my $lzaid=$line->{lzaid}?"With lzaid '$line->{lzaid}'":"No lzaid defined";
my $path=$line->{filePath};
my $mapped = $line->{localPath};
foreach my $additional_key (grep {/^localPath\d/} keys %{ $line }) {
my $additional_path = $line->{$additional_key};
$mapped.= " or $additional_path";
}
say " * AIP `$aipid`";
say " ** Is $isvalid";
say " ** $lzaid";
say " ** Path is `$path`";
say " ** Mapped Path is $mapped";
say " ** processed at $line->{checkdate}, created at $line->{creationdate}";
return 1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment