test both providers
[Biblio-Z3950.git] / server.pl
index 8d7c60d..947e8ba 100755 (executable)
--- a/server.pl
+++ b/server.pl
@@ -7,6 +7,7 @@ use Net::Z3950::SimpleServer;
 use Net::Z3950::OID;
 use Data::Dumper;
 use COBISS;
+use Aleph;
 
 my $databases = {
        'COBISS' => 'COBISS',
@@ -41,8 +42,14 @@ diag "SearchHandle ",Dumper($this);
     my $rpn     = $this->{RPN};
     my $query;
 
-       my $database = $this->{DATABASES}->[0];
-       my $module   = $databases->{$database} || 'COBISS';
+       my $database = uc $this->{DATABASES}->[0];
+       my $module = $databases->{$database};
+       if ( ! defined $module ) {
+        $this->{ERR_CODE} = 108;
+               warn $this->{ERR_STR} = "unknown database $database - available: " . keys %$databases;
+               return;
+       }
+
        my $from = $module->new;
 
 diag "using $module for $database ", Dumper( $from );