Index: /main/trunk/greenstone2/cgi-bin/talkback-progressbar.pl
===================================================================
--- /main/trunk/greenstone2/cgi-bin/talkback-progressbar.pl	(revision 23176)
+++ /main/trunk/greenstone2/cgi-bin/talkback-progressbar.pl	(revision 23177)
@@ -1,4 +1,3 @@
 #!/usr/bin/perl -w
-
 
 use strict; 
@@ -8,5 +7,8 @@
 
 my $gsdl_cgi;
+my $gsdl_home;
 my $gsdl_tmp_dir;
+
+my $debugging_enabled = 1; # if 1, debugging is enabled and deleting files will not happen
 
 BEGIN {
@@ -167,5 +169,5 @@
     # Useful debug to slow down a 'fast' upload
     # Sleep for 10 msecs
-    select(undef, undef, undef, 0.01);
+    # select(undef, undef, undef, 0.01);
     #select(undef, undef, undef, 0.1);
 }
@@ -202,11 +204,50 @@
     my $progress_filename = get_progress_filename($uploaded_file);
 
-    if (!unlink($progress_filename)) {
-	print STDERR "Warning: Failed to delete $progress_filename\n"; 
-    }
+    unlink($progress_filename)
+	unless $debugging_enabled;
 
     my $fc_list = read_file_central();
     $fc_list = remove_from_file_central($uploaded_file,$fc_list);
     write_file_central($fc_list);
+}
+
+
+sub unzip_archives_doc
+{
+    my ($gsdl_cgi,$gsdl_home,$collect_home,$collect,$zip_filename) = @_;
+
+    my $lang_env = $gsdl_cgi->clean_param("lr") || "";
+
+    my $import_dir = &util::filename_cat($collect_home,$collect,"import");
+
+    # Unzip $zip_filename in the collection's import folder
+    my $java = $gsdl_cgi->get_java_path();
+    my $jar_dir= &util::filename_cat($gsdl_home, "bin", "java");
+    my $java_classpath = &util::filename_cat($jar_dir,"GLIServer.jar");
+
+    my $java_args = "\"$zip_filename\" \"$import_dir\"";
+
+    $ENV{'LANG'} = $lang_env;
+    my $java_command = "\"$java\" -classpath \"$java_classpath\" org.greenstone.gatherer.remote.Unzip $java_args"; 
+
+    my $java_output = `$java_command`;
+    my $java_status = $?;
+    if ($java_status > 0) {
+	my $report = "Java failed: $java_command\n--\n";
+	$report .= "$java_output\n";
+	$report .= "Exit status: " . ($java_status / 256) . "\n";
+	$report .= $gsdl_cgi->check_java_home();
+
+	$gsdl_cgi->generate_error($report);
+    }
+    else {
+	# Remove the zip file once we have unzipped it, since it is an intermediate file only
+	unlink($zip_filename) unless $debugging_enabled;
+    }
+
+#    print STDOUT "Content-type:text/plain\n\n";
+#    print STDOUT "cmd = $java_command\n";
+#    print STDOUT "**** $java_output\n";
+
 }
 
@@ -223,5 +264,7 @@
 
     my $gsdl_config = gsdlCGI->prenew();
-    $gsdl_tmp_dir = &util::get_toplevel_tmp_dir();
+
+    $gsdl_home    = $gsdl_config->get_gsdl_home();
+    $gsdl_tmp_dir = &util::get_toplevel_tmp_dir();  
 
     require talkback;
@@ -240,6 +283,6 @@
     if ($gsdl_cgi->param('process')) { 
 
-	my $uploadedfile = $gsdl_cgi->param('uploadedfile');
-	my $full_filename = &util::filename_cat($gsdl_tmp_dir,$uploadedfile);
+	my $uploaded_file = $gsdl_cgi->param('uploadedfile');
+	my $full_filename = &util::filename_cat($gsdl_tmp_dir,$uploaded_file);
 
 	my $done_html = &talkback::generate_done_html($full_filename);
@@ -247,4 +290,9 @@
         if ($gsdl_cgi->param('yes_upload')) { 
             upload_file($gsdl_cgi,$full_filename); 
+
+	    my $collect      = $gsdl_cgi->param('toCollect');
+	    my $collect_home = &util::filename_cat($gsdl_home,"collect");
+
+	    unzip_archives_doc($gsdl_cgi,$gsdl_home,$collect_home,$collect,$full_filename);
         }   
 
@@ -252,5 +300,5 @@
         print $done_html; 
 
-        remove_progress_file($gsdl_cgi->param('uploadedfile'));   
+        remove_progress_file($uploaded_file);   
     }
     else {         
@@ -262,5 +310,5 @@
 	my $uniq_file = $gsdl_cgi->param('uploadedfile');   
 
-	#my $uniq_file = "$collect-$oid-doc.xml";
+	#my $uniq_file = "$collect-$oid-doc.zip";
 	# Light-weight (hidden) form with progress bar
 
Index: /main/trunk/greenstone2/cgi-bin/talkback-transfer.pl
===================================================================
--- /main/trunk/greenstone2/cgi-bin/talkback-transfer.pl	(revision 23176)
+++ /main/trunk/greenstone2/cgi-bin/talkback-transfer.pl	(revision 23177)
@@ -97,7 +97,4 @@
 
     my $java_args = "\"$zip_file_path\" \"$archive_dir\" \"$assoc_path\"";
-    if($gsdl_cgi->greenstone_version() != 2) {
-	$java_args .= " gsdl3"; 
-    }
 
     $ENV{'LANG'} = $lang_env;
@@ -133,5 +130,6 @@
 
     my $oid     = $gsdl_cgi->param('oid');
-    my $collect = $gsdl_cgi->param('collect');
+    my $collect = $gsdl_cgi->param('fromCollect');
+    my $toCollect = $gsdl_cgi->param('toCollect');
     my $site    = $gsdl_cgi->param('site');
 
@@ -161,5 +159,5 @@
 	     'process'      => '1',
 	     'oid'          => $oid,
-	     'collect'      => $collect,
+	     'toCollect'    => $toCollect,
 	     'uploadedfile' => [$zip_filename, "$uniq_prefix-doc.zip"] 
 	     ],
