Lines 87-96
Starts harvesting
Link Here
|
87 |
|
87 |
|
88 |
sub init { |
88 |
sub init { |
89 |
my ( $self, $args ) = @_; |
89 |
my ( $self, $args ) = @_; |
90 |
|
|
|
91 |
$self->printlog("Starting OAI Harvest from repository"); |
90 |
$self->printlog("Starting OAI Harvest from repository"); |
92 |
my $server = $self->{server}; |
91 |
my $server = $self->{server}; |
93 |
my $days = $self->{days}; |
92 |
my $days = $self->{days}; |
|
|
93 |
my $init_results; |
94 |
|
94 |
|
95 |
my $h = HTTP::OAI::Harvester->new( |
95 |
my $h = HTTP::OAI::Harvester->new( |
96 |
repository => HTTP::OAI::Identify->new( |
96 |
repository => HTTP::OAI::Identify->new( |
Lines 117-122
sub init {
Link Here
|
117 |
$lmdflog .= $_->metadataPrefix . " "; |
117 |
$lmdflog .= $_->metadataPrefix . " "; |
118 |
} |
118 |
} |
119 |
$self->printlog("Available metadata formats for this repository: $lmdflog"); |
119 |
$self->printlog("Available metadata formats for this repository: $lmdflog"); |
|
|
120 |
$init_results->{metadata_formats} = $lmdflog; |
120 |
} catch { |
121 |
} catch { |
121 |
$self->printlog("ListMetadataFormats failed"); |
122 |
$self->printlog("ListMetadataFormats failed"); |
122 |
}; |
123 |
}; |
Lines 148-154
sub init {
Link Here
|
148 |
); |
149 |
); |
149 |
if ( $response->is_error ) { |
150 |
if ( $response->is_error ) { |
150 |
$self->printlog( "Error requesting ListRecords: " . $response->code . " " . $response->message ); |
151 |
$self->printlog( "Error requesting ListRecords: " . $response->code . " " . $response->message ); |
151 |
exit; |
152 |
$init_results->{is_error} = $response->message; |
|
|
153 |
return $init_results; |
152 |
} |
154 |
} |
153 |
$self->printlog( "Request URL: " . $response->requestURL ); |
155 |
$self->printlog( "Request URL: " . $response->requestURL ); |
154 |
|
156 |
|
Lines 164-169
sub init {
Link Here
|
164 |
my $status = $self->processRecord($oai_record); |
166 |
my $status = $self->processRecord($oai_record); |
165 |
$stats{$status}++; |
167 |
$stats{$status}++; |
166 |
} |
168 |
} |
|
|
169 |
$init_results->{total} = $stats{'total'}; |
167 |
|
170 |
|
168 |
my $results = ''; |
171 |
my $results = ''; |
169 |
foreach my $status (@statuses) { |
172 |
foreach my $status (@statuses) { |
Lines 193-212
sub init {
Link Here
|
193 |
) |
196 |
) |
194 |
) or $self->printlog("OAI_HARVEST_REPORT letter not found"); |
197 |
) or $self->printlog("OAI_HARVEST_REPORT letter not found"); |
195 |
|
198 |
|
196 |
my $success = C4::Letters::EnqueueLetter( |
199 |
my $message_id = C4::Letters::EnqueueLetter( |
197 |
{ |
200 |
{ |
198 |
letter => $letter, |
201 |
letter => $letter, |
199 |
to_address => C4::Context->preference("OAI-PMH:HarvestEmailReport"), message_transport_type => 'email' |
202 |
to_address => C4::Context->preference("OAI-PMH:HarvestEmailReport"), message_transport_type => 'email' |
200 |
} |
203 |
} |
201 |
); |
204 |
); |
202 |
if ($success) { |
205 |
if ($message_id) { |
203 |
$self->printlog("Email report enqueued"); |
206 |
$self->printlog("Email report enqueued"); |
|
|
207 |
$init_results->{letter_message_id} = $message_id; |
204 |
} else { |
208 |
} else { |
205 |
$self->printlog("Unable to enqueue report email"); |
209 |
$self->printlog("Unable to enqueue report email"); |
206 |
} |
210 |
} |
207 |
} |
211 |
} |
208 |
|
212 |
|
209 |
$self->printlog("Ending OAI Harvest from repository"); |
213 |
$self->printlog("Ending OAI Harvest from repository"); |
|
|
214 |
return $init_results; |
210 |
} |
215 |
} |
211 |
|
216 |
|
212 |
=head2 processRecord |
217 |
=head2 processRecord |