Changeset 23147
- Timestamp:
- 2010-10-17T23:54:21+13:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/cgi-bin/talkback-transfer.pl
r23146 r23147 8 8 use CGI::Carp qw(fatalsToBrowser); 9 9 use CGI; 10 11 use File::Basename; 10 12 11 13 BEGIN { … … 56 58 my $infodb_type = get_infodb_type($opt_site,$collect_home,$collect); 57 59 58 # Obtain the collect andarchives dir59 my $archive s_dir = &util::filename_cat($collect_home,$collect,"archives");60 # Derive the archives dir 61 my $archive_dir = &util::filename_cat($collect_home,$collect,"archives"); 60 62 61 63 # Obtain the doc.xml path for the specified docID 62 64 my $arcinfo_doc_filename 63 65 = &dbutil::get_infodb_file_path($infodb_type, "archiveinf-doc", 64 $archive s_dir);66 $archive_dir); 65 67 my $doc_rec_string 66 68 = &dbutil::read_infodb_entry($infodb_type, $arcinfo_doc_filename, … … 68 70 my $doc_rec = &dbutil::convert_infodb_string_to_hash($doc_rec_string); 69 71 my $doc_xml_file = $doc_rec->{'doc-file'}->[0]; 70 72 my $assoc_path = dirname($doc_xml_file); 73 71 74 # The $doc_xml_file is relative to the archives, so now let's get the 72 75 # full path 73 my $doc_xml_filename = &util::filename_cat($archive s_dir,$doc_xml_file);76 my $doc_xml_filename = &util::filename_cat($archive_dir,$doc_xml_file); 74 77 75 return $doc_xml_filename; 78 return ($doc_xml_filename,$assoc_path); 79 } 80 81 sub zip_up_archives_doc 82 { 83 my ($gsdl_cgi,$collect_home,$collect,$doc_xml_filename,$assoc_path) = @_; 84 85 my $timestamp = time(); 86 my $lang_env = $gsdl_cgi->clean_param("lr") || ""; 87 88 my $archive_dir = &util::filename_cat($collect_home,$collect,"archives"); 89 90 # Zip up the doc_xml file and all the files associated with it 91 my $java = $gsdl_cgi->get_java_path(); 92 my $jar_dir= &util::filename_cat($ENV{'GSDLHOME'}, "bin", "java"); 93 my $java_classpath = &util::filename_cat($jar_dir,"GLIServer.jar"); 94 95 my $zip_file = "$collect-$timestamp.zip"; 96 my $zip_file_path = &util::filename_cat($archive_dir,$zip_file); 97 98 my $java_args = "\"$zip_file_path\" \"$archive_dir\" \"$assoc_path\""; 99 if($gsdl_cgi->greenstone_version() != 2) { 100 $java_args .= " gsdl3"; 101 } 102 103 $ENV{'LANG'} = $lang_env; 104 my $java_command = "\"$java\" -classpath \"$java_classpath\" org.greenstone.gatherer.remote.ZipCollectionShell $java_args"; 105 106 my $java_output = `$java_command`; 107 my $java_status = $?; 108 if ($java_status > 0) { 109 $gsdl_cgi->generate_error("Java failed: $java_command\n--\n$java_output\nExit status: " . ($java_status / 256) . "\n" . $gsdl_cgi->check_java_home()); 110 } 111 112 # Check that the zip file was created successfully 113 if (!-e $zip_file_path || -z $zip_file_path) { 114 $gsdl_cgi->generate_error("Collection zip file $zip_file_path could not be created."); 115 } 116 117 return $zip_file_path; 118 76 119 } 77 120 … … 102 145 my $uniq_prefix = "$collect-$oid"; 103 146 104 my $docxml_filename = oid_to_docxml_filename($site,$collect_home,$collect,$oid); 147 my ($docxml_filename,$assoc_path) 148 = oid_to_docxml_filename($site,$collect_home,$collect,$oid); 149 150 my $zip_filename 151 = zip_up_archives_doc($gsdl_cgi,$collect_home,$collect, 152 $docxml_filename,$assoc_path); 105 153 106 154 my $talktoUploadURL = $gsdl_cgi->param('talktoUpload'); … … 114 162 'oid' => $oid, 115 163 'collect' => $collect, 116 'uploadedfile' => [$ docxml_filename, "$uniq_prefix-doc.xml"]164 'uploadedfile' => [$zip_filename, "$uniq_prefix-doc.xml"] 117 165 ], 118 166 'Content_Type' => 'form-data'
Note:
See TracChangeset
for help on using the changeset viewer.