Lines 25-30
use LWP::UserAgent;
Link Here
|
25 |
|
25 |
|
26 |
use Koha::Exceptions; |
26 |
use Koha::Exceptions; |
27 |
|
27 |
|
|
|
28 |
use Try::Tiny qw( catch try ); |
29 |
|
28 |
use base qw(Koha::Object); |
30 |
use base qw(Koha::Object); |
29 |
|
31 |
|
30 |
use Koha; |
32 |
use Koha; |
Lines 218-241
sub harvest_sushi {
Link Here
|
218 |
return if $self->_sushi_errors($result); |
220 |
return if $self->_sushi_errors($result); |
219 |
|
221 |
|
220 |
# Parse the SUSHI response |
222 |
# Parse the SUSHI response |
221 |
my $sushi_counter = Koha::ERM::EUsage::SushiCounter->new( { response => $result } ); |
223 |
try { |
222 |
my $counter_file = $sushi_counter->get_COUNTER_from_SUSHI; |
224 |
my $sushi_counter = Koha::ERM::EUsage::SushiCounter->new( { response => $result } ); |
223 |
|
225 |
my $counter_file = $sushi_counter->get_COUNTER_from_SUSHI; |
224 |
return if $self->_counter_file_size_too_large($counter_file); |
|
|
225 |
|
226 |
|
226 |
$self->counter_files( |
227 |
return if $self->_counter_file_size_too_large($counter_file); |
227 |
[ |
|
|
228 |
{ |
229 |
usage_data_provider_id => $self->erm_usage_data_provider_id, |
230 |
file_content => $counter_file, |
231 |
date_uploaded => POSIX::strftime( "%Y%m%d%H%M%S", localtime ), |
232 |
|
228 |
|
233 |
#TODO: add ".csv" to end of filename here |
229 |
$self->counter_files( |
234 |
filename => $self->name . "_" . $self->{report_type}, |
230 |
[ |
235 |
} |
231 |
{ |
236 |
] |
232 |
usage_data_provider_id => $self->erm_usage_data_provider_id, |
237 |
); |
233 |
file_content => $counter_file, |
|
|
234 |
date_uploaded => POSIX::strftime( "%Y%m%d%H%M%S", localtime ), |
238 |
|
235 |
|
|
|
236 |
#TODO: add ".csv" to end of filename here |
237 |
filename => $self->name . "_" . $self->{report_type}, |
238 |
} |
239 |
] |
240 |
); |
241 |
} catch { |
242 |
if ( $_->isa('Koha::Exceptions::ERM::EUsage::CounterFile::UnsupportedRelease') ) { |
243 |
$self->{job_callbacks}->{add_message_callback}->( |
244 |
{ |
245 |
type => 'error', |
246 |
message => 'COUNTER release ' . $_->{message}->{counter_release} . ' not supported', |
247 |
} |
248 |
) if $self->{job_callbacks}; |
249 |
} |
250 |
}; |
239 |
} |
251 |
} |
240 |
|
252 |
|
241 |
=head3 set_background_job_callbacks |
253 |
=head3 set_background_job_callbacks |