|
Lines 269-275
Tests the connection of the harvester to the SUSHI service and returns any alert
Link Here
|
| 269 |
sub test_connection { |
269 |
sub test_connection { |
| 270 |
my ($self) = @_; |
270 |
my ($self) = @_; |
| 271 |
|
271 |
|
| 272 |
my $url = _validate_url( $self->service_url, 'status' ); |
272 |
my $url = $self->_validate_url( $self->service_url, 'status' ); |
| 273 |
$url .= 'status'; |
273 |
$url .= 'status'; |
| 274 |
$url .= '?customer_id=' . $self->customer_id; |
274 |
$url .= '?customer_id=' . $self->customer_id; |
| 275 |
$url .= '&requestor_id=' . $self->requestor_id if $self->requestor_id; |
275 |
$url .= '&requestor_id=' . $self->requestor_id if $self->requestor_id; |
|
Lines 384-390
sub _build_url_query {
Link Here
|
| 384 |
$self->erm_usage_data_provider_id; |
384 |
$self->erm_usage_data_provider_id; |
| 385 |
} |
385 |
} |
| 386 |
|
386 |
|
| 387 |
my $url = _validate_url( $self->service_url, 'harvest' ); |
387 |
my $url = $self->_validate_url( $self->service_url, 'harvest' ); |
| 388 |
|
388 |
|
| 389 |
$url .= lc $self->{report_type}; |
389 |
$url .= lc $self->{report_type}; |
| 390 |
$url .= '?customer_id=' . $self->customer_id; |
390 |
$url .= '?customer_id=' . $self->customer_id; |
|
Lines 401-422
sub _build_url_query {
Link Here
|
| 401 |
|
401 |
|
| 402 |
Checks whether the url ends in a trailing "/" and adds one if not |
402 |
Checks whether the url ends in a trailing "/" and adds one if not |
| 403 |
|
403 |
|
| 404 |
my $url = _validate_url($url, 'harvest') |
404 |
my $url = $self->_validate_url($url, 'harvest') |
| 405 |
|
405 |
|
| 406 |
$caller is either the harvest_sushi function ("harvest") or the test_connection function ("status") |
406 |
$caller is either the harvest_sushi function ("harvest") or the test_connection function ("status") |
| 407 |
|
407 |
|
| 408 |
=cut |
408 |
=cut |
| 409 |
|
409 |
|
| 410 |
sub _validate_url { |
410 |
sub _validate_url { |
| 411 |
my ( $url, $caller ) = @_; |
411 |
my ( $self, $url, $caller ) = @_; |
| 412 |
|
412 |
|
| 413 |
if ( $caller eq 'harvest' ) { |
413 |
if ( $caller eq 'harvest' ) { |
| 414 |
|
414 |
|
| 415 |
# Not all urls will end in "/" - add one so they are standardised |
|
|
| 416 |
$url = _check_trailing_character($url); |
415 |
$url = _check_trailing_character($url); |
| 417 |
|
416 |
|
| 418 |
# All SUSHI report requests should be to the "/reports" endpoint |
417 |
# Default to 5.1 if anything other than '5' |
| 419 |
# Not all providers in the counter registry include this in their data so we need to check and add it |
418 |
my $report_release = $self->report_release eq '5' ? $self->report_release : '5.1'; |
|
|
419 |
|
| 420 |
if ( $report_release eq '5.1' ) { |
| 421 |
my $reports_param = substr $url, -4; |
| 422 |
$url .= 'r51/' if $reports_param ne 'r51/'; |
| 423 |
} |
| 424 |
|
| 420 |
my $reports_param = substr $url, -8; |
425 |
my $reports_param = substr $url, -8; |
| 421 |
$url .= 'reports/' if $reports_param ne 'reports/'; |
426 |
$url .= 'reports/' if $reports_param ne 'reports/'; |
| 422 |
} else { |
427 |
} else { |