[Koha-cvs] CVS: koha/C4 Z3950.pm,1.1.2.4,1.1.2.5

Alan Millar amillar at users.sourceforge.net
Sat Jun 29 19:33:49 CEST 2002


Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv8440/C4

Modified Files:
      Tag: rel-1-2
	Z3950.pm 
Log Message:
Allow DEFAULT as input to addz3950search.
Check for existence of pid file (cat crashed otherwise).
Return error messages in addz3950search.

Index: Z3950.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Attic/Z3950.pm,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -r1.1.2.4 -r1.1.2.5
*** Z3950.pm	28 Jun 2002 18:07:27 -0000	1.1.2.4
--- Z3950.pm	29 Jun 2002 17:33:47 -0000	1.1.2.5
***************
*** 105,111 ****
  	$query,		# value to look up
  	$type,		# type of value ("isbn", "lccn", etc).
! 	$requestid,
  	@z3950list,	# list of z3950 servers to query
      )=@_;
  
      my (
--- 105,113 ----
  	$query,		# value to look up
  	$type,		# type of value ("isbn", "lccn", etc).
! 	$requestid,	# Unique value to prevent duplicate searches from multiple HTML form submits
  	@z3950list,	# list of z3950 servers to query
      )=@_;
+     # Returns:
+     my $error;
  
      my (
***************
*** 114,119 ****
--- 116,126 ----
  	$server,
  	$failed,
+ 	$servername,
      );
+ 
+     my $pidfile='/var/log/koha/processz3950queue.pid';
      
+     $error="";
+ 
      requireDBI($dbh,"addz3950queue");
  
***************
*** 121,131 ****
          #   or simply just a server ID number.
  
-         $sth=$dbh->prepare("select host,port,db,userid,password 
- 	  from z3950servers 
- 	  where id=? ");
          foreach $server (@z3950list) {
  	    if ($server =~ /:/ ) {
  		push @serverlist, $server;
  	    } else {
  		$sth->execute($server);
  		my ($host, $port, $db, $userid, $password) = $sth->fetchrow;
--- 128,147 ----
          #   or simply just a server ID number.
  
          foreach $server (@z3950list) {
  	    if ($server =~ /:/ ) {
  		push @serverlist, $server;
+ 	    } elsif ($server eq 'DEFAULT' || $server eq 'CHECKED' ) {
+                 $sth=$dbh->prepare("select host,port,db,userid,password ,name
+ 	          from z3950servers 
+ 	          where checked <> 0 ");
+ 		$sth->execute;
+ 		while ( my ($host, $port, $db, $userid, $password,$servername) 
+ 			= $sth->fetchrow ) {
+ 		    push @serverlist, "$servername/$host\:$port/$db/$userid/$password";
+ 		} # while
  	    } else {
+                 $sth=$dbh->prepare("select host,port,db,userid,password
+ 	          from z3950servers 
+ 	          where id=? ");
  		$sth->execute($server);
  		my ($host, $port, $db, $userid, $password) = $sth->fetchrow;
***************
*** 140,163 ****
  	chop $serverlist;
  
! 	# Don't allow reinsertion of the same request number.
! 	$sth=$dbh->prepare("select identifier from z3950queue 
  		where identifier=?");
! 	$sth->execute($requestid);
! 	unless ($sth->rows) {
! 	    $sth=$dbh->prepare("insert into z3950queue 
! 		(term,type,servers, identifier) 
! 		values (?, ?, ?, ?)");
! 	    $sth->execute($query, $type, $serverlist, $requestid);
! 	    my $pid=`cat /var/log/koha/processz3950queue.pid`;
! 	    chomp $pid;
! 	    my $processcount=kill 1, $pid;
! 	    if ($processcount==0) {
! 		return 1;
! 	    }
! 	}
  } # sub addz3950queue
  
  #--------------------------------------
  # $Log$
  # Revision 1.1.2.4  2002/06/28 18:07:27  tonnesen
  # marcimport.pl will print an error message if it can not signal the
--- 156,198 ----
  	chop $serverlist;
  
! 	if ( $serverlist !~ /^ +$/ ) {
! 	    # Don't allow reinsertion of the same request identifier.
! 	    $sth=$dbh->prepare("select identifier from z3950queue 
  		where identifier=?");
! 	    $sth->execute($requestid);
! 	    if ( ! $sth->rows) {
! 	        $sth=$dbh->prepare("insert into z3950queue 
! 		    (term,type,servers, identifier) 
! 		    values (?, ?, ?, ?)");
! 	        $sth->execute($query, $type, $serverlist, $requestid);
! 		if ( -r $pidfile ) { 
! 	            my $pid=`cat $pidfile`;
! 	            chomp $pid;
! 	            my $processcount=kill 1, $pid;
! 	            if ($processcount==0) {
! 		        $error.="Z39.50 search daemon error: no process signalled. ";
! 	            }
! 		} else {
! 		    $error.="No Z39.50 search daemon running: no file $pidfile. ";
! 		} # if $pidfile
! 	    } else {
! 	        $error.="Duplicate request ID $requestid. ";
! 	    } # if rows
! 	} else {
! 	    # server list is empty
! 	    $error.="No Z39.50 search servers specified. ";
! 	} # if serverlist empty
! 	
! 	return $error;
! 
  } # sub addz3950queue
  
  #--------------------------------------
  # $Log$
+ # Revision 1.1.2.5  2002/06/29 17:33:47  amillar
+ # Allow DEFAULT as input to addz3950search.
+ # Check for existence of pid file (cat crashed otherwise).
+ # Return error messages in addz3950search.
+ #
  # Revision 1.1.2.4  2002/06/28 18:07:27  tonnesen
  # marcimport.pl will print an error message if it can not signal the





More information about the Koha-cvs mailing list