line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Catmandu::FedoraCommons::Model::export - Perl model for the Fedora 'export' and 'getObjectXML' 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->export(pid => 'demo:29')->parse_content; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
'pid' => 'demo:29' , |
15
|
|
|
|
|
|
|
'version' => '1.1', |
16
|
|
|
|
|
|
|
'objectProperties' => { |
17
|
|
|
|
|
|
|
'state' => 'Inactive' , |
18
|
|
|
|
|
|
|
'label' => 'Data Object for Image Manipulation Demo' , |
19
|
|
|
|
|
|
|
'ownerId' => 'fedoraAdmin' , |
20
|
|
|
|
|
|
|
'createdDate' => '2008-07-02T05:09:42.015Z' , |
21
|
|
|
|
|
|
|
'lastModifiedDate' => '2013-02-07T19:57:27.140Z' , |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
'auditTrail' => [ |
24
|
|
|
|
|
|
|
{ |
25
|
|
|
|
|
|
|
'id' => 'AUDREC1' , |
26
|
|
|
|
|
|
|
'process' => 'Fedora API-M' , |
27
|
|
|
|
|
|
|
'action' => 'addDatastream' , |
28
|
|
|
|
|
|
|
'componentID' => 'TEST' , |
29
|
|
|
|
|
|
|
'responsibility' => 'fedoraAdmin' , |
30
|
|
|
|
|
|
|
'date' => '2013-02-07T18:42:24.518Z' , |
31
|
|
|
|
|
|
|
'justification' => '' , |
32
|
|
|
|
|
|
|
}, |
33
|
|
|
|
|
|
|
], |
34
|
|
|
|
|
|
|
'dc' => { |
35
|
|
|
|
|
|
|
'title' => [ 'Coliseum in Rome' ] , |
36
|
|
|
|
|
|
|
'creator' => [ 'Thornton Staples' ] , |
37
|
|
|
|
|
|
|
'subject' => [ 'Architecture, Roman' ] , |
38
|
|
|
|
|
|
|
'description' => [ 'Image of Coliseum in Rome' ] , |
39
|
|
|
|
|
|
|
'publisher' => [ 'University of Virginia Library' ] , |
40
|
|
|
|
|
|
|
'format' => [ 'image/jpeg' ] , |
41
|
|
|
|
|
|
|
'identifier' => [ 'demo:29' ], |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SEE ALSO |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
L<Catmandu::FedoraCommons> |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
package Catmandu::FedoraCommons::Model::export; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
1
|
|
50962
|
use XML::LibXML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub parse { |
55
|
|
|
|
|
|
|
my ($class,$xml) = @_; |
56
|
|
|
|
|
|
|
my $dom = XML::LibXML->load_xml(string => $xml); |
57
|
|
|
|
|
|
|
$dom->getDocumentElement()->setNamespace('info:fedora/fedora-system:def/foxml#','foxml'); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $xc = XML::LibXML::XPathContext->new( $dom ); |
60
|
|
|
|
|
|
|
$xc->registerNs('audit', 'info:fedora/fedora-system:def/audit#'); |
61
|
|
|
|
|
|
|
$xc->registerNs('oai_dc','http://www.openarchives.org/OAI/2.0/oai_dc/'); |
62
|
|
|
|
|
|
|
$xc->registerNs('dc','http://purl.org/dc/elements/1.1/'); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my @nodes; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
@nodes = $xc->findnodes("/foxml:digitalObject/foxml:objectProperties//foxml:property"); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $result; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
for my $node (@nodes) { |
71
|
|
|
|
|
|
|
my $name = $node->getAttribute('NAME'); |
72
|
|
|
|
|
|
|
my $value = $node->getAttribute('VALUE'); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$name =~ s{.*#}{}; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$result->{objectProperties}->{$name} = $value; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
@nodes = $xc->findnodes("//audit:auditTrail/audit:record"); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my @auditTrail = (); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
for my $node (@nodes) { |
84
|
|
|
|
|
|
|
my $id = $node->findvalue('@ID'); |
85
|
|
|
|
|
|
|
my $process = $node->findvalue('./audit:process/@type'); |
86
|
|
|
|
|
|
|
my $action = $node->findvalue('./audit:action'); |
87
|
|
|
|
|
|
|
my $componentID = $node->findvalue('./audit:componentID'); |
88
|
|
|
|
|
|
|
my $responsibility = $node->findvalue('./audit:responsibility'); |
89
|
|
|
|
|
|
|
my $date = $node->findvalue('./audit:date'); |
90
|
|
|
|
|
|
|
my $justification = $node->findvalue('./audit:justification'); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
push(@auditTrail , { |
93
|
|
|
|
|
|
|
id => $id , |
94
|
|
|
|
|
|
|
process => $process , |
95
|
|
|
|
|
|
|
action => $action , |
96
|
|
|
|
|
|
|
componentID => $componentID , |
97
|
|
|
|
|
|
|
responsibility => $responsibility , |
98
|
|
|
|
|
|
|
date => $date , |
99
|
|
|
|
|
|
|
justification => $justification , |
100
|
|
|
|
|
|
|
}); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
$result->{auditTrail} = \@auditTrail; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
@nodes = $xc->findnodes("//oai_dc:dc/*"); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
for my $node (@nodes) { |
108
|
|
|
|
|
|
|
my $name = $node->nodeName; |
109
|
|
|
|
|
|
|
my $value = $node->textContent; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
push @{ $result->{dc}->{$name} } , $value; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my $pid = $dom->firstChild()->getAttribute('PID'); |
115
|
|
|
|
|
|
|
$result->{pid} = $pid; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
my $version = $dom->firstChild()->getAttribute('VERSION'); |
118
|
|
|
|
|
|
|
$result->{version} = $version; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
return $result; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |