From 40fbedb60507e8963c378c782c828f59ef97600d Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Mon, 5 Oct 2015 14:41:44 -0400 Subject: [PATCH] Handle invalid agencies in NCIP::ILS::Evergreen. We modify NCIP::ILS::Evergreen->find_location_failover to return an undefined value in the event of failure to lookup an agency. We then modify the requestitem and cancelrequestitem handlers to return a Problem message if the lookup fails for their selection org. units. These appear to be the only two places possilby affected by a failure to find a location. Signed-off-by: Jason Stephenson --- lib/NCIP/ILS/Evergreen.pm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/NCIP/ILS/Evergreen.pm b/lib/NCIP/ILS/Evergreen.pm index fe2f83b..6ebeeec 100644 --- a/lib/NCIP/ILS/Evergreen.pm +++ b/lib/NCIP/ILS/Evergreen.pm @@ -984,6 +984,18 @@ sub requestitem { # to a given library. We look fo that in the AgencyId of the # BibliographRecordId or in the ToAgencyId of the main message. my $selection_ou = $self->find_location_failover($bibid->{AgencyId}, $request, $message); + unless ($selection_ou) { + $problem = NCIP::Problem->new( + { + ProblemType => 'Unknown Agency', + ProblemDetail => 'Agency is not known', + ProblemElement => 'BibliographicRecordIdentifier', + ProblemValue => $bibid->{AgencyId} || $request->{$message}->{InitiationHeader}->{ToAgencyId}->{AgencyId} + } + ); + $response->problem($problem); + return $response; + } # We need to see if the bib exists and has a holdable, not deleted # copy at the selection_ou. If successful, we retun a @@ -1115,6 +1127,19 @@ sub cancelrequestitem { my $idvalue = $item_id->{ItemIdentifierValue}; my $itemagy = $item_id->{AgencyId}; my $selection_ou = $self->find_location_failover($itemagy, $request, $message); + unless ($selection_ou) { + my $problem = NCIP::Problem->new( + { + ProblemType => 'Unknown Agency', + ProblemDetail => 'Agency is not known', + ProblemElement => 'AgencyId', + ProblemValue => $item_id->{AgencyId} || $request->{$message}->{InitiationHeader}->{ToAgencyId}->{AgencyId} + } + ); + $response->problem($problem); + return $response; + } + # We should support looking up holds by barcode, since we still # support placing them by barcode, but that is not how it is going # to work with Auto-Graphics, apparently. I'll leave the @@ -1878,6 +1903,11 @@ sub retrieve_org_unit_by_shortname { $shortname ); + # Check for failure from the above. + if (ref($aou) eq 'HASH') { + undef($aou); + } + # We want to retrieve the type and manually "flesh" the object. if ($aou) { my $type = $U->simplereq( -- 2.11.0