View | Details | Raw Unified | Return to bug 39345
Collapse All | Expand All

(-)a/Koha/ERM/EUsage/UsageDataProvider.pm (-7 / +12 lines)
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 {
(-)a/Koha/REST/V1/ERM/EUsage/CounterRegistry.pm (-2 / +9 lines)
Lines 90-96 sub list { Link Here
90
    my @counter_5_supporting_platforms;
90
    my @counter_5_supporting_platforms;
91
    foreach my $platform (@$result) {
91
    foreach my $platform (@$result) {
92
        my $name_check = index( lc $platform->{name}, lc $search_string );
92
        my $name_check = index( lc $platform->{name}, lc $search_string );
93
        my @services   = grep { $_->{counter_release} eq '5' } @{ $platform->{sushi_services} };
93
94
        # TODO:
95
        # We should also consider COUNTER 5.1 here, but the COUNTER registry response is not great.
96
        # Visit the following URL:
97
        # <staff_url>/api/v1/erm/counter_registry?_per_page=-1&q={"name":"wiley"}
98
        # Notice the response comes back as the only sushi service being counter release 5,
99
        # but for all supported reports, both '5' and '5.1' are returned.
100
101
        my @services = grep { $_->{counter_release} eq '5' } @{ $platform->{sushi_services} };
94
        if (   scalar(@services) > 0
102
        if (   scalar(@services) > 0
95
            && $name_check != -1
103
            && $name_check != -1
96
            && scalar( @{ $platform->{reports} } ) > 0 )
104
            && scalar( @{ $platform->{reports} } ) > 0 )
97
- 

Return to bug 39345