line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::OAI::Error; |
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
81
|
use strict; |
|
16
|
|
|
|
|
33
|
|
|
16
|
|
|
|
|
502
|
|
4
|
16
|
|
|
16
|
|
82
|
use base qw( XML::SAX::Base Exporter ); |
|
16
|
|
|
|
|
35
|
|
|
16
|
|
|
|
|
21289
|
|
5
|
|
|
|
|
|
|
our @EXPORT = ( |
6
|
|
|
|
|
|
|
); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Net::OAI::Error - OAI-PMH errors. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Note: Actually this class implements the SAX filter which processes |
18
|
|
|
|
|
|
|
(and forwards) all top-level OAI-PMH elements. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Specifically the following events are not forwarded: OAI-PMH itself, |
21
|
|
|
|
|
|
|
request, responseDate and error. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Thus only events for the elements corresponding to the individual |
24
|
|
|
|
|
|
|
OAI-PMH verbs are forwarded. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 METHODS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 new() |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub new { |
34
|
33
|
|
|
33
|
1
|
1026
|
my ( $class, %opts ) = @_; |
35
|
33
|
|
33
|
|
|
308
|
my $self = bless \%opts, ref( $class ) || $class; |
36
|
33
|
|
|
|
|
253
|
$self->{ tagStack } = []; |
37
|
33
|
100
|
|
|
|
230
|
$self->{ errorCode } = '' if ! exists( $self->{ errorCode } ); |
38
|
33
|
100
|
|
|
|
219
|
$self->{ errorString } = '' if ! exists( $self->{ errorString } ); |
39
|
|
|
|
|
|
|
# do not initialize $self->{ HTTPError } and $self->{ HTTPRetryAfter } |
40
|
33
|
|
|
|
|
203
|
return( $self ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 errorCode() |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Returns an OAI error if one was encountered, or the empty string if no errors |
46
|
|
|
|
|
|
|
were associated with the OAI request. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=over 4 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
badArgument |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
badResumptionToken |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
badVerb |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
cannotDisseminateFormat |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
idDoesNotExist |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
noRecordsMatch |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
noMetadataFormats |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
noSetHierarchy |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
xmlParseError |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
xmlContentError |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
numerical HTTP status code |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
For more information about these error codes see: |
97
|
|
|
|
|
|
|
L. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub errorCode { |
102
|
54
|
|
|
54
|
1
|
117
|
my ( $self, $code ) = @_; |
103
|
54
|
50
|
|
|
|
166
|
if ( $code ) { $self->{ errorCode } = $code; } |
|
0
|
|
|
|
|
0
|
|
104
|
54
|
|
|
|
|
318
|
return( $self->{ errorCode } ); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 errorString() |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Returns a textual description of the error that was encountered, or an empty |
110
|
|
|
|
|
|
|
string if there was no error associated with the OAI request. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub errorString { |
115
|
4
|
|
|
4
|
1
|
12
|
my ( $self, $str ) = @_; |
116
|
4
|
50
|
|
|
|
21
|
if ( $str ) { $self->{ errorString } = $str; } |
|
0
|
|
|
|
|
0
|
|
117
|
4
|
|
|
|
|
45
|
return( $self->{ errorString } ); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 HTTPError() |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
In case of HTTP level errors, returns the associated HTTP::Response object. |
123
|
|
|
|
|
|
|
Otherwise C. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub HTTPError { |
129
|
33
|
|
|
33
|
1
|
77
|
my ( $self ) = @_; |
130
|
33
|
100
|
|
|
|
216
|
return exists $self->{ HTTPError } ? $self->{ HTTPError } : undef; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 HTTPRetryAfter() |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
In case of HTTP level errors, returns the Retry-After header of the HTTP Response object, |
137
|
|
|
|
|
|
|
or the empty string if no such header is persent. Otherwise C. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub HTTPRetryAfter { |
143
|
0
|
|
|
0
|
1
|
0
|
my ( $self ) = @_; |
144
|
0
|
0
|
|
|
|
0
|
return exists $self->{ HTTPRetryAfter } ? $self->{ HTTPRetryAfter } : undef; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 TODO |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 SEE ALSO |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=over 4 |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=back |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 AUTHORS |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Ed Summers |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
## internal stuff |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
## all children of Net::OAI::Base should call this to make sure |
165
|
|
|
|
|
|
|
## certain object properties are set |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub start_prefix_mapping { |
168
|
4449
|
|
|
4449
|
1
|
2530265
|
my ($self, $mapping) = @_; |
169
|
4449
|
50
|
|
|
|
12250
|
warn "N_O_E: start_prefix_mapping @{[$mapping]} w/o handler" unless $self->get_handler(); |
|
0
|
|
|
|
|
0
|
|
170
|
4449
|
|
|
|
|
39006
|
return $self->SUPER::start_prefix_mapping( $mapping ); |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub start_element { |
174
|
66885
|
|
|
66885
|
1
|
21205372
|
my ( $self, $element ) = @_; |
175
|
66885
|
100
|
|
|
|
234143
|
return $self->SUPER::start_element($element) unless $element->{NamespaceURI} eq Net::OAI::Harvester::XMLNS_OAI; # should be error? |
176
|
|
|
|
|
|
|
|
177
|
32370
|
|
|
|
|
47898
|
my $tagName = $element->{ LocalName }; |
178
|
32370
|
100
|
|
|
|
102614
|
if ( $tagName eq 'request' ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
179
|
27
|
|
|
|
|
116
|
Net::OAI::Harvester::debug( "caught request" ); |
180
|
27
|
|
|
|
|
90
|
$self->{ _requestAttrs } = {}; |
181
|
27
|
|
|
|
|
64
|
foreach ( values %{$element->{ Attributes }} ) { |
|
27
|
|
|
|
|
129
|
|
182
|
64
|
50
|
|
|
|
204
|
next if $_->{ Prefix }; |
183
|
64
|
|
|
|
|
253
|
$self->{ _requestAttrs }->{ $_->{ Name } } = $_->{ Value }; |
184
|
|
|
|
|
|
|
} |
185
|
27
|
|
|
|
|
174
|
$self->{ _insideSelf } = ""; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
elsif ( $tagName eq 'responseDate' ) { |
188
|
27
|
|
|
|
|
138
|
Net::OAI::Harvester::debug( "caught responseDate" ); |
189
|
27
|
|
|
|
|
146
|
$self->{ _insideSelf } = ""; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
elsif ( $tagName eq 'error' ) { |
192
|
4
|
|
|
|
|
24
|
Net::OAI::Harvester::debug( "caught error" ); |
193
|
4
|
|
|
|
|
18
|
$self->{ errorCode } = $element->{ Attributes }{ '{}code' }{ Value }; |
194
|
4
|
|
|
|
|
23
|
$self->{ _insideSelf } = ""; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
else { |
197
|
32312
|
|
|
|
|
84159
|
$self->SUPER::start_element( $element ); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub end_element { |
202
|
66885
|
|
|
66885
|
1
|
12011567
|
my ( $self, $element ) = @_; |
203
|
66885
|
100
|
|
|
|
234213
|
return $self->SUPER::end_element($element) unless $element->{NamespaceURI} eq Net::OAI::Harvester::XMLNS_OAI; # should be error? |
204
|
|
|
|
|
|
|
|
205
|
32370
|
|
|
|
|
47510
|
my $tagName = $element->{ LocalName }; |
206
|
32370
|
100
|
|
|
|
104833
|
if ( $tagName eq 'request' ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
207
|
27
|
|
|
|
|
76
|
$self->{ _requestContent } = $self->{ _insideSelf }; |
208
|
27
|
|
|
|
|
115
|
delete $self->{ _insideSelf }; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
elsif ( $tagName eq 'responseDate' ) { |
211
|
27
|
|
|
|
|
100
|
$self->{ _responseDate } = $self->{ _insideSelf }; |
212
|
27
|
|
|
|
|
135
|
delete $self->{ _insideSelf }; |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
elsif ( $tagName eq 'error' ) { |
215
|
4
|
|
|
|
|
15
|
$self->{ errorString } = $self->{ _insideSelf }; |
216
|
4
|
|
|
|
|
22
|
delete $self->{ _insideSelf }; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
else { |
219
|
32312
|
|
|
|
|
82803
|
$self->SUPER::end_element( $element ); |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
sub characters { |
224
|
141202
|
|
|
141202
|
1
|
14383235
|
my ( $self, $characters ) = @_; |
225
|
141202
|
100
|
|
|
|
292814
|
if ( exists $self->{ _insideSelf } ) { |
226
|
58
|
|
|
|
|
285
|
$self->{ _insideSelf } .= $characters->{ Data }; |
227
|
|
|
|
|
|
|
} else { |
228
|
141144
|
|
|
|
|
348797
|
$self->SUPER::characters( $characters ); |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
1; |
233
|
|
|
|
|
|
|
|