[open-ils-commits] r9593 - in trunk/Open-ILS/src/perlmods/OpenILS: Application WWW

svn at svn.open-ils.org svn at svn.open-ils.org
Tue May 13 17:38:57 EDT 2008


Author: miker
Date: 2008-05-13 17:38:53 -0400 (Tue, 13 May 2008)
New Revision: 9593

Added:
   trunk/Open-ILS/src/perlmods/OpenILS/WWW/Vandelay.pm
Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
Log:
mod_perl stub for uploading vandelay files

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm	2008-05-13 21:23:19 UTC (rev 9592)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm	2008-05-13 21:38:53 UTC (rev 9593)
@@ -175,6 +175,29 @@
 	argc		=> 3,
 );                      
 
+sub process_marc {
+    my $r = shift;
+    my $cgi = new CGI;
 
+    my $auth = $cgi->param('ses') || $cgi->cookie('ses');
+
+    return Apache2::Const::FORBIDDEN unless verify_login($auth);
+
+    my $fingerprint = $cgi->param('fingerprint')
+    my $type = $cgi->param('type')
+    my $queue = $cgi->param('queue')
+
+    my $cache = new OpenSRF::Utils::Cache();
+
+    my $data = $cache->get_cache('vandelay_import_spool_' . $fingerprint);
+    $data = decode_base64($data);
+
+    print "Content-type: text/plain; charset=utf-8\n\n$data_fingerprint";
+
+    return Apache2::Const::OK;
+
+}
+
+
 1;
 

Added: trunk/Open-ILS/src/perlmods/OpenILS/WWW/Vandelay.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/WWW/Vandelay.pm	                        (rev 0)
+++ trunk/Open-ILS/src/perlmods/OpenILS/WWW/Vandelay.pm	2008-05-13 21:38:53 UTC (rev 9593)
@@ -0,0 +1,97 @@
+package OpenILS::WWW::Vandelay;
+use strict;
+use warnings;
+use bytes;
+
+use Apache2::Log;
+use Apache2::Const -compile => qw(OK REDIRECT DECLINED NOT_FOUND :log);
+use APR::Const    -compile => qw(:error SUCCESS);
+use APR::Table;
+
+use Apache2::RequestRec ();
+use Apache2::RequestIO ();
+use Apache2::RequestUtil;
+use CGI;
+use Data::Dumper;
+use Text::CSV;
+
+use OpenSRF::EX qw(:try);
+use OpenSRF::Utils qw/:datetime/;
+use OpenSRF::Utils::Cache;
+use OpenSRF::System;
+use OpenSRF::AppSession;
+use XML::LibXML;
+use XML::LibXSLT;
+
+use Encode;
+use Unicode::Normalize;
+use OpenILS::Utils::Fieldmapper;
+use OpenSRF::Utils::Logger qw/$logger/;
+
+use MARC::Record;
+use MARC::File::XML;
+
+use MIME::Base64;
+use Digest::MD5 qw/md5_hex/;
+
+use UNIVERSAL::require;
+
+our @formats = qw/USMARC UNIMARC XML BRE/;
+
+# set the bootstrap config and template include directory when
+# this module is loaded
+my $bootstrap;
+
+sub import {
+        my $self = shift;
+        $bootstrap = shift;
+}
+
+
+sub child_init {
+        OpenSRF::System->bootstrap_client( config_file => $bootstrap );
+}
+
+sub spool_marc {
+	my $r = shift;
+	my $cgi = new CGI;
+
+	my $auth = $cgi->param('ses') || $cgi->cookie('ses');
+
+	return Apache2::Const::FORBIDDEN unless verify_login($auth);
+
+	my $cache = new OpenSRF::Utils::Cache();
+	my $file = $cgi->param('marc_upload');
+	my $filename = "$file";
+
+	my $data = join '', (<$file>);
+	$data = encode_base64($data);
+
+	my $data_fingerprint = md5_hex($data);
+
+	$cache->put_cache('vandelay_import_spool_' . $data_fingerprint, $data);
+
+	print "Content-type: text/plain; charset=utf-8\n\n$data_fingerprint";
+
+	return Apache2::Const::OK;
+
+}
+
+sub verify_login {
+        my $auth_token = shift;
+        return undef unless $auth_token;
+
+        my $user = OpenSRF::AppSession
+                ->create("open-ils.auth")
+                ->request( "open-ils.auth.session.retrieve", $auth_token )
+                ->gather(1);
+
+        if (ref($user) eq 'HASH' && $user->{ilsevent} == 1001) {
+                return undef;
+        }
+
+        return $user if ref($user);
+        return undef;
+}
+
+1;



More information about the open-ils-commits mailing list