source: gli/branches/glicolgroup/src/org/greenstone/gatherer/remote/RemoteGreenstoneServerAction.java@ 19668

Last change on this file since 19668 was 19668, checked in by ak19, 15 years ago

Not working. Changes made for collectiongroup.

File size: 26.8 KB
RevLine 
[17612]1/**
2 *#########################################################################
3 *
4 * A component of the Greenstone Librarian Interface application, part of
5 * the Greenstone digital library suite from the New Zealand Digital
6 * Library Project at the University of Waikato, New Zealand.
7 *
8 * Author: Michael Dewsnip, NZDL Project, University of Waikato
9 *
10 * Copyright (C) 2005 New Zealand Digital Library Project
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *########################################################################
26*/
27
28package org.greenstone.gatherer.remote;
29
30import java.io.*;
31import java.net.*;
32import java.util.*;
33import java.util.zip.*;
34import javax.swing.*;
35import java.io.ByteArrayOutputStream;
36import org.greenstone.gatherer.Configuration;
37import org.greenstone.gatherer.DebugStream;
38import org.greenstone.gatherer.Dictionary;
39import org.greenstone.gatherer.FedoraInfo;
40import org.greenstone.gatherer.GAuthenticator;
41import org.greenstone.gatherer.Gatherer;
42import org.greenstone.gatherer.collection.CollectionManager;
[18646]43import org.greenstone.gatherer.feedback.Base64;
[17612]44import org.greenstone.gatherer.shell.GShell;
45import org.greenstone.gatherer.util.UnzipTools;
46import org.greenstone.gatherer.util.Utility;
47import org.apache.commons.httpclient.HttpClient;
48import org.apache.commons.httpclient.methods.PostMethod;
49import org.apache.commons.httpclient.methods.GetMethod;
50import org.apache.commons.httpclient.HttpException;
51import org.apache.commons.httpclient.methods.multipart.FilePart;
52import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
53import org.apache.commons.httpclient.methods.multipart.Part;
54import org.apache.commons.httpclient.methods.multipart.*;
55import org.apache.commons.httpclient.params.*;
56import org.apache.commons.httpclient.HttpStatus;
57
58
59// Code moved here from RemoteGreenstoneServer.java
60// ----------------------------------------------------------------------------------------------------
61// ACTIONS
62// ----------------------------------------------------------------------------------------------------
63/** RemoteGreenstoneServer Actions that can go into the remote GS server's ActionQueue.
64 * Contains many package access inner classes that are Actions.
65*/
66public abstract class RemoteGreenstoneServerAction
67{
68 public String action_output = null;
69 public boolean processed = false;
70 public boolean processed_successfully;
71
72 protected RemoteGreenstoneServer remote = null;
73 protected RemoteGreenstoneServer.ProgressBar progress_bar = null;
74
75 public RemoteGreenstoneServerAction() {
76 remote = Gatherer.remoteGreenstoneServer;
77 progress_bar = remote.getProgressBar();
78 }
79
80 abstract public void perform()
81 throws Exception;
82
83 /*
84 protected String sendCommandToServer(String gliserver_args, GShell shell)
85 throws Exception
86 {
87 return Gatherer.remoteGreenstoneServer.sendCommandToServer(gliserver_args, shell);
88 }
89
90 protected void setAction(String action) {
91 Gatherer.remoteGreenstoneServer.progress_bar.setAction(action);
92 }*/
93
94 static class ActionCancelledException
95 extends Exception
96 {
97 }
98
99 /**
100 * --------------------------------------------------------------------------------------------
101 * DELETE COLLECTION
102 * --------------------------------------------------------------------------------------------
103 */
104 static class DeleteCollectionAction
105 extends RemoteGreenstoneServerAction
106 {
107 private String collection_name;
108
109 public DeleteCollectionAction(String collection_name)
110 {
[19668]111 this.collection_name = collection_name; //.replace('/', File.separatorChar); // if colgroup contained url slashes
[17612]112 }
113
114 public void perform()
115 throws Exception
116 {
117 progress_bar.setAction("Deleting collection " + collection_name + "...");
118
119 String delete_collection_command = "cmd=delete-collection";
120 delete_collection_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
121 action_output = remote.sendCommandToServer(delete_collection_command, null);
122 }
123 }
124
125
126 /**
127 * --------------------------------------------------------------------------------------------
128 * DELETE COLLECTION FILE
129 * --------------------------------------------------------------------------------------------
130 */
131 static class DeleteCollectionFileAction
132 extends RemoteGreenstoneServerAction
133 {
134 private String collection_name;
135 private File collection_file;
136
137 public DeleteCollectionFileAction(String collection_name, File collection_file)
138 {
[19668]139 this.collection_name = collection_name; //.replace('/', File.separatorChar); // if colgroup contained url slashes
[17612]140 this.collection_file = collection_file;
141 }
142
143 public void perform()
144 throws Exception
145 {
146 String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
147 String collection_file_relative_path = remote.getPathRelativeToDirectory(collection_file, collection_directory_path);
[19668]148 System.err.println("**** DeleteCollectionFile.\n\tcol_file: "+collection_file + "\n\t" + collection_directory_path);
149
[17612]150 collection_file_relative_path = collection_file_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
151 progress_bar.setAction("Deleting collection file " + collection_file_relative_path + "...");
152
153 String delete_collection_file_command = "cmd=delete-collection-file";
154 delete_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
[18646]155 delete_collection_file_command += "&file=" + Base64.encodeBytes(collection_file_relative_path.getBytes());
[17612]156 action_output = remote.sendCommandToServer(delete_collection_file_command, null);
157 }
158 }
159
160
161 /**
162 * --------------------------------------------------------------------------------------------
163 * DOWNLOAD COLLECTION
164 * --------------------------------------------------------------------------------------------
165 */
166 static class DownloadCollectionAction
167 extends RemoteGreenstoneServerAction
168 {
169 private String collection_name;
170
171 public DownloadCollectionAction(String collection_name)
172 {
173 this.collection_name = collection_name;
174 }
175
176 public void perform()
177 throws Exception
178 {
179 progress_bar.setAction("Downloading remote collection " + collection_name + "...");
[19668]180 System.err.println("*** RGSAction.DownloadCollectionAction, col_name: " + collection_name);
[17612]181
182 String download_collection_command = "cmd=download-collection";
183 download_collection_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
[19173]184 download_collection_command += "&lr=" + remote.lang_region;
[17612]185 String zip_file_path = Gatherer.getCollectDirectoryPath() + collection_name + ".zip";
186 action_output = remote.downloadFile(download_collection_command, zip_file_path);
187
188 // Delete the existing (local) collection directory
189 Utility.delete(new File(CollectionManager.getCollectionDirectoryPath(collection_name)));
190
191 // Unzip the collection just downloaded
192 UnzipTools.unzipFile(zip_file_path, Gatherer.getCollectDirectoryPath());
193 }
194 }
195
196
197 /**
198 * --------------------------------------------------------------------------------------------
199 * DOWNLOAD COLLECTION ARCHIVES
200 * --------------------------------------------------------------------------------------------
201 */
202 static class DownloadCollectionArchivesAction
203 extends RemoteGreenstoneServerAction
204 {
205 private String collection_name;
206
207 public DownloadCollectionArchivesAction(String collection_name)
208 {
209 this.collection_name = collection_name;
210 }
211
212 public void perform()
213 throws Exception
214 {
215 progress_bar.setAction("Downloading collection archives for " + collection_name + "...");
216
217 String download_collection_archives_command = "cmd=download-collection-archives";
218 download_collection_archives_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
[19173]219 download_collection_archives_command += "&lr=" + remote.lang_region;
[17612]220 String zip_file_path = Gatherer.getCollectDirectoryPath() + collection_name + "-archives.zip";
221 action_output = remote.downloadFile(download_collection_archives_command, zip_file_path);
222
223 // Delete the existing (local) collection archives
224 Utility.delete(new File(CollectionManager.getLoadedCollectionArchivesDirectoryPath()));
225
226 // Unzip the collection archives just downloaded
227 UnzipTools.unzipFile(zip_file_path, Gatherer.getCollectDirectoryPath());
228 }
229 }
230
231
232 /**
233 * --------------------------------------------------------------------------------------------
234 * DOWNLOAD COLLECTION CONFIGURATIONS
235 * --------------------------------------------------------------------------------------------
236 */
237 static class DownloadCollectionConfigurationsAction
238 extends RemoteGreenstoneServerAction
239 {
240 public DownloadCollectionConfigurationsAction()
241 {
242 }
243
244 public void perform()
245 throws Exception
246 {
247 progress_bar.setAction("Downloading collection configurations...");
248
249 // Delete the existing (local) collect directory
250 Utility.delete(new File(Gatherer.getCollectDirectoryPath()));
251 new File(Gatherer.getCollectDirectoryPath()).mkdirs();
252
253 String download_collection_configurations_command = "cmd=download-collection-configurations";
[19173]254 download_collection_configurations_command += "&lr=" + remote.lang_region;
[17612]255 String zip_file_path = Gatherer.getCollectDirectoryPath() + "collections.zip";
256 action_output = remote.downloadFile(download_collection_configurations_command, zip_file_path);
257
258 // Unzip the collection configurations just downloaded
259 UnzipTools.unzipFile(zip_file_path, Gatherer.getCollectDirectoryPath());
260 }
261 }
262
263 /**
264 * --------------------------------------------------------------------------------------------
265 * DISCOVERING WHAT VERSION THE REMOTE GREENSTONE SERVER IS (2 or 3)
266 * --------------------------------------------------------------------------------------------
267 */
268
269 static class VersionAction
270 extends RemoteGreenstoneServerAction
271 {
272 public void perform()
273 throws Exception
274 {
275 action_output = remote.sendCommandToServer("cmd=greenstone-server-version", null);
276 }
277 }
278
279 static class LibraryURLSuffixAction
280 extends RemoteGreenstoneServerAction
281 {
282 public void perform()
283 throws Exception
284 {
285 action_output = remote.sendCommandToServer("cmd=get-library-url-suffix", null);
286 }
287 }
288
289 /**
290 * --------------------------------------------------------------------------------------------
291 * CHECKING IF A FILE/FOLDER EXISTS ON SERVER SIDE
292 * --------------------------------------------------------------------------------------------
293 */
294 static class ExistsAction
295 extends RemoteGreenstoneServerAction
296 {
297 private String collection_name;
298 private File collection_file;
299
300 public ExistsAction(String collection_name, File collection_file)
301 {
302 this.collection_name = collection_name;
303 this.collection_file = collection_file;
304 }
305
306 public void perform()
307 throws Exception
308 {
309 String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
310 String collection_file_relative_path = remote.getPathRelativeToDirectory(collection_file, collection_directory_path);
311 collection_file_relative_path = collection_file_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
312 File file = new File(collection_directory_path, collection_file_relative_path);
313
314 String file_exists_command = "cmd=file-exists";
315 file_exists_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
[18646]316 // base64 encode the filename to preserve special characters
317 file_exists_command += "&file=" + Base64.encodeBytes(collection_file_relative_path.getBytes());
318
[17612]319 // returns either "File <filename> exists" or "File <filename> does not exist"
320 // for the file/folder collection_file
321 action_output = remote.sendCommandToServer(file_exists_command, null);
322 }
323 }
324
325
326 /**
327 * --------------------------------------------------------------------------------------------
328 * DOWNLOAD COLLECTION FILE
329 * --------------------------------------------------------------------------------------------
330 */
331 static class DownloadCollectionFileAction
332 extends RemoteGreenstoneServerAction
333 {
334 private String collection_name;
335 private File collection_file;
336
337 public DownloadCollectionFileAction(String collection_name, File collection_file)
338 {
339 this.collection_name = collection_name;
340 this.collection_file = collection_file;
341 }
342
343 public void perform()
344 throws Exception
345 {
346 String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
347 String collection_file_relative_path = remote.getPathRelativeToDirectory(collection_file, collection_directory_path);
348 collection_file_relative_path = collection_file_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
349 progress_bar.setAction("Downloading collection file " + collection_file_relative_path + "...");
350
351 String download_collection_file_command = "cmd=download-collection-file";
352 download_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
353 download_collection_file_command += "&file=" + URLEncoder.encode(collection_file_relative_path, "UTF-8");
[19173]354 download_collection_file_command += "&lr=" + remote.lang_region;
[17612]355 String zip_file_name = collection_name + "-" + collection_file.getName() + ".zip";
356 String zip_file_path = collection_directory_path + zip_file_name;
357 action_output = remote.downloadFile(download_collection_file_command, zip_file_path);
358
359 // Unzip the collection file just downloaded
360 UnzipTools.unzipFile(zip_file_path, collection_directory_path);
361 }
362 }
363
364 /**
365 * --------------------------------------------------------------------------------------------
366 * DOWNLOAD web.xml FILE --for a remote GS3
367 * --------------------------------------------------------------------------------------------
368 */
369 static class DownloadWebXMLFileAction
370 extends RemoteGreenstoneServerAction
371 {
372 public DownloadWebXMLFileAction()
373 {}
374
375 public void perform()
376 throws Exception
377 {
378 String web_xml_directory_path=(Configuration.gli_user_directory_path);
379 String download_web_xml_file_command = "cmd=download-web-xml-file";
380 download_web_xml_file_command += "&file=" + URLEncoder.encode("web.xml", "UTF-8");
[19173]381 download_web_xml_file_command += "&lr=" + remote.lang_region;
[17612]382 String zip_file_name = "web-xml.zip";
383 String zip_file_path = web_xml_directory_path + zip_file_name;
384 action_output = remote.downloadFile(download_web_xml_file_command, zip_file_path);
385
386 // Unzip the web.xml file just downloaded
387 UnzipTools.unzipFile(zip_file_path,web_xml_directory_path);
388 }
389 }
390
391 /**
392 * --------------------------------------------------------------------------------------------
393 * GET SCRIPT OPTIONS
394 * --------------------------------------------------------------------------------------------
395 */
396 static class GetScriptOptionsAction
397 extends RemoteGreenstoneServerAction
398 {
399 private String script_name;
400 private String script_arguments;
401
402 public GetScriptOptionsAction(String script_name, String script_arguments)
403 {
404 this.script_name = script_name;
405 this.script_arguments = script_arguments;
406 }
407
408 public void perform()
409 throws Exception
410 {
411 progress_bar.setAction("Getting options for " + script_name + "...");
412
413 String get_script_options_command = "cmd=get-script-options";
414 get_script_options_command += "&script=" + script_name;
415 get_script_options_command += "&xml=";
416 get_script_options_command += "&language=" + Configuration.getLanguage();
417 get_script_options_command += script_arguments;
418 action_output = remote.sendCommandToServer(get_script_options_command, null);
419 }
420 }
421
422 /**
423 * --------------------------------------------------------------------------------------------
424 * GET ALL NAMES OF SITES // for a remote GS3
425 * --------------------------------------------------------------------------------------------
426 */
427 static class GetSiteNamesAction
428 extends RemoteGreenstoneServerAction
429 {
430 public GetSiteNamesAction()
431 {}
432
433 public void perform()
434 throws Exception
435 {
436 progress_bar.setAction("Getting names of sites ...");
437
438 String get_script_options_command = "cmd=get-site-names";
439 action_output = remote.sendCommandToServer(get_script_options_command, null);
440 }
441 }
442
443 /**
444 * --------------------------------------------------------------------------------------------
445 * MOVE COLLECTION FILE
446 * --------------------------------------------------------------------------------------------
447 */
448 static class MoveCollectionFileAction
449 extends RemoteGreenstoneServerAction
450 {
451 private String collection_name;
452 private File source_collection_file;
453 private File target_collection_file;
454
455 public MoveCollectionFileAction(String collection_name, File source_collection_file, File target_collection_file)
456 {
457 this.collection_name = collection_name;
458 this.source_collection_file = source_collection_file;
459 this.target_collection_file = target_collection_file;
460 }
461
462 public void perform()
463 throws Exception
464 {
465 String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
466 String source_collection_file_relative_path = remote.getPathRelativeToDirectory(
467 source_collection_file, collection_directory_path);
468 source_collection_file_relative_path = source_collection_file_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
469 String target_collection_file_relative_path = remote.getPathRelativeToDirectory(
470 target_collection_file, collection_directory_path);
471 target_collection_file_relative_path = target_collection_file_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
472 progress_bar.setAction("Moving file " + source_collection_file_relative_path + " -> " + target_collection_file_relative_path + "...");
473
474 String move_collection_file_command = "cmd=move-collection-file";
475 move_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
[19231]476 move_collection_file_command += "&source=" + Base64.encodeBytes(source_collection_file_relative_path.getBytes());
477 move_collection_file_command += "&target=" + Base64.encodeBytes(target_collection_file_relative_path.getBytes());
478 //move_collection_file_command += "&source=" + URLEncoder.encode(source_collection_file_relative_path, "UTF-8");
479 //move_collection_file_command += "&target=" + URLEncoder.encode(target_collection_file_relative_path, "UTF-8");
[17612]480 action_output = remote.sendCommandToServer(move_collection_file_command, null);
481 }
482 }
483
484
485 /**
486 * --------------------------------------------------------------------------------------------
487 * NEW COLLECTION DIRECTORY
488 * --------------------------------------------------------------------------------------------
489 */
490 static class NewCollectionDirectoryAction
491 extends RemoteGreenstoneServerAction
492 {
493 private String collection_name;
494 private File new_collection_directory;
495
496 public NewCollectionDirectoryAction(String collection_name, File new_collection_directory)
497 {
498 this.collection_name = collection_name;
499 this.new_collection_directory = new_collection_directory;
500 }
501
502 public void perform()
503 throws Exception
504 {
505 String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
506 String new_collection_directory_relative_path = remote.getPathRelativeToDirectory(
507 new_collection_directory, collection_directory_path);
508 new_collection_directory_relative_path = new_collection_directory_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
509 progress_bar.setAction("Creating new directory " + new_collection_directory_relative_path + "...");
510
511 String new_collection_directory_command = "cmd=new-collection-directory";
512 new_collection_directory_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
513 new_collection_directory_command += "&directory=" + URLEncoder.encode(new_collection_directory_relative_path, "UTF-8");
514 action_output = remote.sendCommandToServer(new_collection_directory_command, null);
515 }
516 }
517
518
519 /**
520 * --------------------------------------------------------------------------------------------
521 * RUN SCRIPT
522 * --------------------------------------------------------------------------------------------
523 */
524 static class RunScriptAction
525 extends RemoteGreenstoneServerAction
526 {
527 private String collection_name;
528 private String script_name;
529 private String script_arguments;
530 private GShell shell;
531
532 public RunScriptAction(String collection_name, String script_name, String script_arguments, GShell shell)
533 {
534 this.collection_name = collection_name;
535 this.script_name = script_name;
536 this.script_arguments = script_arguments;
537 this.shell = shell;
538 }
539
540 public void perform()
541 throws Exception
542 {
543 progress_bar.setAction("Running " + script_name + "...");
544
545 String run_script_command = "cmd=run-script";
546 run_script_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
547 run_script_command += "&script=" + script_name;
548 run_script_command += "&language=" + Configuration.getLanguage();
549 run_script_command += script_arguments;
550 action_output = remote.sendCommandToServer(run_script_command, shell);
551 }
552 }
553
554
555 /**
556 * --------------------------------------------------------------------------------------------
557 * UPLOAD COLLECTION FILE
558 * --------------------------------------------------------------------------------------------
559 */
560 static class UploadCollectionFilesAction
561 extends RemoteGreenstoneServerAction
562 {
563 private String collection_name;
564 private File[] collection_files;
565
566
567 public UploadCollectionFilesAction(String collection_name, File[] collection_files)
568 {
569 this.collection_name = collection_name;
570 this.collection_files = collection_files;
571 }
572
573
574 public void perform()
575 throws Exception
576 {
577 progress_bar.setAction("Uploading collection files...");
578
579 // Determine the file paths relative to the collection directory
580 String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
581 String[] collection_file_relative_paths = new String[collection_files.length];
582 for (int i = 0; i < collection_files.length; i++) {
583 collection_file_relative_paths[i] = remote.getPathRelativeToDirectory(collection_files[i], collection_directory_path);
584 }
585
586 // Zip up the files to send to the server
587 String zip_file_name = collection_name + "-" + System.currentTimeMillis() + ".zip";
588 String zip_file_path = collection_directory_path + zip_file_name;
589 ZipTools.zipFiles(zip_file_path, collection_directory_path, collection_file_relative_paths);
590
591 // Upload the zip file
592 String upload_collection_file_command = "cmd=upload-collection-file";
593 upload_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
594 upload_collection_file_command += "&file=" + URLEncoder.encode(zip_file_name, "UTF-8");
595 upload_collection_file_command += "&directory=";
596 upload_collection_file_command += "&zip=true";
[19173]597 upload_collection_file_command += "&lr=" + remote.lang_region;
[17612]598 action_output = remote.uploadFile(upload_collection_file_command, zip_file_path);
599 }
600 }
601
602
603 /**
604 * --------------------------------------------------------------------------------------------
605 * UPLOAD FILES INTO COLLECTION
606 * --------------------------------------------------------------------------------------------
607 */
608 static class UploadFilesIntoCollectionAction
609 extends RemoteGreenstoneServerAction
610 {
611 private String collection_name;
612 private File[] source_files;
613 private File target_collection_directory;
614
615
616 public UploadFilesIntoCollectionAction(String collection_name, File[] source_files, File target_collection_directory)
617 {
[19668]618 this.collection_name = collection_name; //.replace('/', File.separatorChar); // if colgroup contained url slashes
[17612]619 this.source_files = source_files;
620 this.target_collection_directory = target_collection_directory;
621 }
622
623
624 public void perform()
625 throws Exception
626 {
627 String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name);
628 String target_collection_directory_relative_path = remote.getPathRelativeToDirectory(
629 target_collection_directory, collection_directory_path);
630 target_collection_directory_relative_path = target_collection_directory_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|");
631 progress_bar.setAction("Uploading files into collection...");
632
633 String zip_file_name = collection_name + "-" + System.currentTimeMillis() + ".zip";
634 String zip_file_path = Gatherer.getCollectDirectoryPath() + zip_file_name;
635 DebugStream.println("Zip file path: " + zip_file_path);
636
637 String base_directory_path = source_files[0].getParentFile().getAbsolutePath();
638 DebugStream.println("Base directory path: " + base_directory_path);
639 String[] source_file_relative_paths = new String[source_files.length];
640 for (int i = 0; i < source_files.length; i++) {
641 DebugStream.println("Source file path: " + source_files[i]);
642 source_file_relative_paths[i] = remote.getPathRelativeToDirectory(source_files[i], base_directory_path);
643 }
644
645 ZipTools.zipFiles(zip_file_path, base_directory_path, source_file_relative_paths);
646
647 String upload_collection_file_command = "cmd=upload-collection-file";
648 upload_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8");
649 upload_collection_file_command += "&file=" + URLEncoder.encode(zip_file_name, "UTF-8");
650 upload_collection_file_command += "&directory=" + URLEncoder.encode(target_collection_directory_relative_path, "UTF-8");
651 upload_collection_file_command += "&zip=true";
[19173]652 upload_collection_file_command += "&lr=" + remote.lang_region;
[17612]653 action_output = remote.uploadFile(upload_collection_file_command, zip_file_path);
654 }
655 }
[18646]656}
Note: See TracBrowser for help on using the repository browser.