Bug 39345: Use data provider report release to establish service URL
Signed-off-by: Eric Phetteplace <phette23@gmail.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
db5f51e4ce
commit
ff82cd37f5
|
|
@ -269,7 +269,7 @@ Tests the connection of the harvester to the SUSHI service and returns any alert
|
|||
sub test_connection {
|
||||
my ($self) = @_;
|
||||
|
||||
my $url = _validate_url( $self->service_url, 'status' );
|
||||
my $url = $self->_validate_url( $self->service_url, 'status' );
|
||||
$url .= 'status';
|
||||
$url .= '?customer_id=' . $self->customer_id;
|
||||
$url .= '&requestor_id=' . $self->requestor_id if $self->requestor_id;
|
||||
|
|
@ -384,7 +384,7 @@ sub _build_url_query {
|
|||
$self->erm_usage_data_provider_id;
|
||||
}
|
||||
|
||||
my $url = _validate_url( $self->service_url, 'harvest' );
|
||||
my $url = $self->_validate_url( $self->service_url, 'harvest' );
|
||||
|
||||
$url .= lc $self->{report_type};
|
||||
$url .= '?customer_id=' . $self->customer_id;
|
||||
|
|
@ -401,22 +401,27 @@ sub _build_url_query {
|
|||
|
||||
Checks whether the url ends in a trailing "/" and adds one if not
|
||||
|
||||
my $url = _validate_url($url, 'harvest')
|
||||
my $url = $self->_validate_url($url, 'harvest')
|
||||
|
||||
$caller is either the harvest_sushi function ("harvest") or the test_connection function ("status")
|
||||
|
||||
=cut
|
||||
|
||||
sub _validate_url {
|
||||
my ( $url, $caller ) = @_;
|
||||
my ( $self, $url, $caller ) = @_;
|
||||
|
||||
if ( $caller eq 'harvest' ) {
|
||||
|
||||
# Not all urls will end in "/" - add one so they are standardised
|
||||
$url = _check_trailing_character($url);
|
||||
|
||||
# All SUSHI report requests should be to the "/reports" endpoint
|
||||
# Not all providers in the counter registry include this in their data so we need to check and add it
|
||||
# Default to 5.1 if anything other than '5'
|
||||
my $report_release = $self->report_release eq '5' ? $self->report_release : '5.1';
|
||||
|
||||
if ( $report_release eq '5.1' ) {
|
||||
my $reports_param = substr $url, -4;
|
||||
$url .= 'r51/' if $reports_param ne 'r51/';
|
||||
}
|
||||
|
||||
my $reports_param = substr $url, -8;
|
||||
$url .= 'reports/' if $reports_param ne 'reports/';
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -90,7 +90,15 @@ sub list {
|
|||
my @counter_5_supporting_platforms;
|
||||
foreach my $platform (@$result) {
|
||||
my $name_check = index( lc $platform->{name}, lc $search_string );
|
||||
my @services = grep { $_->{counter_release} eq '5' } @{ $platform->{sushi_services} };
|
||||
|
||||
# TODO:
|
||||
# We should also consider COUNTER 5.1 here, but the COUNTER registry response is not great.
|
||||
# Visit the following URL:
|
||||
# <staff_url>/api/v1/erm/counter_registry?_per_page=-1&q={"name":"wiley"}
|
||||
# Notice the response comes back as the only sushi service being counter release 5,
|
||||
# but for all supported reports, both '5' and '5.1' are returned.
|
||||
|
||||
my @services = grep { $_->{counter_release} eq '5' } @{ $platform->{sushi_services} };
|
||||
if ( scalar(@services) > 0
|
||||
&& $name_check != -1
|
||||
&& scalar( @{ $platform->{reports} } ) > 0 )
|
||||
|
|
|
|||
Loading…
Reference in New Issue