- 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/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
Note:
See TracChangeset
for help on using the changeset viewer.