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 qw/:datetime/;
20 use OpenSRF::Utils::Cache;
22 use OpenSRF::AppSession;
27 use Unicode::Normalize;
28 use OpenILS::Utils::Fieldmapper;
29 use OpenSRF::Utils::Logger qw/$logger/;
35 use Digest::MD5 qw/md5_hex/;
37 use UNIVERSAL::require;
39 our @formats = qw/USMARC UNIMARC XML BRE/;
41 # set the bootstrap config and template include directory when
42 # this module is loaded
52 OpenSRF::System->bootstrap_client( config_file => $bootstrap );
59 my $auth = $cgi->param('ses') || $cgi->cookie('ses');
61 return Apache2::Const::FORBIDDEN unless verify_login($auth);
63 my $cache = new OpenSRF::Utils::Cache();
64 my $file = $cgi->param('marc_upload');
65 my $filename = "$file";
67 my $data = join '', (<$file>);
68 $data = encode_base64($data);
70 my $data_fingerprint = md5_hex($data);
72 $cache->put_cache('vandelay_import_spool_' . $data_fingerprint, $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);