Changeset 23177


Ignore:
Timestamp:
2010-10-19T17:30:19+13:00 (11 years ago)
Author:
davidb
Message:

CGI scripts need to know the fromCollect and toCollect

Location:
main/trunk/greenstone2/cgi-bin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/cgi-bin/talkback-progressbar.pl

    r23149 r23177  
    11#!/usr/bin/perl -w
    2 
    32
    43use strict;
     
    87
    98my $gsdl_cgi;
     9my $gsdl_home;
    1010my $gsdl_tmp_dir;
     11
     12my $debugging_enabled = 1; # if 1, debugging is enabled and deleting files will not happen
    1113
    1214BEGIN {
     
    167169    # Useful debug to slow down a 'fast' upload
    168170    # Sleep for 10 msecs
    169     select(undef, undef, undef, 0.01);
     171    # select(undef, undef, undef, 0.01);
    170172    #select(undef, undef, undef, 0.1);
    171173}
     
    202204    my $progress_filename = get_progress_filename($uploaded_file);
    203205
    204     if (!unlink($progress_filename)) {
    205     print STDERR "Warning: Failed to delete $progress_filename\n";
    206     }
     206    unlink($progress_filename)
     207    unless $debugging_enabled;
    207208
    208209    my $fc_list = read_file_central();
    209210    $fc_list = remove_from_file_central($uploaded_file,$fc_list);
    210211    write_file_central($fc_list);
     212}
     213
     214
     215sub unzip_archives_doc
     216{
     217    my ($gsdl_cgi,$gsdl_home,$collect_home,$collect,$zip_filename) = @_;
     218
     219    my $lang_env = $gsdl_cgi->clean_param("lr") || "";
     220
     221    my $import_dir = &util::filename_cat($collect_home,$collect,"import");
     222
     223    # Unzip $zip_filename in the collection's import folder
     224    my $java = $gsdl_cgi->get_java_path();
     225    my $jar_dir= &util::filename_cat($gsdl_home, "bin", "java");
     226    my $java_classpath = &util::filename_cat($jar_dir,"GLIServer.jar");
     227
     228    my $java_args = "\"$zip_filename\" \"$import_dir\"";
     229
     230    $ENV{'LANG'} = $lang_env;
     231    my $java_command = "\"$java\" -classpath \"$java_classpath\" org.greenstone.gatherer.remote.Unzip $java_args";
     232
     233    my $java_output = `$java_command`;
     234    my $java_status = $?;
     235    if ($java_status > 0) {
     236    my $report = "Java failed: $java_command\n--\n";
     237    $report .= "$java_output\n";
     238    $report .= "Exit status: " . ($java_status / 256) . "\n";
     239    $report .= $gsdl_cgi->check_java_home();
     240
     241    $gsdl_cgi->generate_error($report);
     242    }
     243    else {
     244    # Remove the zip file once we have unzipped it, since it is an intermediate file only
     245    unlink($zip_filename) unless $debugging_enabled;
     246    }
     247
     248#    print STDOUT "Content-type:text/plain\n\n";
     249#    print STDOUT "cmd = $java_command\n";
     250#    print STDOUT "**** $java_output\n";
     251
    211252}
    212253
     
    223264
    224265    my $gsdl_config = gsdlCGI->prenew();
    225     $gsdl_tmp_dir = &util::get_toplevel_tmp_dir();
     266
     267    $gsdl_home    = $gsdl_config->get_gsdl_home();
     268    $gsdl_tmp_dir = &util::get_toplevel_tmp_dir(); 
    226269
    227270    require talkback;
     
    240283    if ($gsdl_cgi->param('process')) {
    241284
    242     my $uploadedfile = $gsdl_cgi->param('uploadedfile');
    243     my $full_filename = &util::filename_cat($gsdl_tmp_dir,$uploadedfile);
     285    my $uploaded_file = $gsdl_cgi->param('uploadedfile');
     286    my $full_filename = &util::filename_cat($gsdl_tmp_dir,$uploaded_file);
    244287
    245288    my $done_html = &talkback::generate_done_html($full_filename);
     
    247290        if ($gsdl_cgi->param('yes_upload')) {
    248291            upload_file($gsdl_cgi,$full_filename);
     292
     293        my $collect      = $gsdl_cgi->param('toCollect');
     294        my $collect_home = &util::filename_cat($gsdl_home,"collect");
     295
     296        unzip_archives_doc($gsdl_cgi,$gsdl_home,$collect_home,$collect,$full_filename);
    249297        }   
    250298
     
    252300        print $done_html;
    253301
    254         remove_progress_file($gsdl_cgi->param('uploadedfile'));   
     302        remove_progress_file($uploaded_file);   
    255303    }
    256304    else {         
     
    262310    my $uniq_file = $gsdl_cgi->param('uploadedfile');   
    263311
    264     #my $uniq_file = "$collect-$oid-doc.xml";
     312    #my $uniq_file = "$collect-$oid-doc.zip";
    265313    # Light-weight (hidden) form with progress bar
    266314
  • main/trunk/greenstone2/cgi-bin/talkback-transfer.pl

    r23162 r23177  
    9797
    9898    my $java_args = "\"$zip_file_path\" \"$archive_dir\" \"$assoc_path\"";
    99     if($gsdl_cgi->greenstone_version() != 2) {
    100     $java_args .= " gsdl3";
    101     }
    10299
    103100    $ENV{'LANG'} = $lang_env;
     
    133130
    134131    my $oid     = $gsdl_cgi->param('oid');
    135     my $collect = $gsdl_cgi->param('collect');
     132    my $collect = $gsdl_cgi->param('fromCollect');
     133    my $toCollect = $gsdl_cgi->param('toCollect');
    136134    my $site    = $gsdl_cgi->param('site');
    137135
     
    161159         'process'      => '1',
    162160         'oid'          => $oid,
    163          'collect'      => $collect,
     161         'toCollect'    => $toCollect,
    164162         'uploadedfile' => [$zip_filename, "$uniq_prefix-doc.zip"]
    165163         ],
Note: See TracChangeset for help on using the changeset viewer.