17 |
|
|
18 |
=head1 VERSION |
=head1 VERSION |
19 |
|
|
20 |
Version 0.03 |
Version 0.04 |
21 |
|
|
22 |
=cut |
=cut |
23 |
|
|
24 |
our $VERSION = '0.03'; |
our $VERSION = '0.04'; |
25 |
|
|
26 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
27 |
|
|
153 |
} |
} |
154 |
|
|
155 |
my $type = $args->{'type'}; |
my $type = $args->{'type'}; |
156 |
my $mfn = $args->{'id'}; |
my $id = $args->{'id'}; |
157 |
|
|
158 |
my $uri = "file:///$type/$database/$mfn"; |
my $uri = "file:///$type/$database/$id"; |
159 |
$log->debug("creating $uri"); |
$log->debug("creating $uri"); |
160 |
|
|
161 |
my $doc = HyperEstraier::Document->new; |
my $doc = HyperEstraier::Document->new; |
214 |
nodedel => [ qw/name/ ], |
nodedel => [ qw/name/ ], |
215 |
}; |
}; |
216 |
|
|
217 |
|
=head2 est_ua |
218 |
|
|
219 |
|
Make C<LWP::UserAgent> object with Super User priviledges |
220 |
|
|
221 |
|
my $ua = $self->est_ua( user => 'admin', passwd => 'admin' ); |
222 |
|
|
223 |
|
=cut |
224 |
|
|
225 |
|
sub est_ua { |
226 |
|
my $self = shift; |
227 |
|
|
228 |
|
return $self->{_master_ua} if ($self->{_master_ua}); |
229 |
|
|
230 |
|
$self->{_master_ua} = LWP::UserAgent->new( ) || sub { |
231 |
|
my $log = $self->_get_logger; |
232 |
|
$log->logdie("can't create LWP::UserAgent: $!"); |
233 |
|
}; |
234 |
|
|
235 |
|
$self->{_master_ua}->credentials('localhost:1978','Super User', $self->{user} => $self->{passwd}); |
236 |
|
|
237 |
|
return $self->{_master_ua}; |
238 |
|
} |
239 |
|
|
240 |
sub est_master { |
sub est_master { |
241 |
my $self = shift; |
my $self = shift; |
242 |
my $args = {@_}; |
my $args = {@_}; |
257 |
|
|
258 |
$log->debug("calling $url"); |
$log->debug("calling $url"); |
259 |
|
|
260 |
if (! $self->{_master_ua}) { |
my $res = $self->est_ua()->get($url); |
|
$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}); |
|
|
} |
|
|
|
|
|
my $res = $self->{_master_ua}->get($url); |
|
261 |
|
|
262 |
if ($res->is_success) { |
if ($res->is_success) { |
263 |
#$log->debug( $res->content ); |
#$log->debug( $res->content ); |
265 |
return $res->content; |
return $res->content; |
266 |
} else { |
} else { |
267 |
$log->warn("unable to call $url: " . $res->status_line); |
$log->warn("unable to call $url: " . $res->status_line); |
|
#$log->debug(Dumper($res, $self->{'_master_ua'})); |
|
268 |
return; |
return; |
269 |
} |
} |
270 |
|
|