line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::OAI::Base; |
2
|
|
|
|
|
|
|
|
3
|
14
|
|
|
14
|
|
91
|
use strict; |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
8349
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Net::OAI::Base - A base class for all OAI-PMH responses |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
if ( $object->resumptionToken() ) { |
12
|
|
|
|
|
|
|
... |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
if ( $object->errorCode() ) { |
16
|
|
|
|
|
|
|
print "verb action resulted in error code:" . $object->errorCode() . |
17
|
|
|
|
|
|
|
" message:" . $object->errorString() . "\n"; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
print "xml response can be found here: " . $obj->file() . "\n"; |
21
|
|
|
|
|
|
|
print "the response xml is " . $obj->xml(); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Net::OAI::Base is the base class for all the OAI-PMH verb responses. It is |
26
|
|
|
|
|
|
|
used to provide similar methods to all the responses. The following |
27
|
|
|
|
|
|
|
classes inherit from Net::OAI::Base. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=over 4 |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=item * |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Net::OAI::GetRecord |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item * |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Net::OAI::Identify |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item * |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Net::OAI::ListIdentifiers |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item * |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Net::OAI::ListMetadataFormats |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item * |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Net::OAI::ListRecords |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item * |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Net::OAI::ListSets |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=back |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 METHODS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 errorCode() |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Returns an error code associated with the verb result. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub errorCode { |
66
|
33
|
|
|
33
|
1
|
77986
|
my $self = shift; |
67
|
33
|
100
|
|
|
|
229
|
if ( $self->{ error } ) { |
68
|
13
|
|
|
|
|
79
|
return( $self->{ error }->errorCode() ); |
69
|
|
|
|
|
|
|
} |
70
|
20
|
|
|
|
|
109
|
return( undef ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 errorString() |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Returns an error message associated with an error code. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub errorString { |
80
|
9
|
|
|
9
|
1
|
41
|
my $self = shift; |
81
|
9
|
50
|
|
|
|
48
|
if ( $self->{ error } ) { |
82
|
9
|
|
|
|
|
69
|
return( $self->{ error }->errorString() ); |
83
|
|
|
|
|
|
|
} |
84
|
0
|
|
|
|
|
0
|
return( undef ); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 HTTPError() |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Returns the HTTP::Response object in case of HTTP level errors. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub HTTPError { |
94
|
2
|
|
|
2
|
1
|
944
|
my ( $self ) = @_; |
95
|
2
|
50
|
|
|
|
10
|
return undef unless $self->{ error }; |
96
|
|
|
|
|
|
|
return exists $self->{ error }->{ HTTPError } |
97
|
|
|
|
|
|
|
? $self->{ error }->{ HTTPError } |
98
|
2
|
50
|
|
|
|
17
|
: undef; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 resumptionToken() |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Returns a Net::OAI::ResumptionToken object associated with the call. If |
105
|
|
|
|
|
|
|
there was no resumption token returned in the response then you will |
106
|
|
|
|
|
|
|
be returned undef. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub resumptionToken { |
111
|
7
|
|
|
7
|
1
|
47
|
my $self = shift; |
112
|
7
|
|
|
|
|
29
|
return( $self->{ token } ); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 xml() |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Returns a reference to a scalar that contains the raw content of the response |
118
|
|
|
|
|
|
|
as XML. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub xml { |
123
|
0
|
|
|
0
|
1
|
0
|
my( $self, %args ) = shift; |
124
|
0
|
0
|
|
|
|
0
|
return undef unless $self->{ file }; # not set eg. after HTTP error |
125
|
0
|
0
|
|
|
|
0
|
open( XML, $self->{ file } ) || die "unable to open $self->{ file }"; |
126
|
|
|
|
|
|
|
## slurp entire file into $xml |
127
|
0
|
|
|
|
|
0
|
local $/ = undef; |
128
|
0
|
|
|
|
|
0
|
my $xml = ; |
129
|
0
|
|
|
|
|
0
|
close(XML); # prevent tempfile leak on Win32 |
130
|
0
|
|
|
|
|
0
|
return( $xml ); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 file() |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Returns the path to a file that contains the complete XML response. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub file { |
140
|
40
|
|
|
40
|
1
|
72
|
my $self = shift; |
141
|
40
|
|
|
|
|
457
|
return( $self->{ file } ); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub handleResumptionToken { |
145
|
7
|
|
|
7
|
0
|
24
|
my ( $self, $method ) = @_; |
146
|
|
|
|
|
|
|
|
147
|
7
|
100
|
|
|
|
43
|
my $harvester = exists( $self->{ harvester } ) ? $self->{ harvester } : 0; |
148
|
7
|
100
|
|
|
|
45
|
return() if ref($harvester) ne 'Net::OAI::Harvester'; |
149
|
|
|
|
|
|
|
|
150
|
4
|
|
|
|
|
32
|
my $rToken = $self->resumptionToken(); |
151
|
4
|
100
|
|
|
|
17
|
if ( $rToken ) { |
152
|
3
|
|
|
|
|
18
|
my $new = $harvester->$method( resumptionToken => $rToken->token(), |
153
|
|
|
|
|
|
|
metadataHandler => $self->{metadataHandler} ); |
154
|
3
|
|
|
|
|
15
|
$new->{ harvester } = $harvester; |
155
|
3
|
|
|
|
|
164
|
%$self = %$new; |
156
|
3
|
|
|
|
|
25
|
return( $self->next() ); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
1
|
|
|
|
|
7
|
return(); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 TODO |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 SEE ALSO |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=over 4 |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=back |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 AUTHORS |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=over 4 |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item * Ed Summers |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=back |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
1; |