8 |
use HyperEstraier; |
use HyperEstraier; |
9 |
use Text::Iconv; |
use Text::Iconv; |
10 |
use Data::Dumper; |
use Data::Dumper; |
11 |
use LWP::Simple; |
use LWP; |
12 |
use URI::Escape; |
use URI::Escape; |
13 |
|
|
14 |
=head1 NAME |
=head1 NAME |
17 |
|
|
18 |
=head1 VERSION |
=head1 VERSION |
19 |
|
|
20 |
Version 0.02 |
Version 0.03 |
21 |
|
|
22 |
=cut |
=cut |
23 |
|
|
24 |
our $VERSION = '0.02'; |
our $VERSION = '0.03'; |
25 |
|
|
26 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
27 |
|
|
81 |
|
|
82 |
my $log = $self->_get_logger; |
my $log = $self->_get_logger; |
83 |
|
|
84 |
$log->debug("self: ", sub { Dumper($self) }); |
#$log->debug("self: ", sub { Dumper($self) }); |
85 |
|
|
86 |
foreach my $p (qw/masterurl user passwd database/) { |
foreach my $p (qw/masterurl user passwd database/) { |
87 |
$log->logdie("need $p") unless ($self->{$p}); |
$log->logdie("need $p") unless ($self->{$p}); |
93 |
|
|
94 |
$log->info("opening Hyper Estraier index $self->{url}"); |
$log->info("opening Hyper Estraier index $self->{url}"); |
95 |
|
|
96 |
my @nodes = $self->est_master( action => 'nodelist' ); |
my $nodes = $self->est_master( action => 'nodelist' ); |
97 |
|
|
98 |
if (! grep(/$self->{database}/, @nodes)) { |
$log->debug("nodes found: $nodes"); |
99 |
|
|
100 |
|
if ($nodes !~ m/^$self->{database}\t/sm) { |
101 |
$log->info("creating index $url"); |
$log->info("creating index $url"); |
102 |
$self->est_master( |
$self->est_master( |
103 |
action => 'nodeadd', |
action => 'nodeadd', |
236 |
|
|
237 |
$log->debug("calling $url"); |
$log->debug("calling $url"); |
238 |
|
|
239 |
my $tsv = get($url); |
if (! $self->{_master_ua}) { |
240 |
|
$self->{_master_ua} = LWP::UserAgent->new( ) || $log->logdie("can't create LWP::UserAgent: $!"); |
241 |
|
$self->{_master_ua}->credentials('localhost:1978','Super User', $self->{user} => $self->{passwd}); |
242 |
|
} |
243 |
|
|
244 |
if (! $tsv) { |
my $res = $self->{_master_ua}->get($url); |
245 |
$log->warn("unable to call $url"); |
|
246 |
|
if ($res->is_success) { |
247 |
|
#$log->debug( $res->content ); |
248 |
|
return split(/\n/, $res->content) if wantarray; |
249 |
|
return $res->content; |
250 |
|
} else { |
251 |
|
$log->warn("unable to call $url: " . $res->status_line); |
252 |
|
#$log->debug(Dumper($res, $self->{'_master_ua'})); |
253 |
return; |
return; |
254 |
} |
} |
255 |
|
|
|
return split(/\n/, $tsv); |
|
256 |
} |
} |
257 |
|
|
258 |
=head1 AUTHOR |
=head1 AUTHOR |