1 package OpenILS::WWW::Vandelay;
7 use Apache2::Const -compile => qw(OK REDIRECT DECLINED NOT_FOUND :log);
8 use APR::Const -compile => qw(:error SUCCESS);
11 use Apache2::RequestRec ();
12 use Apache2::RequestIO ();
13 use Apache2::RequestUtil;
18 use OpenSRF::EX qw(:try);
19 use OpenSRF::Utils::Cache;
21 use OpenSRF::AppSession;
24 use OpenILS::Utils::Fieldmapper;
25 use OpenSRF::Utils::Logger qw/$logger/;
31 use Digest::MD5 qw/md5_hex/;
33 use UNIVERSAL::require;
35 our @formats = qw/USMARC UNIMARC XML BRE/;
37 # set the bootstrap config and template include directory when
38 # this module is loaded
48 OpenSRF::System->bootstrap_client( config_file => $bootstrap );
55 my $auth = $cgi->param('ses') || $cgi->cookie('ses');
57 return Apache2::Const::FORBIDDEN unless verify_login($auth);
60 my $purpose = $cgi->param('purpose');
61 my $file = $cgi->param('marc_upload');
62 my $filename = "$file";
64 my $data = join '', (<$file>);
65 $data = encode_base64($data);
67 my $data_fingerprint = md5_hex($data);
69 OpenSRF::Utils::Cache()->new->put_cache(
70 'vandelay_import_spool_' . $data_fingerprint,
71 { purpose => $purpose, marc => $data }
74 print "Content-type: text/plain; charset=utf-8\n\n$data_fingerprint";
76 return Apache2::Const::OK;
81 my $auth_token = shift;
82 return undef unless $auth_token;
84 my $user = OpenSRF::AppSession
85 ->create("open-ils.auth")
86 ->request( "open-ils.auth.session.retrieve", $auth_token )
89 if (ref($user) eq 'HASH' && $user->{ilsevent} == 1001) {
93 return $user if ref($user);