From 6f372ac976df83fc57c8864abf4d62a2f1107d02 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Sun, 24 Aug 2014 10:11:03 -0400 Subject: [PATCH] Change ILS->find_barcode to ILS->find_user_barcode. I anticipate that we'll need a separate method to find an item barcode. Also, we return the tag of the field where the barcode was in list context. We still return only the barcode in scalar context. Signed-off-by: Jason Stephenson --- lib/NCIP/ILS.pm | 18 ++++++++++++------ lib/NCIP/ILS/Evergreen.pm | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/NCIP/ILS.pm b/lib/NCIP/ILS.pm index e835573..a64414b 100644 --- a/lib/NCIP/ILS.pm +++ b/lib/NCIP/ILS.pm @@ -301,19 +301,23 @@ sub parse_request_type { =head2 find_barcode -Cfind_barcode($request);> +Cfind_user_barcode($request);> -If you have a request type that includes a barcode identifier value, -this routine will find it. It presently works only on LookupUser -requests. +If you have a request type that includes a user barcode identifier +value, this routine will find it. It presently works only on +LookupUser requests. + +It will return the barcode in scalar context, or the barcode and the +tag of the field where the barcode was found in list context. =cut -sub find_barcode { +sub find_user_barcode { my $self = shift; my $request = shift; my $barcode; + my $field; my $message = $self->parse_request_type($request); return unless($message); if ($message eq 'LookupUser') { @@ -326,6 +330,7 @@ sub find_barcode { foreach my $input (@$authinput) { if ($input->{AuthenticationInputType} =~ /barcode/i) { $barcode = $input->{AuthenticationInputData}; + $field = 'AuthenticationInputData'; last; } } @@ -338,13 +343,14 @@ sub find_barcode { foreach my $input (@$authinput) { if ($input->{UserIdentifierType} =~ /barcode/i) { $barcode = $input->{UserIdentifierValue}; + $field = 'UserIdentifierValue'; last; } } } } - return $barcode; + return (wantarray) ? ($barcode, $field) : $barcode; } 1; diff --git a/lib/NCIP/ILS/Evergreen.pm b/lib/NCIP/ILS/Evergreen.pm index 4fb15e8..a0a772d 100644 --- a/lib/NCIP/ILS/Evergreen.pm +++ b/lib/NCIP/ILS/Evergreen.pm @@ -109,7 +109,7 @@ sub lookupuser { # Need to parse the request object to get the barcode and other # data out. - my $barcode = $self->find_barcode($request); + my ($barcode, $idfield) = $self->find_user_barcode($request); # If we can't find a barcode, report a problem. unless ($barcode) { @@ -140,7 +140,7 @@ sub lookupuser { my $problem = NCIP::Problem->new(); $problem->ProblemType('Unknown User'); $problem->ProblemDetail("User with barcode $barcode unknown"); - $problem->ProblemElement('AuthenticationInputData'); + $problem->ProblemElement($idfield); $problem->ProblemValue($barcode); $response->problem($problem); return $response; -- 2.11.0