[Patches] [PATCH] Fix for Bug 7148 - Add some error handling to Acquisitions'
koha-patchbot at kohaaloha.com
koha-patchbot at kohaaloha.com
Wed Dec 21 03:12:41 NZDT 2011
From: Owen Leonard <oleonard at myacpl.org>
Date: Thu, 3 Nov 2011 10:22:11 -0400
Subject: [PATCH] Fix for Bug 7148 - Add some error handling to Acquisitions'
Z39.50 search to match Cataloging's
- Copying over error handling for timeout(10007) and refused(10000)
- Copying over error handling for submission with no targets chosen
- Correcting "cancel" link in the template which was not modified
when it was copied from cataloging's popup window template.
Signed-off-by: Chris Cormack <chrisc at catalyst.net.nz>
---
acqui/z3950_search.pl | 33 +++++++++++---------
.../prog/en/modules/acqui/z3950_search.tt | 9 +++++-
2 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/acqui/z3950_search.pl b/acqui/z3950_search.pl
index 47dbe52..80503e0 100755
--- a/acqui/z3950_search.pl
+++ b/acqui/z3950_search.pl
@@ -134,8 +134,17 @@ if ( $op ne "do_search" ) {
}
else {
my @id = $input->param('id');
+
+ if ( not defined @id ) {
+ # empty server list -> report and exit
+ $template->param( emptyserverlist => 1 );
+ output_html_with_http_headers $input, $cookie, $template->output;
+ exit;
+ }
+
my @oConnection;
my @oResult;
+ my @errconn;
my $s = 0;
my $query;
my $nterms;
@@ -164,7 +173,7 @@ else {
$query .= " \@attr 1=21 \"$subject\" ";
$nterms++;
}
- if ($lccn) {
+ if ($lccn) {
$query .= " \@attr 1=9 $lccn ";
$nterms++;
}
@@ -186,7 +195,6 @@ warn "query ".$query if $DEBUG;
$sth->execute($servid);
while ( $server = $sth->fetchrow_hashref ) {
warn "serverinfo ".join(':',%$server) if $DEBUG;
- my $noconnection = 0;
my $option1 = new ZOOM::Options();
$option1->option( 'async' => 1 );
$option1->option( 'elementSetName', 'F' );
@@ -237,9 +245,10 @@ sub displayresults {
my ( $error, $errmsg, $addinfo, $diagset ) =
$oConnection[$k]->error_x();
if ($error) {
- warn "$k $serverhost[$k] error $query: $errmsg ($error) $addinfo\n"
- if $DEBUG;
-
+ if ($error =~ m/^(10000|10007)$/ ) {
+ push(@errconn, {'server' => $serverhost[$k]});
+ }
+ $DEBUG and warn "$k $serverhost[$k] error $query: $errmsg ($error) $addinfo\n";
}
else {
my $numresults = $oResult[$k]->size();
@@ -280,13 +289,6 @@ sub displayresults {
)
= ImportBreeding( $marcdata, 2, $serverhost[$k], $encoding[$k], $random, 'z3950' );
my %row_data;
- if ( $i % 2 ) {
- $toggle = 1;
- }
- else {
- $toggle = 0;
- }
- $row_data{toggle} = $toggle;
$row_data{server} = $servername[$k];
$row_data{isbn} = $oldbiblio->{isbn};
$row_data{lccn} = $oldbiblio->{lccn};
@@ -295,9 +297,9 @@ sub displayresults {
$row_data{breedingid} = $breedingid;
$row_data{biblionumber} = $biblionumber;
push( @breeding_loop, \%row_data );
-
+
} else {
- push(@breeding_loop,{'toggle'=>($i % 2)?1:0,'server'=>$servername[$k],'title'=>join(': ',$oConnection[$k]->error_x()),'breedingid'=>-1,'biblionumber'=>-1});
+ push(@breeding_loop,{'server'=>$servername[$k],'title'=>join(': ',$oConnection[$k]->error_x()),'breedingid'=>-1,'biblionumber'=>-1});
} # $rec
} # upto 5 results
} #$numresults
@@ -308,10 +310,11 @@ sub displayresults {
breeding_loop => \@breeding_loop,
server => $servername[$k],
numberpending => $numberpending,
+ errconn => \@errconn
);
output_html_with_http_headers $input, $cookie, $template->output if $numberpending == 0;
- # print $template->output if $firstresult !=1;
+ # print $template->output if $firstresult !=1;
$firstresult++;
}
displayresults();
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt
index 66dbc6e..1f2ad60 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt
@@ -120,7 +120,7 @@ tr.selected { background-color : #FFFFCC; } tr.selected td { background-color :
</p>
[% END %]
- <fieldset class="action"><input type="submit" class="submit" value="Search" onclick="cursor :'wait'"/> <a class="cancel close" href="#">Cancel</a></fieldset>
+ <fieldset class="action"><input type="submit" class="submit" value="Search" onclick="cursor :'wait'"/> <a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?booksellerid=[% booksellerid %]&basketno=[% basketno %]">Cancel</a></fieldset>
</div>
</form>
@@ -155,6 +155,13 @@ tr.selected { background-color : #FFFFCC; } tr.selected td { background-color :
[% END %]</tbody>
</table>
[% ELSE %]
+ [% IF ( emptyserverlist ) %]
+ You didn't select any Z39.50 target.
+ [% ELSE %]
+ [% FOREACH errcon IN errconn %]
+ Connection failed to [% errcon.server %]
+ [% END %]
+ [% END %]
<p>Nothing found. <a href="javascript: history.back()">Try another search</a>.</p>
[% END %]
--
1.7.5.4
More information about the Patches
mailing list