--- trunk/lib/WebPAC/Output/Estraier.pm 2005/12/05 17:47:04 210 +++ trunk/lib/WebPAC/Output/Estraier.pm 2005/12/05 17:47:16 212 @@ -8,7 +8,7 @@ use HyperEstraier; use Text::Iconv; use Data::Dumper; -use LWP::Simple; +use LWP; use URI::Escape; =head1 NAME @@ -17,11 +17,11 @@ =head1 VERSION -Version 0.02 +Version 0.03 =cut -our $VERSION = '0.02'; +our $VERSION = '0.03'; =head1 SYNOPSIS @@ -81,21 +81,22 @@ my $log = $self->_get_logger; - $log->debug("self: ", sub { Dumper($self) }); + #$log->debug("self: ", sub { Dumper($self) }); foreach my $p (qw/masterurl user passwd database/) { $log->logdie("need $p") unless ($self->{$p}); } my $url = $self->{masterurl} . '/node/' . $self->{database}; - $url =~ s#//#/#g; $self->{url} = $url; $log->info("opening Hyper Estraier index $self->{url}"); - my @nodes = $self->est_master( action => 'nodelist' ); + my $nodes = $self->est_master( action => 'nodelist' ); - if (! grep(/$self->{database}/, @nodes)) { + $log->debug("nodes found: $nodes"); + + if ($nodes !~ m/^$self->{database}\t/sm) { $log->info("creating index $url"); $self->est_master( action => 'nodeadd', @@ -125,13 +126,12 @@ id => 42, ds => $ds, type => 'display', - url_prefix => 'database name', text => 'optional text from which snippet is created', ); This function will create entries in index using following URI format: - C + C Each tag in C with specified C will create one attribute and corresponding hidden text (used for search). @@ -193,7 +193,7 @@ } $log->debug("adding ", sub { $doc->dump_draft } ); - $self->{'db'}->put_doc($doc) || $log->logdie("can't add document $uri to index"); + $self->{'db'}->put_doc($doc) || $log->logdie("can't add document $uri to node " . $self->{url} . " status: " . $self->{db}->status()); return 1; } @@ -234,14 +234,23 @@ $log->debug("calling $url"); - my $tsv = get($url); + if (! $self->{_master_ua}) { + $self->{_master_ua} = LWP::UserAgent->new( ) || $log->logdie("can't create LWP::UserAgent: $!"); + $self->{_master_ua}->credentials('localhost:1978','Super User', $self->{user} => $self->{passwd}); + } - if (! $tsv) { - $log->warn("unable to call $url"); + my $res = $self->{_master_ua}->get($url); + + if ($res->is_success) { + #$log->debug( $res->content ); + return split(/\n/, $res->content) if wantarray; + return $res->content; + } else { + $log->warn("unable to call $url: " . $res->status_line); + #$log->debug(Dumper($res, $self->{'_master_ua'})); return; } - return split(/\n/, $tsv); } =head1 AUTHOR