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@catalyst.net.nz>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
This commit is contained in:
Owen Leonard 2011-11-03 10:22:11 -04:00 committed by Paul Poulain
parent abdef00248
commit 952bfc6f07
2 changed files with 26 additions and 16 deletions

View File

@ -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();

View File

@ -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 %]&amp;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 %]