From 08962b6b5bacc40b211a0d825376ca170f713b20 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Sun, 28 Sep 2014 10:29:39 -0400 Subject: [PATCH] Alter NCIP::ILS::Evergreen->_hold_search() to do just one thing. Remove the code that had it return a problem if no holds were found and make it the caller's responsibility to check if a hold was returned or nothing. Signed-off-by: Jason Stephenson --- lib/NCIP/ILS/Evergreen.pm | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/lib/NCIP/ILS/Evergreen.pm b/lib/NCIP/ILS/Evergreen.pm index 2623fdf..8a4abed 100644 --- a/lib/NCIP/ILS/Evergreen.pm +++ b/lib/NCIP/ILS/Evergreen.pm @@ -1290,9 +1290,7 @@ sub cancelrequestitem { # the user. We'll need to search for copy (or force) holds, a # volume hold, or a title hold. $hold = $self->_hold_search($user, $copy_details); - if (ref($hold) eq 'NCIP::Problem') { - $response->problem($hold); - } elsif ($hold->transit()) { + if ($hold && $hold->transit()) { $response->problem( NCIP::Problem->new( { @@ -1303,7 +1301,7 @@ sub cancelrequestitem { } ) ) - } else { + } elsif ($hold) { $self->cancel_hold($hold); $response->data( { @@ -1321,6 +1319,17 @@ sub cancelrequestitem { ) } ) + } else { + $response->problem( + NCIP::Problem->new( + { + ProblemType => 'Unknown Request', + ProblemDetail => 'No request found for the item and user', + ProblemElement => 'NULL', + ProblemValue => 'NULL' + } + ) + ) } } } @@ -2547,8 +2556,7 @@ sub _hold_search { my $hold; - # Retrieve all of the user's uncanceled, unfulfilled holds, and - # then search them in Perl. + # Retrieve all of the user's active holds, and then search them in Perl. my $holds_list = $U->simplereq( 'open-ils.circ', 'open-ils.circ.holds.retrieve', @@ -2578,17 +2586,6 @@ sub _hold_search { } } - unless ($hold) { - $hold = NCIP::Problem->new( - { - ProblemType => 'Unknown Request', - ProblemDetail => 'Request matching the user and item not found.', - ProblemElement => 'NULL', - ProblemValue => 'NULL' - } - ) - } - return $hold; } -- 2.43.2