From f458e79f3d6c1d878d59653a702f3d10b87c455f Mon Sep 17 00:00:00 2001 From: dbs Date: Tue, 8 Mar 2011 22:01:10 +0000 Subject: [PATCH] Be more defensive when parsing SFX target results SFX in the wild has been observed returning targets for getFullTxt requests that have no target URLs, which makes it rather impossible to provide a link to the full text resource. Skip such targets (and for good measure, skip them if they don't have a name either). Also, change from the SID "conifer" to the more generic and accurate "evergreen". git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_2_1@19647 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../lib/OpenILS/Application/ResolverResolver.pm | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/ResolverResolver.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/ResolverResolver.pm index 3463c1e9ef..4d852145e9 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/ResolverResolver.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/ResolverResolver.pm @@ -123,7 +123,7 @@ sub resolve_holdings { # Big ugly SFX OpenURL request my $url_args = '?url_ver=Z39.88-2004&url_ctx_fmt=infofi/fmt:kev:mtx:ctx&' - . 'ctx_enc=UTF-8&ctx_ver=Z39.88-2004&rfr_id=info:sid/conifer&' + . 'ctx_enc=UTF-8&ctx_ver=Z39.88-2004&rfr_id=info:sid/evergreen&' . 'sfx.ignore_date_threshold=1&' . 'sfx.response_type=multi_obj_detailed_xml&__service_type=getFullTxt'; @@ -158,19 +158,27 @@ sub resolve_holdings { my @sfx_result; foreach my $target (@targets) { + my %full_txt; + + # Ensure we have a name and especially URL to return + $full_txt{'name'} = $target->findvalue('./target_public_name') || next; + $full_txt{'url'} = $target->findvalue('.//target_url') || next; + $full_txt{'coverage'} = $target->findvalue('.//coverage_statement') || ''; + $full_txt{'embargo'} = $target->findvalue('.//embargo_statement') || ''; + if ($format eq 'raw') { push @sfx_result, { - public_name => $target->findvalue('./target_public_name'), - target_url => $target->findvalue('.//target_url'), - target_coverage => $target->findvalue('.//coverage_statement'), - target_embargo => $target->findvalue('.//embargo_statement'), + public_name => $full_txt{'name'}, + target_url => $full_txt{'url'}, + target_coverage => $full_txt{'coverage'}, + target_embargo => $full_txt{'embargo'}, }; } else { my $rhr = Fieldmapper::resolver::holdings_record->new; - $rhr->public_name($target->findvalue('./target_public_name')); - $rhr->target_url($target->findvalue('.//target_url')); - $rhr->target_coverage($target->findvalue('.//coverage_statement')); - $rhr->target_embargo($target->findvalue('.//embargo_statement')); + $rhr->public_name($full_txt{'name'}); + $rhr->target_url($full_txt{'url'}); + $rhr->target_coverage($full_txt{'coverage'}); + $rhr->target_embargo($full_txt{'embargo'}); push @sfx_result, $rhr; } } -- 2.11.0