From 74f7b26d1bc269ace27d6a8a5e2f81b288d78c17 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 27 Apr 2011 12:14:00 -0400 Subject: [PATCH] push full set of isbns and upcs down to handler code --- .../src/perlmods/lib/OpenILS/WWW/AddedContent.pm | 46 ++++++++++++---------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm index 5e9c2bf352..6d94135db6 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm @@ -97,27 +97,31 @@ sub handler { return $res if defined($res = $AC->serve_from_cache($type, $format, $id)); return Apache2::Const::NOT_FOUND unless $AC->lookups_enabled; - my $keys = get_rec_keys($id); - my @isbns = grep { $_->{tag} eq '020' } @$keys; - my @upcs = grep { $_->{tag} eq '024' } @$keys; - - for my $key (@isbns, @upcs) { - - my $key_type = $key->{tag}; - my $key_value = $key->{value}; - $logger->info("AC: trying key $key_value : $key_type"); - - try { - $data = $handler->$method($key_value, $key_type); - } catch Error with { - $err = shift; - decr_error_countdown(); - $logger->debug("added content handler failed: $method($id) => $err"); - }; - - return Apache2::Const::NOT_FOUND if $err; - next unless $data; - } + my $key_data = get_rec_keys($id); + my @isbns = grep {$_->{tag} eq '020'} @$key_data; + my @upcs = grep {$_->{tag} eq '024'} @$key_data; + + my $keys = { + isbn => [map {$_->{value}} @isbns], + upc => [map {$_->{value}} @upcs] + }; + + # TODO clean isbn + + # XXX DEBUG + use OpenSRF::Utils::JSON; + $logger->info("Added Content Keys: " . OpenSRF::Utils::JSON->perl2JSON($keys)); + + try { + $data = $handler->$method($keys); + } catch Error with { + $err = shift; + decr_error_countdown(); + $logger->debug("added content handler failed: $method($id) => $err"); + }; + + return Apache2::Const::NOT_FOUND if $err; + next unless $data; if(!$data) { # if the AC lookup found no corresponding data, cache that information -- 2.11.0