Changeset 9095 for trunk/gli/src/org/greenstone/gatherer/shell/GShell.java
- Timestamp:
- 2005-02-18T12:31:54+13:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/shell/GShell.java
r9049 r9095 227 227 protected void runRemote(String[] args, BufferedOutputStream bos) 228 228 { 229 if(hasSignalledStop()) { return; } 230 int error_count = 0; 231 StringBuffer error_list = new StringBuffer(); 229 232 try { 230 233 if (type == IMPORT) { 234 String col_name = args[args.length-1]; 235 if (progress!=null) { 236 progress.messageOnProgressBar("Uploading data to server"); 237 } 238 239 String collect_directory_path = Gatherer.getCollectDirectoryPath(); 240 241 // zip up import folder 242 Utility.zipup(collect_directory_path, col_name, "import", this); 243 244 if(hasSignalledStop()) { return; } 245 // upload it to gsdl server 246 GathererApplet.upload_url_zip(col_name, "import", this); 247 248 if(hasSignalledStop()) { return; } 249 // upload etc folder to server (need collect.cfg and any hfiles) 250 Utility.zipup(collect_directory_path, col_name, "etc", this); 251 252 if(hasSignalledStop()) { return; } 253 GathererApplet.upload_url_zip(col_name, "etc", this); 254 255 String collection_directory_path = Gatherer.c_man.getCollectionDirectoryPath(col_name); 256 File img_dir = new File(Gatherer.c_man.getCollectionImagesDirectoryPath()); 257 if (img_dir.exists() && img_dir.list().length > 0) { 258 // upload images/ directory to server 259 if(hasSignalledStop()) { return; } 260 Utility.zipup(collect_directory_path, col_name, "images", this); 261 262 if(hasSignalledStop()) { return; } 263 GathererApplet.upload_url_zip(col_name, "images", this); 264 } 265 266 if(hasSignalledStop()) { return; } 267 // see if collection specific image needs uploading 268 CollectionMetaManager cmm 269 = CollectionDesignManager.collectionmeta_manager; 270 271 CollectionMeta icon_collection_collectionmeta 272 = cmm.getMetadatum(CollectionConfiguration.COLLECTIONMETADATA_ICONCOLLECTION_STR); 273 CollectionMeta icon_collection_small_collectionmeta 274 = cmm.getMetadatum(CollectionConfiguration.COLLECTIONMETADATA_ICONCOLLECTIONSMALL_STR); 275 276 String ics_text = icon_collection_collectionmeta.getValue(CollectionMeta.TEXT); 277 String icsc_text = icon_collection_small_collectionmeta.getValue(CollectionMeta.TEXT); 278 if ((ics_text != null) && (ics_text != "")) { 279 // Stub code for detecting when collectoin image changed 280 // => need to upload images 281 // System.err.println("**** ics_text = " + ics_text); 282 } 283 284 if (progress!=null) { 285 progress.messageOnProgressBar(""); 286 } 287 } 288 289 if(hasSignalledStop()) { return; } 231 290 String perl_cmd = args[0]; 232 291 int perl_cmd_root = perl_cmd.lastIndexOf(File.separator); 233 292 234 293 if (perl_cmd_root > 0) { 235 294 String perl_cmd_cut = perl_cmd.substring(perl_cmd_root+1); 236 295 perl_cmd = perl_cmd_cut; 237 296 } 238 297 239 298 String launch = Gatherer.cgiBase + "launch"; 240 299 launch = launch + "?cmd=" + perl_cmd; 241 300 242 301 for(int i = 1; i<args.length; i++) { 243 302 244 303 String arg = args[i]; 245 304 246 305 if (arg.equals("-collectdir") || arg.equals("-importdir") 247 306 || arg.equals("-builddir")) { … … 250 309 continue; 251 310 } 252 311 253 312 launch += "&"; 254 313 255 314 if(arg.startsWith(StaticStrings.MINUS_CHARACTER)) { 256 315 String name = arg.substring(1); … … 268 327 } 269 328 } 270 329 271 330 System.err.println("**** launch url = " + launch); 272 331 // fireMessage(type, Dictionary.get("GShell.Command") + ": " + launch, status, null); // **** 273 332 274 333 URL launch_url = new URL(launch); 275 334 URLConnection launch_connection = launch_url.openConnection(); 276 335 InputStream stdis = launch_connection.getInputStream(); 277 336 InputStreamReader stdisr = new InputStreamReader(stdis, "UTF-8"); 278 337 279 338 BufferedReader stdbr = new BufferedReader(stdisr); 280 281 StringBuffer error_list = new StringBuffer(); 282 int error_count = 0; 283 339 284 340 if (type == GShell.NEW) { 285 341 while(true) { … … 295 351 error_count = check_for_error(line,error_list,error_count); 296 352 fireMessage(type, typeAsString(type) + "> " + line, status, bos); 297 } 353 } 354 System.err.println("Wants to stop (1)."); 298 355 } 299 356 stdbr.close(); 300 357 301 358 if (error_count>0) { 302 359 status = ERROR; … … 305 362 fireMessage(type, typeAsString(type) + "> " + error_list, status, null); 306 363 } 364 } 365 else if(hasSignalledStop()) { 366 //User pressed the cancel button. 367 //Status already set in hasSignalledStop method. 307 368 } 308 369 else { … … 458 519 } 459 520 460 if (Gatherer.isGsdlRemote) {461 if (type == IMPORT) {462 if (progress!=null) {463 progress.messageOnProgressBar("Uploading data to server");464 }465 466 String collect_directory_path = Gatherer.getCollectDirectoryPath();467 468 // zip up import folder469 Utility.zipup(collect_directory_path, col_name, "import");470 // upload it to gsdl server471 GathererApplet.upload_url_zip(col_name, "import");472 473 // upload etc folder to server (need collect.cfg and any hfiles)474 Utility.zipup(collect_directory_path, col_name, "etc");475 GathererApplet.upload_url_zip(col_name, "etc");476 477 String collection_directory_path = Gatherer.c_man.getCollectionDirectoryPath(col_name);478 File img_dir = new File(Gatherer.c_man.getCollectionImagesDirectoryPath());479 if (img_dir.exists() && img_dir.list().length > 0) {480 // upload images/ directory to server481 Utility.zipup(collect_directory_path, col_name, "images");482 GathererApplet.upload_url_zip(col_name, "images");483 }484 485 // see if collection specific image needs uploading486 CollectionMetaManager cmm487 = CollectionDesignManager.collectionmeta_manager;488 489 CollectionMeta icon_collection_collectionmeta490 = cmm.getMetadatum(CollectionConfiguration.COLLECTIONMETADATA_ICONCOLLECTION_STR);491 CollectionMeta icon_collection_small_collectionmeta492 = cmm.getMetadatum(CollectionConfiguration.COLLECTIONMETADATA_ICONCOLLECTIONSMALL_STR);493 494 String ics_text = icon_collection_collectionmeta.getValue(CollectionMeta.TEXT);495 String icsc_text = icon_collection_small_collectionmeta.getValue(CollectionMeta.TEXT);496 if ((ics_text != null) && (ics_text != "")) {497 // Stub code for detecting when collectoin image changed498 // => need to upload images499 // System.err.println("**** ics_text = " + ics_text);500 }501 502 503 if (progress!=null) {504 progress.messageOnProgressBar("");505 }506 507 }508 }509 510 511 521 // Issue a processBegun event 512 522 fireProcessBegun(type, status); … … 521 531 if (type == NEW) { 522 532 if (Gatherer.isGsdlRemote) { 523 GathererApplet.download_url_zip(col_name,"."); 524 Utility.unzip(Gatherer.getCollectDirectoryPath(), col_name); 533 GathererApplet.download_url_zip(col_name, ".", this); 534 if (!hasSignalledStop()) { 535 Utility.unzip(Gatherer.getCollectDirectoryPath(), col_name); 536 } 525 537 } 526 538 } … … 535 547 536 548 Utility.delete(Gatherer.c_man.getCollectionArchivesDirectoryPath()); // remove current archives 537 GathererApplet.download_url_zip(col_name,"archives"); 538 Utility.unzip(Gatherer.getCollectDirectoryPath(), col_name); 539 540 if (progress!=null) { 541 progress.messageOnProgressBar(""); 542 } 549 GathererApplet.download_url_zip(col_name, "archives", this); 550 if (!hasSignalledStop()) { 551 Utility.unzip(Gatherer.getCollectDirectoryPath(), col_name); 552 } 553 if (progress!=null) { 554 progress.messageOnProgressBar(""); 555 } 543 556 } 544 557 … … 560 573 Utility.delete(buildDir); // remove current build dir 561 574 buildDir.mkdir(); //Make a clean dir 562 GathererApplet.download_url_zip(col_name,"building/build.cfg"); //Only need build.cfg 563 Utility.unzip(Gatherer.getCollectDirectoryPath(), col_name); 564 575 GathererApplet.download_url_zip(col_name, "building/build.cfg", this); //Only need build.cfg 576 if (!hasSignalledStop()) { 577 Utility.unzip(Gatherer.getCollectDirectoryPath(), col_name); 578 } 579 565 580 if (progress!=null) { 566 581 progress.messageOnProgressBar(""); … … 570 585 } 571 586 572 if(hasSignalledStop()) {573 status = CANCELLED;574 }575 587 // We're done. 576 588 fireProcessComplete(type, status); … … 678 690 * @return A <strong>boolean</strong> indicating if the user wanted to stop. 679 691 */ 680 p rivateboolean hasSignalledStop() {692 public boolean hasSignalledStop() { 681 693 boolean has_signalled_stop = false; 682 694 if(progress != null) { 683 695 has_signalled_stop = progress.hasSignalledStop(); 696 } 697 if(has_signalled_stop) { 698 status = CANCELLED; 684 699 } 685 700 return has_signalled_stop;
Note:
See TracChangeset
for help on using the changeset viewer.