- Timestamp:
- 2010-10-02T22:11:29+13:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r22911 r23015 316 316 popupFedoraInfo(); 317 317 } 318 319 open_collection_file_path = open_collection; 320 if (open_collection_file_path == null) { 321 open_collection_file_path = Configuration.getString( 322 "general.open_collection"+Configuration.gliPropertyNameSuffix(), true); 323 } 324 if (no_load) { 325 open_collection_file_path = null; 326 // collectDirectoryHasChanged(); // make sure gsdlsite.cfg's collecthome defaults to GS' collect 327 } 328 329 // If opening a collection outside the standard GS collect folder, need 330 // to open the non-standard collect folder that the collection resides in 331 if (open_collection_file_path != null && 332 !open_collection_file_path.startsWith(getDefaultGSCollectDirectoryPath(true))) { 333 File collectFolder = null; 334 335 if(!open_collection_file_path.equals("")) { 336 337 if(!open_collection_file_path.endsWith("gli.col")) { // then it's a collect folder 338 collectFolder = new File(open_collection_file_path); 339 } else { 340 // the filepath is a gli.col file. To get the collect folder: the 1st level 341 // up is collection folder, 2 two levels up is the containing collect folder 342 collectFolder = new File(open_collection_file_path).getParentFile().getParentFile(); 343 } 344 345 // Need to deal with colgroups as well: while there's an etc/collect.cfg in the current 346 // collectFolder, move one level up 347 String cfg_file = (Gatherer.GS3)? Utility.CONFIG_GS3_FILE : Utility.CONFIG_FILE; 348 if(new File(collectFolder.getAbsolutePath()+File.separator+cfg_file).exists()) { // colgroup 349 collectFolder = collectFolder.getParentFile(); 350 } 351 } 352 353 if(!isGsdlRemote && (collectFolder == null || !collectFolder.exists())) { 354 // if GLI config file specified no collectDir (open_collection_file_path is "") 355 // OR if dealing with a local server but the collectdir no longer exists, 356 // use the default greenstone collect directory, and write that to affected files 357 358 String defaultColDir = getDefaultGSCollectDirectoryPath(false); // no file separator at end 359 open_collection_file_path = defaultColDir; 360 361 setCollectDirectoryPath(defaultColDir); // will ensure the required file separator at end 362 363 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), 364 true, ""); 365 366 if(Gatherer.GS3) { // GS2's gsdlsite.cfg was taken care of when LocalLibraryServer was started up 367 // (LocalLibraryServer would also already have set glisite.cfg to the correct collecthome) 368 String gsdlsitecfg = Configuration.gsdl3_path + File.separator 369 + "WEB-INF" + File.separator + "cgi" + File.separator + "gsdl3site.cfg"; 370 Utility.updatePropertyConfigFile(gsdlsitecfg, "collecthome", defaultColDir); // no file separator 371 // if gsdlsite.cfg does not exist (if using server.exe for instance), the above method will just return 372 } 373 } else { // remote GS, or collect dir exists (all config files will already be set since last GLI session) 374 if(collectFolder == null) { 375 setCollectDirectoryPath(getDefaultGSCollectDirectoryPath(false)); // no file separator at end 376 } else { 377 setCollectDirectoryPath(collectFolder.getAbsolutePath()); // now set this as the current collect folder 378 } 379 380 } 381 } 318 382 319 383 // Finally, we're ready to find out the version of the remote Greenstone server … … 353 417 } 354 418 else { // local greenstone: Start up the local library server, if that's what we want 355 if (!GS3) { 419 if (!GS3) { 356 420 isLocalLibrary = LocalLibraryServer.start(gsdl_path, local_library_path); 357 421 } … … 492 556 } 493 557 } 494 495 open_collection_file_path = open_collection; 496 if (open_collection_file_path == null) { 497 open_collection_file_path = Configuration.getString( 498 "general.open_collection"+Configuration.gliPropertyNameSuffix(), true); 499 } 500 if (no_load || open_collection_file_path.equals("")) { 501 open_collection_file_path = null; 502 // collectDirectoryHasChanged(); // make sure gsdlsite.cfg's collecthome defaults to GS' collect 503 } 504 505 // If opening a collection outside the standard GS collect folder, need 506 // to open the non-standard collect folder that the collection resides in 507 if (open_collection_file_path != null && 508 !open_collection_file_path.startsWith(getDefaultGSCollectDirectoryPath(true))) { 509 File collectFolder = null; 510 if(!open_collection_file_path.endsWith("gli.col")) { // then it's a collect folder 511 collectFolder = new File(open_collection_file_path); 512 } else { 513 // the filepath is a gli.col file. To get the collect folder: the 1st level 514 // up is collection folder, 2 two levels up is the containing collect folder 515 collectFolder = new File(open_collection_file_path).getParentFile().getParentFile(); 516 } 517 518 // Need to deal with colgroups as well: while there's an etc/collect.cfg in the current 519 // collectFolder, move one level up 520 String cfg_file = (Gatherer.GS3)? Utility.CONFIG_GS3_FILE : Utility.CONFIG_FILE; 521 if(new File(collectFolder.getAbsolutePath()+File.separator+cfg_file).exists()) { // colgroup 522 collectFolder = collectFolder.getParentFile(); 523 } 524 525 if(!isGsdlRemote && !collectFolder.exists()) { 526 // if dealing with a local server but the collectdir no longer exists, 527 // use the default greenstone collect directory, and write that to affected files 528 open_collection_file_path = null; // no longer have an open collection from last time if coldir doesn't exist 529 530 String defaultColDir = getDefaultGSCollectDirectoryPath(false); // no file separator at end 531 532 setCollectDirectoryPath(defaultColDir); // will ensure the required file separator at end 533 534 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), 535 true, defaultColDir + File.separator); 536 537 if(Gatherer.GS3) { // GS2's gsdlsite.cfg was taken care of when LocalLibraryServer was started up 538 // (LocalLibraryServer would also already have set glisite.cfg to the correct collecthome) 539 String gsdlsitecfg = Configuration.gsdl3_path + File.separator 540 + "WEB-INF" + File.separator + "cgi" + File.separator + "gsdl3site.cfg"; 541 Utility.updatePropertyConfigFile(gsdlsitecfg, "collecthome", defaultColDir); // no file separator 542 } 543 } else { // remote GS or collect dir exists 544 setCollectDirectoryPath(collectFolder.getAbsolutePath()); // now set this as the current collect folder 545 } 546 } 558 547 559 } catch (Exception exception) { 548 560 DebugStream.printStackTrace(exception); … … 646 658 }*/ 647 659 648 // If there was a collection left open last time, reopen it 649 if (open_collection_file_path == null ) {660 // If there was a collection left open last time, reopen it 661 if (open_collection_file_path == null || new File(Gatherer.open_collection_file_path).isDirectory()) { 650 662 651 663 //the menu bar items, file and edit, are disabled from the moment of their creation. if there is no left-over collection from the last session, enable them; otherwise it is untill the collection finishes loading, will they be enabled in collectionManager.java … … 823 835 public static void collectDirectoryHasChanged( 824 836 String oldCollectPath, String newCollectPath, final Component container) 825 { 837 { 838 if(oldCollectPath.equals(newCollectPath)) { 839 return; // nothing to be done 840 } 841 826 842 // Will use a busy cursor if the process of changing the collect directory takes more 827 843 // than half a second/500ms. See http://www.catalysoft.com/articles/busyCursor.html … … 838 854 timer.schedule(timerTask, 500); 839 855 840 if(oldCollectPath.equals(newCollectPath)) {841 return; // nothing to be done842 }843 844 856 // first save any open collection in the old location, then close it 845 857 if(Gatherer.c_man.getCollection() != null) { … … 848 860 849 861 // change to new collect path 850 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), 862 if(newCollectPath.equals(getDefaultGSCollectDirectoryPath(true))) { 863 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), 864 true, ""); 865 } else { 866 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), 851 867 true, newCollectPath); 868 } 852 869 Gatherer.setCollectDirectoryPath(newCollectPath); 853 870
Note:
See TracChangeset
for help on using the changeset viewer.