line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Catmandu::FedoraCommons::Model::validate - Perl model for the Fedora 'validate' REST call |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Catmandu::FedoraCommons; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $fedora = Catmandu::FedoraCommons->new('http://localhost:8080/fedora','fedoraAdmin','fedoraAdmin'); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $obj = $fedora->validate(pid => 'demo:29')->parse_content; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
'pid' => 'demo:29' , |
15
|
|
|
|
|
|
|
'valid' => 'false' , |
16
|
|
|
|
|
|
|
'asOfDateTime' => '2013-02-08T10:09:09.273Z' , |
17
|
|
|
|
|
|
|
'model' => [ |
18
|
|
|
|
|
|
|
'info:fedora/demo:UVA_STD_IMAGE' , |
19
|
|
|
|
|
|
|
'info:fedora/fedora-system:FedoraObject-3.0' , |
20
|
|
|
|
|
|
|
], |
21
|
|
|
|
|
|
|
'problem' => [ |
22
|
|
|
|
|
|
|
'test' |
23
|
|
|
|
|
|
|
] , |
24
|
|
|
|
|
|
|
'datastream' => [ |
25
|
|
|
|
|
|
|
{ |
26
|
|
|
|
|
|
|
'dsID' => 'url' , |
27
|
|
|
|
|
|
|
'problem' => [ |
28
|
|
|
|
|
|
|
"Datastream 'url' is does not have the FORMAT_URI and MIME_TYPE attributes required by 'demo:UVA_STD_IMAGE'" , |
29
|
|
|
|
|
|
|
] |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
] , |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 SEE ALSO |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
L<Catmandu::FedoraCommons> |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
package Catmandu::FedoraCommons::Model::validate; |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
1
|
|
47884
|
use XML::LibXML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub parse { |
44
|
|
|
|
|
|
|
my ($class,$xml) = @_; |
45
|
|
|
|
|
|
|
my $dom = XML::LibXML->load_xml(string => $xml); |
46
|
|
|
|
|
|
|
$dom->getDocumentElement()->setNamespace('http://www.fedora.info/definitions/1/0/management/','m'); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $result; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$result->{asOfDateTime} = $dom->findnodes("/m:validation/m:asOfDateTime")->[0]->textContent; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my @nodes; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
@nodes = $dom->findnodes("/m:validation/m:contentModels/m:model"); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
for my $node (@nodes) { |
57
|
|
|
|
|
|
|
my $value = $node->textContent; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
push @{$result->{model}} , $value; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
@nodes = $dom->findnodes("/m:validation/m:datastreamProblems/m:datastream"); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
for my $node (@nodes) { |
65
|
|
|
|
|
|
|
my $dsID = $node->getAttribute('datastreamID'); |
66
|
|
|
|
|
|
|
my $value = $node->textContent; |
67
|
|
|
|
|
|
|
my $datastream = { dsID => $dsID }; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my @subnodes = $node->findnodes("./m:problem"); |
70
|
|
|
|
|
|
|
for my $subnode (@subnodes) { |
71
|
|
|
|
|
|
|
my $value = $node->textContent; |
72
|
|
|
|
|
|
|
push @{$datastream->{problem}} , $value; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
push @{$result->{datastream}} , $datastream; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
@nodes = $dom->findnodes("/m:validation/m:problems/m:problem"); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
for my $node (@nodes) { |
81
|
|
|
|
|
|
|
my $value = $node->textContent; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
push @{$result->{problem}} , $value; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $pid = $dom->firstChild()->getAttribute('pid'); |
87
|
|
|
|
|
|
|
$result->{pid} = $pid; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $valid = $dom->firstChild()->getAttribute('valid'); |
90
|
|
|
|
|
|
|
$result->{valid} = $valid; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
return $result; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |