| 1 | package HTTP::OAI::Harvester; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use base HTTP::OAI::UserAgent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 11 | our $VERSION = '4.13'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | my ($class,%args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | my %ARGS = %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | delete @ARGS{qw(baseURL resume repository handlers onRecord)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | my $self = $class->SUPER::new(%ARGS); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | $self->{doc} = XML::LibXML::Document->new( '1.0', 'UTF-8' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | $self->{'resume'} = exists($args{resume}) ? $args{resume} : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | if ($ENV{HTTP_OAI_AGENT}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | $self->agent($ENV{HTTP_OAI_AGENT}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | $self->agent('OAI-PERL/'.$HTTP::OAI::VERSION); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # Record the base URL this harvester instance is associated with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | $self->{repository} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | $args{repository} || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | ▶ | HTTP::OAI::Identify->new(baseURL=>$args{baseURL}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$args{'repository'} || 'HTTP::OAI::Identify'->new('baseURL', $args{'baseURL'})
MC/DC0%0/2
$args{'repository'} || 'HTTP::OAI::Identify'->new('baseURL', $args{'baseURL'})
$args{'repository'}
'HTTP::OAI::Identify'->new('baseURL', $args{'baseURL'})
Truth table33%1/3
A || B
A= $args{'repository'}B= 'HTTP::OAI::Identify'->new('baseURL', $args{'baseURL'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | ▶ | Carp::croak "Requires repository or baseURL" unless $self->repository and $self->repository->baseURL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->repository and $self->repository->baseURL
MC/DC0%0/2
$self->repository and $self->repository->baseURL
$self->repository
$self->repository->baseURL
Truth table33%1/3
A and B
A= $self->repositoryB= $self->repository->baseURL
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # Canonicalise | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | $self->baseURL($self->baseURL); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | ▶ | sub resume { shift->_elem('resume',@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resume: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 33 | ▶ | sub repository { shift->_elem('repository',@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repository: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 18 | ▶ | sub baseURL { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
baseURL: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 18 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 18 | ▶ | return @_ ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | $self->repository->baseURL(URI->new(shift)->canonical) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | $self->repository->baseURL(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 7 | ▶ | sub version { shift->repository->protocolVersion(@_); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | ▶ | sub ListIdentifiers { shift->_list( @_, verb => "ListIdentifiers" ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ListIdentifiers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 3 | ▶ | sub ListRecords { shift->_list( @_, verb => "ListRecords" ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ListRecords: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | ▶ | sub ListSets { shift->_list( @_, verb => "ListSets" ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ListSets: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | sub _list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_list: called CC=7 SCAR=21.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 5 | local $self->{recursion}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 5 | my $r = $self->_oai( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # resume the partial list? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # note: noRecordsMatch is a "success" but won't have a resumptionToken | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 5 | ▶ | RESUME: while($self->resume && $r->is_success && !$r->error && defined(my $token = $r->resumptionToken)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$self->resume and $r->is_success and not $r->error and defined(my $token = $r->resumptionToken)
$self->resume and $r->is_success and not $r->error
$self->resume and $r->is_success
MC/DC0%0/4
$self->resume and $r->is_success and not $r->error and defined(my $token = $r->resumptionToken)
$self->resume
$r->is_success
not $r->error
defined(my $token = $r->resumptionToken)
Truth table60%3/5
A and B and not(C) and D
A= $self->resumeB= $r->is_successC= not $r->errorD= defined(my $token = $r->resumptionToken)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | last RESUME if !$token->resumptionToken; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | local $self->{recursion}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | $r = $self->_oai( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | onRecord => $r->{onRecord}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | handlers => $r->handlers, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | verb => $r->verb, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | resumptionToken => $token->resumptionToken, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 5 | ▶ | $self->version( $r->version ) if $r->is_success; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 5 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # build the methods for each OAI verb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 11 | foreach my $verb (qw( GetRecord Identify ListMetadataFormats )) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 11 | ▶ | no strict "refs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 5 | ▶ | *$verb = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 5 | local $self->{recursion}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 5 | my $r = $self->_oai( @_, verb => $verb ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 5 | ▶ | $self->version( $r->version ) if $r->is_success; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 5 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 33 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||