From 27c75bab7f48ec87fef2b335dbc93ef72954db7a Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 29 Dec 2005 19:15:43 +0000 Subject: [PATCH] added content methods return empty sets unless the content server info is properly defined currently, empty sets will simply not show up in the db git-svn-id: svn://svn.open-ils.org/ILS/trunk@2549 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../Application/Search/AddedContent.pm | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/AddedContent.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/AddedContent.pm index c5a263fc2b..75981a3420 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/AddedContent.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/AddedContent.pm @@ -8,10 +8,10 @@ use XML::LibXML; use LWP::UserAgent; use OpenSRF::EX qw(:try); - my $host; my $username; my $password; +my $enabled = 0; my $urlbase = "ContentCafe"; my $types = { toc => "TOC.asmx", @@ -28,6 +28,8 @@ sub initialize { "apps", "open-ils.search","app_settings", "added_content", "username"); $password = $conf->config_value( "apps", "open-ils.search","app_settings", "added_content", "password"); + + $enabled = 1 if ($host and $username and $password); } @@ -57,7 +59,7 @@ sub retrieve_added_content { }; alarm(0); - warn "received content data:\n$data\n"; +# warn "received content data:\n$data\n"; return $data; } @@ -80,6 +82,18 @@ __PACKAGE__->register_method( sub summary { my( $self, $client, $isbn ) = @_; + + if(!$enabled) { + return { + Review => "false", + Inventory => "false", + Annotation => "false", + Jacket => "false", + TOC => "false", + Product => "false", + }; + } + my $data = retrieve_added_content( "member", $isbn, 1 ); return {} unless $data; my $doc = XML::LibXML->new->parse_string($data); @@ -117,10 +131,12 @@ __PACKAGE__->register_method( sub reviews { my( $self, $client, $isbn ) = @_; + my $ret = []; + return $ret unless $enabled; my $data = retrieve_added_content( "review", $isbn ); - return undef unless $data; + return $ret unless $data; my $doc = XML::LibXML->new->parse_string($data); - my $ret = []; + if(!$doc) { if( $self->api_name =~ /random/ ) { return undef; } -- 2.43.2