Changeset 23015
- Timestamp:
- 2010-10-02T22:11:29+13:00 (14 years ago)
- Location:
- main/trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 4 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 -
main/trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r22807 r23015 1161 1161 public void loadCollection(String collection_file_path) 1162 1162 { 1163 if(new File(collection_file_path).isDirectory()) { // collect folder instead of previously-opened collection1164 Gatherer.setMenuBarEnabled(true);1165 return; // nothing else to be done, no collection to open1166 }1167 1168 1163 // Display a modal progress popup to indicate that the collection is being loaded 1169 1164 ModalProgressPopup load_collection_progress_popup = new ModalProgressPopup(Dictionary.get("CollectionManager.Loading_Collection"), Dictionary.get("CollectionManager.Loading_Collection_Please_Wait")); … … 1562 1557 1563 1558 public void openCollectionFromLastTime() { 1564 // If there was an open collection last session, reopen it 1565 if (Gatherer.open_collection_file_path != null) { 1566 // Load the collection now 1567 loadCollection(Gatherer.open_collection_file_path); 1568 } 1569 1559 // If there was an open collection last session, reopen it. 1560 // Skip if there was none or only a collect folder instead of any previously-opened collection 1561 if (Gatherer.open_collection_file_path != null 1562 && !(new File(Gatherer.open_collection_file_path).isDirectory())) { 1563 // Load the collection now 1564 loadCollection(Gatherer.open_collection_file_path); 1565 } 1570 1566 } 1571 1567 -
main/trunk/gli/src/org/greenstone/gatherer/greenstone/LocalLibraryServer.java
r22911 r23015 696 696 // GS2. We're in the constructor, so we'll be running the LLS the first time 697 697 // Set the correct collectdir (from last time) before the server is started up 698 String collectDir = Configuration.getString("general.open_collection_gs2", true); 699 String defaultColDir = Gatherer.getDefaultGSCollectDirectoryPath(false); // no file separator at end 698 699 //String collectDir = Configuration.getString("general.open_collection_gs2", true); 700 String orig_collection_path = Configuration.getString("general.open_collection_gs2", true); 701 String collectDir = Gatherer.getCollectDirectoryPath(); 702 String defaultColDir = Gatherer.getDefaultGSCollectDirectoryPath(true); // with file separator at end 703 700 704 // If opening a collection outside the standard GS collect folder, need 701 // to open the non-standard collect folder that the collection resides in 702 if (!collectDir.startsWith(defaultColDir + File.separator)) { 703 File collectFolder = null; 704 if(!collectDir.endsWith("gli.col")) { // then it's a collect folder 705 collectFolder = new File(collectDir); 706 } else { 707 // the filepath is a gli.col file. To get the collect folder: the 1st level 708 // up is collection folder, 2 two levels up is the containing collect folder 709 collectFolder = new File(collectDir).getParentFile().getParentFile(); 710 } 711 712 // Need to deal with colgroups as well: while there's an etc/collect.cfg 713 // in the current collectFolder, move one level up 714 if(new File(collectFolder.getAbsolutePath()+File.separator+Utility.CONFIG_FILE).exists()) { 715 collectFolder = collectFolder.getParentFile(); 716 } 717 718 // if the collectdir from last time no longer exists this time, 719 // go back to Greenstone default collect dir 720 if(collectFolder.exists()) { 721 collectDir = collectFolder.getAbsolutePath(); 722 if(collectDir.endsWith(File.separator)) { 723 collectDir = collectDir.substring(0, collectDir.length()-1); 724 } 725 } else { 726 collectDir = defaultColDir; 727 // necessary for local apache web server: update gsdlsite.cfg with the reverted collectdir 728 String gsdlsitecfg = Configuration.gsdl_path + File.separator 729 + "cgi-bin" + File.separator + "gsdlsite.cfg"; 730 Utility.updatePropertyConfigFile(gsdlsitecfg, "collecthome", collectDir); // no file separator at end 731 // if gsdlsite.cfg does not exist (if using server.exe for instance), the above method will just return 732 } 733 734 // if we're running *server.exe* and if the current collect dir at Local Lib's startup 735 // is anything other than the default GS collect dir or if we changed back to the default 736 // collect dir because the non-standard collectDir didn't exist, then write out 737 // the new collectDir (minus file separator at end) to the lls site conf in use 705 // to open the non-standard collect folder that the collection resides in. 706 // Also, would have been forced to change the loaded collection--and hence collectDir-- 707 // to the default coldir if orig_col_path was "" or led to a collectdir that didn't exist 708 // (in the last case, gsdlsite.cfg already corrected in Gatherer if coldir was changed). 709 710 if(orig_collection_path.equals("")) { // default GS collect dir path 711 return; 712 } 713 714 if (Gatherer.open_collection_file_path != null // may be null if no_load was specified on GLI startup 715 && (!orig_collection_path.startsWith(collectDir) // if coldir would've been changed on startup OR if coldir is non-standard collect folder 716 || !collectDir.equals(defaultColDir))) 717 { 718 // if we're running *server.exe* and if the current collect dir at Local Lib's startup is 719 // anything other than the default GS collect dir or if we changed back to the default collect 720 // dir because the non-standard collectDir didn't exist/wasn't specified in the GLI config 721 // file, then write out the new collectDir (minus file separator at end) to the lls site conf in use 738 722 if (isPersistentServer) { // server.exe, so we're dealing with a local GS2 739 723 put(COLLECTHOME, collectDir); 740 724 save(); 741 725 lastModified = configFile.lastModified(); 742 } 743 744 } // now the correct current collect dir will get loaded when the server is started up hereafter 726 } 727 } // now the correct current collect dir will get loaded when the server is started up hereafter 745 728 } 746 729 -
main/trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java
r22686 r23015 510 510 else { 511 511 // if there was no open collection, then write out the collect dir path for next time 512 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), 513 true, Gatherer.getCollectDirectoryPath()); // null 512 // IF this is not the default collect directory 513 if(Gatherer.getCollectDirectoryPath().equals( 514 Gatherer.getDefaultGSCollectDirectoryPath(true))) { 515 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), 516 true, ""); 517 } else { 518 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), 519 true, Gatherer.getCollectDirectoryPath()); 520 } 514 521 } 515 522
Note:
See TracChangeset
for help on using the changeset viewer.