View | Details | Raw Unified | Return to bug 9612
Collapse All | Expand All

(-)a/C4/Context.pm (-18 / +12 lines)
Lines 689-694 C<$auth> whether this connection has rw access (1) or just r access (0 or NULL) Link Here
689
689
690
sub Zconn {
690
sub Zconn {
691
    my ($self, $server, $async, $auth, $piggyback, $syntax) = @_;
691
    my ($self, $server, $async, $auth, $piggyback, $syntax) = @_;
692
    #TODO: We actually just ignore the auth and syntax parameter
693
    #It also looks like we are not passing auth, piggyback, syntax anywhere
692
694
693
    my $cache_key = join ('::', (map { $_ // '' } ($server, $async, $auth, $piggyback, $syntax)));
695
    my $cache_key = join ('::', (map { $_ // '' } ($server, $async, $auth, $piggyback, $syntax)));
694
    if ( defined($context->{"Zconn"}->{$cache_key}) && (0 == $context->{"Zconn"}->{$cache_key}->errcode()) ) {
696
    if ( defined($context->{"Zconn"}->{$cache_key}) && (0 == $context->{"Zconn"}->{$cache_key}->errcode()) ) {
Lines 703-709 sub Zconn { Link Here
703
        # the basic health of a ZOOM::Connection
705
        # the basic health of a ZOOM::Connection
704
        $context->{"Zconn"}->{$cache_key}->destroy() if defined($context->{"Zconn"}->{$cache_key});
706
        $context->{"Zconn"}->{$cache_key}->destroy() if defined($context->{"Zconn"}->{$cache_key});
705
707
706
        $context->{"Zconn"}->{$cache_key} = &_new_Zconn($server,$async,$auth,$piggyback,$syntax);
708
        $context->{"Zconn"}->{$cache_key} = &_new_Zconn( $server, $async, $piggyback );
707
        return $context->{"Zconn"}->{$cache_key};
709
        return $context->{"Zconn"}->{$cache_key};
708
    }
710
    }
709
}
711
}
Lines 723-737 C<$auth> whether this connection has rw access (1) or just r access (0 or NULL) Link Here
723
=cut
725
=cut
724
726
725
sub _new_Zconn {
727
sub _new_Zconn {
726
    my ($server,$async,$auth,$piggyback,$syntax) = @_;
728
    my ( $server, $async, $piggyback ) = @_;
727
729
728
    my $tried=0; # first attempt
730
    my $tried=0; # first attempt
729
    my $Zconn; # connection object
731
    my $Zconn; # connection object
730
    my $elementSetName;
732
    my $elementSetName;
731
    my $index_mode;
733
    my $index_mode;
734
    my $syntax;
732
735
733
    $server //= "biblioserver";
736
    $server //= "biblioserver";
734
    $syntax //= "XML";
735
737
736
    if ( $server eq 'biblioserver' ) {
738
    if ( $server eq 'biblioserver' ) {
737
        $index_mode = $context->{'config'}->{'zebra_bib_index_mode'} // 'grs1';
739
        $index_mode = $context->{'config'}->{'zebra_bib_index_mode'} // 'grs1';
Lines 740-775 sub _new_Zconn { Link Here
740
    }
742
    }
741
743
742
    if ( $index_mode eq 'grs1' ) {
744
    if ( $index_mode eq 'grs1' ) {
743
744
        $elementSetName = 'F';
745
        $elementSetName = 'F';
745
        $syntax = ( $context->preference("marcflavour") eq 'UNIMARC' )
746
        $syntax = ( $context->preference("marcflavour") eq 'UNIMARC' )
746
                ? 'unimarc'
747
                ? 'unimarc'
747
                : 'usmarc';
748
                : 'usmarc';
748
749
749
    } else {
750
    } else { # $index_mode eq 'dom'
750
751
        #we do not need an elementSetName
751
        $elementSetName = 'marcxml';
752
        $syntax = 'xml';
752
        $syntax = 'XML';
753
    }
753
    }
754
754
755
    my $host = $context->{'listen'}->{$server}->{'content'};
755
    my $host = $context->{'listen'}->{$server}->{'content'};
756
    my $servername = $context->{"config"}->{$server};
757
    my $user = $context->{"serverinfo"}->{$server}->{"user"};
756
    my $user = $context->{"serverinfo"}->{$server}->{"user"};
758
    my $password = $context->{"serverinfo"}->{$server}->{"password"};
757
    my $password = $context->{"serverinfo"}->{$server}->{"password"};
759
    $auth = 1 if($user && $password);
760
    retry:
761
    eval {
758
    eval {
762
        # set options
759
        # set options
763
        my $o = new ZOOM::Options();
760
        my $o = new ZOOM::Options();
764
        $o->option(user=>$user) if $auth;
761
        $o->option(user => $user) if $user && $password;
765
        $o->option(password=>$password) if $auth;
762
        $o->option(password => $password) if $user && $password;
766
        $o->option(async => 1) if $async;
763
        $o->option(async => 1) if $async;
767
        $o->option(count => $piggyback) if $piggyback;
764
        $o->option(count => $piggyback) if $piggyback;
768
        $o->option(cqlfile=> $context->{"server"}->{$server}->{"cql2rpn"});
765
        $o->option(cqlfile=> $context->{"server"}->{$server}->{"cql2rpn"});
769
        $o->option(cclfile=> $context->{"serverinfo"}->{$server}->{"ccl2rpn"});
766
        $o->option(cclfile=> $context->{"serverinfo"}->{$server}->{"ccl2rpn"});
770
        $o->option(preferredRecordSyntax => $syntax);
767
        $o->option(preferredRecordSyntax => $syntax);
771
        $o->option(elementSetName => $elementSetName);
768
        $o->option(elementSetName => $elementSetName) if $elementSetName;
772
        $o->option(databaseName => ($servername?$servername:"biblios"));
769
        $o->option(databaseName => $context->{"config"}->{$server}||"biblios");
773
770
774
        # create a new connection object
771
        # create a new connection object
775
        $Zconn= create ZOOM::Connection($o);
772
        $Zconn= create ZOOM::Connection($o);
Lines 781-789 sub _new_Zconn { Link Here
781
        if ($Zconn->errcode() !=0) {
778
        if ($Zconn->errcode() !=0) {
782
            warn "something wrong with the connection: ". $Zconn->errmsg();
779
            warn "something wrong with the connection: ". $Zconn->errmsg();
783
        }
780
        }
784
785
    };
781
    };
786
787
    return $Zconn;
782
    return $Zconn;
788
}
783
}
789
784
790
- 

Return to bug 9612