1 package OpenILS::WWW::AddedContent;
2 use strict; use warnings;
4 use lib qw(/usr/lib/perl5/Bundle/);
9 use Apache2::Const -compile => qw(OK REDIRECT DECLINED NOT_FOUND :log);
10 use APR::Const -compile => qw(:error SUCCESS);
11 use Apache2::RequestRec ();
12 use Apache2::RequestIO ();
13 use Apache2::RequestUtil;
16 use OpenSRF::EX qw(:try);
17 use OpenSRF::Utils::Cache;
19 use OpenSRF::Utils::Logger qw/$logger/;
23 # set the bootstrap config when this module is loaded
35 OpenSRF::System->bootstrap_client( config_file => $bs_config );
37 my $sclient = OpenSRF::Utils::SettingsClient->new();
38 my $ac_data = $sclient->config_value("added_content");
39 my $ac_handler = $ac_data->{module};
40 return unless $ac_handler;
42 $logger->debug("Attempting to load Added Content handler: $ac_handler");
44 eval "use $ac_handler";
47 $logger->error("Unable to load Added Content handler [$ac_handler]: $@");
51 $handler = $ac_handler->new($ac_data);
52 $logger->debug("added content loaded handler: $handler");
60 my $path = $r->path_info;
62 child_init() unless $handler; # why isn't apache doing this for us?
63 return Apache2::Const::NOT_FOUND unless $handler;
65 my( undef, $data, $format, $key ) = split(/\//, $r->path_info);
69 my $method = "${data}_${format}";
72 $success = $handler->$method($key);
75 $logger->error("added content handler failed: $method($key) => $err");
78 return Apache2::Const::NOT_FOUND if $err or !$success;
79 return Apache2::Const::OK;