line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Catmandu::FedoraCommons::Model::getObjectHistory - Perl model for the Fedora 'getObjectHistory' 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->getObjectHistory(pid => 'demo:29')->parse_content; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
'pid' => 'demo:29' , |
15
|
|
|
|
|
|
|
'objectChangeDate' => [ |
16
|
|
|
|
|
|
|
'2008-07-02T05:09:43.234Z' , |
17
|
|
|
|
|
|
|
'2013-02-07T18:42:24.672Z' , |
18
|
|
|
|
|
|
|
] , |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SEE ALSO |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
L<Catmandu::FedoraCommons> |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
package Catmandu::FedoraCommons::Model::getObjectHistory; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
89113
|
use XML::LibXML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub parse { |
31
|
|
|
|
|
|
|
my ($class,$xml) = @_; |
32
|
|
|
|
|
|
|
my $dom = XML::LibXML->load_xml(string => $xml); |
33
|
|
|
|
|
|
|
$dom->getDocumentElement()->setNamespace('http://www.fedora.info/definitions/1/0/access/','a'); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $result = {}; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my @nodes = $dom->findnodes("/a:fedoraObjectHistory/*"); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
for my $node (@nodes) { |
40
|
|
|
|
|
|
|
my $name = $node->nodeName; |
41
|
|
|
|
|
|
|
my $value = $node->textContent; |
42
|
|
|
|
|
|
|
push @{ $result->{$name} } , $value; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $pid = $dom->firstChild()->getAttribute('pid'); |
46
|
|
|
|
|
|
|
$result->{pid} = $pid; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
return $result; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |