1 |
+ |
# |
2 |
+ |
# Easy Setup of cache etc for ActiveDoc enactivation |
3 |
+ |
# |
4 |
+ |
# Author : C.Williams |
5 |
+ |
# |
6 |
+ |
# Interface |
7 |
+ |
# --------- |
8 |
+ |
# new(location) : Create a new activeation area at location |
9 |
+ |
# activatedoc($url) : Return the object corresponding to the activedoc |
10 |
+ |
# provided by the url |
11 |
+ |
# get(url) : download url and return the filename |
12 |
+ |
# of the processed doc |
13 |
+ |
|
14 |
+ |
package ActiveDoc::Activate; |
15 |
+ |
use ActiveDoc::ActiveDoc; |
16 |
+ |
use ActiveDoc::ActiveStore; |
17 |
+ |
use Utilities::Verbose; |
18 |
+ |
|
19 |
+ |
@ISA=qw(Utilities::Verbose); |
20 |
+ |
|
21 |
+ |
|
22 |
+ |
sub new { |
23 |
+ |
my $class=shift; |
24 |
+ |
my $self={}; |
25 |
+ |
bless $self, $class; |
26 |
+ |
|
27 |
+ |
# -- initiate cgi work area |
28 |
+ |
$self->{workarea}=shift; |
29 |
+ |
$self->_initarea($self->{workarea}); |
30 |
+ |
return $self; |
31 |
+ |
} |
32 |
+ |
|
33 |
+ |
sub _initarea { |
34 |
+ |
my $self=shift; |
35 |
+ |
my $dir=shift; |
36 |
+ |
$self->{dbstore}=ActiveDoc::ActiveStore->new($dir); |
37 |
+ |
$self->{ad}=ActiveDoc::ActiveDoc->new($self->{dbstore}); |
38 |
+ |
} |
39 |
+ |
|
40 |
+ |
sub get { |
41 |
+ |
my $self=shift; |
42 |
+ |
my $url=shift; |
43 |
+ |
$self->verbose("Attempt to get $url"); |
44 |
+ |
my $file; |
45 |
+ |
# We dont want it messaging |
46 |
+ |
if ( eval { $file=$self->{ad}->getfile($url)->ProcessedFile() } ) { |
47 |
+ |
return ($file, $@); |
48 |
+ |
} |
49 |
+ |
else { |
50 |
+ |
return (undef, $@); |
51 |
+ |
} |
52 |
+ |
} |
53 |
+ |
|
54 |
+ |
sub activatedoc { |
55 |
+ |
my $self=shift; |
56 |
+ |
my $url=shift; |
57 |
+ |
|
58 |
+ |
my $obj; |
59 |
+ |
$self->verbose("Attempting activation of $url"); |
60 |
+ |
if ( eval { $obj=$self->{ad}->activatedoc($url) } ) { |
61 |
+ |
return ($obj, $@); |
62 |
+ |
} |
63 |
+ |
else { |
64 |
+ |
return (undef, $@); |
65 |
+ |
} |
66 |
+ |
} |