| 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.11'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | my ($class,%args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=17.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | $self->agent('OAI-PERL/'.$HTTP::OAI::VERSION); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # Record the base URL this harvester instance is associated with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | $self->{repository} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | $args{repository} || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 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'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # Canonicalise | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | $self->baseURL($self->baseURL); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 6 | ▶ | sub resume { shift->_elem('resume',@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resume: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 33 | ▶ | sub repository { shift->_elem('repository',@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repository: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | sub baseURL { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 18 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
baseURL: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 18 | ▶ | return @_ ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | $self->repository->baseURL(URI->new(shift)->canonical) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | $self->repository->baseURL(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 7 | ▶ | sub version { shift->repository->protocolVersion(@_); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | sub ListIdentifiers { shift->_list( @_, verb => "ListIdentifiers" ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ListIdentifiers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | ▶ | sub ListRecords { shift->_list( @_, verb => "ListRecords" ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ListRecords: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | sub ListSets { shift->_list( @_, verb => "ListSets" ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ListSets: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | sub _list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_list: called CC=7 SCAR=21.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 5 | local $self->{recursion}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 5 | my $r = $self->_oai( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | # resume the partial list? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # note: noRecordsMatch is a "success" but won't have a resumptionToken | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | last RESUME if !$token->resumptionToken; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | local $self->{recursion}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | $r = $self->_oai( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | onRecord => $r->{onRecord}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | handlers => $r->handlers, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | verb => $r->verb, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | resumptionToken => $token->resumptionToken, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 5 | ▶ | $self->version( $r->version ) if $r->is_success; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 5 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # build the methods for each OAI verb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 11 | foreach my $verb (qw( GetRecord Identify ListMetadataFormats )) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 11 | ▶ | no strict "refs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | *$verb = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 5 | local $self->{recursion}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 5 | my $r = $self->_oai( @_, verb => $verb ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 5 | ▶ | $self->version( $r->version ) if $r->is_success; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 5 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 33 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||