Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tools for technical analysts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Digital Preservation
tools for technical analysts
Commits
4c79734a
Commit
4c79734a
authored
1 year ago
by
Andreas Romeyke
Browse files
Options
Downloads
Patches
Plain Diff
- fixed validation using algorithm explicitely
- added different output formats
parent
5bf7338d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/SLUB/LZA/TA/Command/permanent.pm
+43
-14
43 additions, 14 deletions
lib/SLUB/LZA/TA/Command/permanent.pm
with
43 additions
and
14 deletions
lib/SLUB/LZA/TA/Command/permanent.pm
+
43
−
14
View file @
4c79734a
...
@@ -2,6 +2,7 @@ package SLUB::LZA::TA::Command::permanent;
...
@@ -2,6 +2,7 @@ package SLUB::LZA::TA::Command::permanent;
use
SLUB::LZA::
TA
-
command
;
use
SLUB::LZA::
TA
-
command
;
use
v5
.36
;
use
v5
.36
;
use
SLUB::LZA::TA::Archivematica::
Elasticsearch
;
use
SLUB::LZA::TA::Archivematica::
Elasticsearch
;
use
SLUB::LZA::TA::
Output
;
use
Archive::
BagIt
;
use
Archive::
BagIt
;
use
File::
Find
;
use
File::
Find
;
use
namespace::
autoclean
;
use
namespace::
autoclean
;
...
@@ -22,7 +23,15 @@ sub description {
...
@@ -22,7 +23,15 @@ sub description {
sub
opt_spec
{
sub
opt_spec
{
my
@global_opts
=
SLUB::LZA::TA::
common_global_opt_spec
();
my
@global_opts
=
SLUB::LZA::TA::
common_global_opt_spec
();
my
@local_opts
=
(
my
@local_opts
=
(
[]
[
'
output-format
'
=>
hidden
=>
{
one_of
=>
[
[
'
output-as-csv|C
'
=>
'
prints output as Comma Separated Values (CSV)
'
],
[
'
output-as-raw|R
'
=>
'
print raw hash output of elasticsearch response
'
],
[
'
output-as-rsv|r
'
=>
'
prints output as Raw Strings Values (RSV)
'
],
[
'
output-as-asciidoc|a
'
=>
'
prints output as human readable AsciiDoc (default)
'
],
],
}
],
);
);
return
(
@global_opts
,
[]
,
@local_opts
);
return
(
@global_opts
,
[]
,
@local_opts
);
}
}
...
@@ -31,30 +40,50 @@ sub validate_args {
...
@@ -31,30 +40,50 @@ sub validate_args {
SLUB::LZA::TA::
common_global_validate
(
$self
,
$opt
,
$args
);
SLUB::LZA::TA::
common_global_validate
(
$self
,
$opt
,
$args
);
# no args allowed but options!
# no args allowed but options!
$self
->
usage_error
("
No args allowed
")
if
@$args
;
$self
->
usage_error
("
No args allowed
")
if
@$args
;
if
(
!
exists
$opt
->
{
output_format
})
{
$opt
->
{
output_format
}
=
'
output_as_asciidoc
';}
return
1
;
return
1
;
}
}
sub
execute
{
sub
execute
{
my
(
$self
,
$opt
,
$args
)
=
@_
;
my
(
$self
,
$opt
,
$args
)
=
@_
;
use
Data::
Printer
;
p
(
$opt
);
p
(
%
SLUB::LZA::TA::
config
);
my
%result
;
my
@candidates
;
my
@candidates
;
my
$wanted
=
sub
{
my
$wanted
=
sub
{
my
(
$dev
,
$ino
,
$mode
,
$nlink
,
$uid
,
$gid
);
my
(
$dev
,
$ino
,
$mode
,
$nlink
,
$uid
,
$gid
);
((
$dev
,
$ino
,
$mode
,
$nlink
,
$uid
,
$gid
)
=
lstat
(
$_
))
((
$dev
,
$ino
,
$mode
,
$nlink
,
$uid
,
$gid
)
=
lstat
(
$_
))
&&
and
(
-
d
_
)
-
f
_
&&
and
(
-
f
"
$_
/bagit.txt
")
/^bag-info\.txt\z/s
&&
and
(
$
File::Find::
prune
=
1
)
(
$
File::Find::
prune
=
1
)
and
push
@candidates
,
$
File::Find::
name
;
&&
push
@candidates
,
$
File::find::
dir
;
};
};
File::Find::
find
({
wanted
=>
$wanted
},
@
{
$
SLUB::LZA::TA::
config
{
permanent_volume
}
}
);
File::Find::
find
(
foreach
my
$candidate
(
@candidates
)
{
{
wanted
=>
$wanted
},
@
{
$
SLUB::LZA::TA::
config
{
permanent_volume
}
}
);
my
@results
=
map
{
my
$candidate
=
$_
;
my
$bag
=
Archive::
BagIt
->
new
(
$candidate
);
my
$bag
=
Archive::
BagIt
->
new
(
$candidate
);
# explicite SHA loading, because
# Archivematica only use SHA512, but have version 0.97
$bag
->
use_plugins
('
Archive::BagIt::Plugin::Algorithm::SHA512
');
my
$is_valid
=
$bag
->
verify_bag
();
my
$is_valid
=
$bag
->
verify_bag
();
$result
{
$candidate
}
=
$is_valid
;
my
$line
;
say
"
$candidate
is
"
.
(
$is_valid
?
"
valid
"
:
"
invalid
");
$line
->
{'
AIP storage path
'}
=
$candidate
;
$line
->
{'
bagit validation result
'}
=
(
$is_valid
?
"
valid
"
:
"
invalid
");
$line
;
}
(
sort
@candidates
);
my
@headers
=
sort
keys
%
{
$results
[
0
]};
if
(
$opt
->
{
output_format
}
eq
'
output_as_csv
')
{
SLUB::LZA::TA::Output::CSV::
print_results
(
\
@headers
,
\
@results
);
}
elsif
(
$opt
->
{
output_format
}
eq
'
output_as_rsv
')
{
SLUB::LZA::TA::Output::RSV::
print_results
(
\
@headers
,
\
@results
);
}
elsif
(
$opt
->
{
output_format
}
eq
'
output_as_raw
')
{
SLUB::LZA::TA::Output::Raw::
print_results
(
\
@results
);
}
else
{
SLUB::LZA::TA::Output::Asciidoc::
print_results
(
\
@headers
,
\
@results
);
}
}
return
1
;
return
1
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment