2 use strict; use warnings;
5 use OpenSRF::Utils::Logger qw/$logger/;
6 use OpenILS::Application::AppUtils;
10 our $U = "OpenILS::Application::AppUtils";
12 #do '##CONFIG##/upload-server.pl';
13 do 'offline-config.pl';
15 our $base_dir = $config{base_dir};
16 my $bsconfig = $config{bootstrap};
19 # --------------------------------------------------------------------
21 # --------------------------------------------------------------------
22 OpenSRF::System->bootstrap_client(config_file => $bsconfig);
27 # --------------------------------------------------------------------
28 # Prints out an error message to the client
29 # --------------------------------------------------------------------
32 $logger->error("offline: $err");
33 print "content-type: text/html\n\n";
37 <title>Offline Upload Failed</title>
40 <div style='margin-top: 50px; text-align: center;'>
41 <b style='color:red;'>Offline Upload Failed</b><br/>
51 # --------------------------------------------------------------------
52 # Prints out a success message to the client
53 # --------------------------------------------------------------------
56 $logger->info("offline: returned success message: $msg");
57 print "content-type: text/html\n\n";
61 <title>Success</title>
64 <div style='margin-top: 50px; text-align: center;'>
65 <b style='color:blue;'> $msg </b><br/>
74 # --------------------------------------------------------------------
75 # Fetches and creates if necessary the pending directory
76 # --------------------------------------------------------------------
79 my $dir = "$base_dir/pending/$org/";
80 system( ('mkdir', '-p', "$dir") ) == 0
81 or handle_error("Unable to create directory $dir");
82 $logger->debug("offline: created/fetched pending directory $dir");
86 # --------------------------------------------------------------------
87 # Fetches and creates if necessary the archive directory
88 # --------------------------------------------------------------------
89 sub create_archive_dir {
91 my (undef,$min,$hour,$mday,$mon,$year) = localtime(time);
95 $min = "0$min" unless $min =~ /\d{2}/o;
96 $hour = "0$hour" unless $hour =~ /\d{2}/o;
97 $mday = "0$mday" unless $mday =~ /\d{2}/o;
98 $mon = "0$mon" unless $mon =~ /\d{2}/o;
100 my $dir = "$base_dir/archive/$org/$year$mon$mday$hour$min/";
101 system( ('mkdir', '-p', "$dir") ) == 0
102 or handle_error("Unable to create archive directory $dir");
103 $logger->debug("offline: Created archive directory $dir");
109 # --------------------------------------------------------------------
110 # Fetches the workstation object by name
111 # --------------------------------------------------------------------
112 sub fetch_workstation {
114 $logger->debug("offline: Fetching workstation $name");
115 my $ws = $U->storagereq(
116 'open-ils.storage.direct.actor.workstation.search.name', $name);
117 handle_error("Workstation $name does not exists") unless $ws;