ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/ActiveDoc/Activate.pm
Revision: 1.3
Committed: Tue Nov 14 15:19:42 2000 UTC (24 years, 6 months ago) by williamc
Content type: text/plain
Branch: MAIN
CVS Tags: v102p1, V1_0_1, V1_0_0, V1_pre0, SCRAM_V1, SCRAMV1_IMPORT, V0_19_7, V0_19_6, V0_19_6p1, V0_19_5, SFATEST, V0_19_4, V0_19_4_pre3, V0_19_4_pre2, V0_19_4_pre1, V0_19_3, V0_19_2, V0_19_1, V0_19_0, V0_18_5, V0_18_4, V_18_3_TEST, VO_18_3, V0_18_2, V0_18_1
Branch point for: V1_pre1, SCRAM_V1_BRANCH, V0_19_4_B
Changes since 1.2: +30 -3 lines
Log Message:
quick ci

File Contents

# User Rev Content
1 williamc 1.2 #
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 williamc 1.3 require FileHandle;
47     local (*FHOLD);
48     local (*FHOLDERR);
49     # - copy STDERR and STDOUT
50     open(FHOLD,">&STDOUT");
51     open(FHOLDERR,">&STDERR");
52    
53     # - redirect STDERR and STDOUT
54     my $rfile="/tmp/$$";
55     $self->verbose("Redirecting STDOUT to $rfile");
56     open(STDOUT, ">".$rfile) || die "Unable to open $!\n";
57     open(STDERR, ">&STDOUT") || die "Unable to open $!\n";
58    
59     # -- call
60     my @rv=();
61     eval { $file=$self->{ad}->getfile($url)->ProcessedFile() };
62     if ( (! defined $file) || ($file eq "") ) {
63     push @rv, (undef,$rfile);
64 williamc 1.2 }
65     else {
66 williamc 1.3 push @rv, ($file,$rfile);
67 williamc 1.2 }
68 williamc 1.3 close STDOUT;
69     close STDERR;
70    
71     # -- restore STDOUT & STDERR
72     open(STDOUT, ">&FHOLD");
73     open(STDERR, ">&FHOLDERR");
74     close FHOLD;
75     close FHOLDERR;
76    
77     $self->verbose("Redirection Finnished of STDOUT");
78     return (@rv);
79 williamc 1.2 }
80    
81     sub activatedoc {
82     my $self=shift;
83     my $url=shift;
84    
85     my $obj;
86     $self->verbose("Attempting activation of $url");
87     if ( eval { $obj=$self->{ad}->activatedoc($url) } ) {
88     return ($obj, $@);
89     }
90     else {
91     return (undef, $@);
92     }
93     }