- Timestamp:
- 2010-10-15T20:33:43+13:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r23031 r23143 102 102 static private String non_standard_collect_directory_path = null; 103 103 static public String open_collection_file_path = null; 104 static public String gsdlsite_collecthome = ""; 104 105 /** A public reference to the FileAssociationManager. */ 105 106 static public FileAssociationManager assoc_man; … … 315 316 if (fedora_info.isActive()) { 316 317 popupFedoraInfo(); 317 } 318 318 } 319 319 320 // the no_load flag to GLI is processed at the end of handling open_collection_file_path 320 321 open_collection_file_path = open_collection; 321 322 if (open_collection_file_path == null) { … … 323 324 "general.open_collection"+Configuration.gliPropertyNameSuffix(), true); 324 325 } 326 327 initCollectDirectoryPath(open_collection); 328 325 329 if (no_load || (isGsdlRemote && open_collection_file_path.equals(""))) { 326 330 open_collection_file_path = null; 327 // collectDirectoryHasChanged(); // make sure gsdlsite.cfg's collecthome defaults to GS' collect328 }329 330 // If opening a collection outside the standard GS collect folder, need331 // to open the non-standard collect folder that the collection resides in332 if (!isGsdlRemote333 && open_collection_file_path != null334 && !open_collection_file_path.startsWith(getDefaultGSCollectDirectoryPath(true)))335 {336 File collectFolder = null;337 338 if(!open_collection_file_path.equals("")) {339 340 if(!open_collection_file_path.endsWith("gli.col")) { // then it's a collect folder341 collectFolder = new File(open_collection_file_path);342 } else {343 // the filepath is a gli.col file. To get the collect folder: the 1st level344 // up is collection folder, 2 two levels up is the containing collect folder345 collectFolder = new File(open_collection_file_path).getParentFile().getParentFile();346 }347 348 // Need to deal with colgroups as well: while there's an etc/collect.cfg in the current349 // collectFolder, move one level up350 String cfg_file = (Gatherer.GS3)? Utility.CONFIG_GS3_FILE : Utility.CONFIG_FILE;351 if(new File(collectFolder.getAbsolutePath()+File.separator+cfg_file).exists()) { // colgroup352 collectFolder = collectFolder.getParentFile();353 }354 }355 356 if(collectFolder == null || !collectFolder.exists()) {357 // if GLI config file specified no collectDir (open_collection_file_path is "")358 // OR if dealing with a local server but the collectdir no longer exists,359 // use the default greenstone collect directory, and write that to affected files360 361 String defaultColDir = getDefaultGSCollectDirectoryPath(false); // no file separator at end362 open_collection_file_path = defaultColDir;363 364 setCollectDirectoryPath(defaultColDir); // will ensure the required file separator at end365 366 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(),367 true, "");368 369 if(Gatherer.GS3) { // GS2's gsdlsite.cfg was taken care of when LocalLibraryServer was started up370 // (LocalLibraryServer would also already have set glisite.cfg to the correct collecthome)371 String gsdlsitecfg = Configuration.gsdl3_path + File.separator372 + "WEB-INF" + File.separator + "cgi" + File.separator + "gsdl3site.cfg";373 Utility.updatePropertyConfigFile(gsdlsitecfg, "collecthome", defaultColDir); // no file separator374 // if gsdlsite.cfg does not exist (if using server.exe for instance), the above method will just return375 }376 } else { // remote GS, or collect dir exists (all config files will already be set since last GLI session)377 if(collectFolder == null) {378 setCollectDirectoryPath(getDefaultGSCollectDirectoryPath(false)); // no file separator at end379 } else {380 setCollectDirectoryPath(collectFolder.getAbsolutePath()); // now set this as the current collect folder381 }382 }383 331 } 384 332 … … 711 659 // Flush debug 712 660 DebugStream.closeDebugStream(); 713 661 714 662 // If we started a server, we should try to stop it. 715 if (LocalLibraryServer.isRunning() == true) { 663 if (LocalLibraryServer.isRunning() == true) { 716 664 LocalLibraryServer.stop(); 717 665 } … … 751 699 752 700 } 701 702 // if we need to know whether the local server we are running is server.exe vs apache web server 703 static public boolean isPersistentServer() { 704 return (!isGsdlRemote && LocalLibraryServer.isPersistentServer()); 705 } 753 706 754 707 /** Returns the path of the Greenstone "collect" directory. */ … … 835 788 } 836 789 790 791 public static void initCollectDirectoryPath(String open_collection) { 792 String defaultColdir = getDefaultGSCollectDirectoryPath(false); // no file separator at end 793 String coldir = defaultColdir; 794 // If local GS and opening a collection outside the standard GS collect folder, 795 // need to open the non-standard collect folder that the collection resides in 796 if (!isGsdlRemote 797 && !open_collection_file_path.startsWith(defaultColdir)) 798 { 799 File collectFolder = null; 800 801 if(!open_collection_file_path.equals("")) { 802 if(!open_collection_file_path.endsWith("gli.col")) { // then it's a collect folder 803 collectFolder = new File(open_collection_file_path); 804 } else { 805 // the filepath is a gli.col file. To get the collect folder: the 1st level up 806 // is the collection folder, 2 two levels up is the containing collect folder 807 collectFolder = new File(open_collection_file_path).getParentFile().getParentFile(); 808 } 809 810 // Need to deal with colgroups as well: while there's an etc/collect.cfg 811 // in the current collectFolder, move one level up 812 String cfg_file = (Gatherer.GS3)? Utility.CONFIG_GS3_FILE : Utility.CONFIG_FILE; 813 if(new File(collectFolder.getAbsolutePath()+File.separator+cfg_file).exists()) { // colgroup 814 collectFolder = collectFolder.getParentFile(); 815 } 816 } 817 818 if(collectFolder == null || !collectFolder.exists()) { 819 // if GLI config file specified no collectDir (open_collection_file_path is "") 820 // OR if dealing with a local server but the collectdir no longer exists, 821 // use the default greenstone collect directory, and write that to affected files 822 823 open_collection_file_path = defaultColdir; // default GS collect dir 824 // Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), true, ""); 825 } else { // use the coldir value specified in the flags to GLI or from the last GLI session 826 coldir = collectFolder.getAbsolutePath(); 827 } 828 // set it as the current folder 829 setCollectDirectoryPath(coldir); // will ensure the required file separator at end 830 } 831 832 if(!isGsdlRemote) { 833 // LocalLibraryServer would already have set glisite.cfg to the correct collecthome for server.exe 834 // Here we set collecthome in gsdl(3)site.cfg for the GS2 apache web server and GS3 tomcat server 835 String gsdlsitecfg = getGsdlSiteConfigFile(); 836 // update the gsdlsite config file and store the old value for use when we exit GLI 837 if(coldir.equals(defaultColdir)) { 838 gsdlsite_collecthome = Utility.updatePropertyConfigFile( 839 gsdlsitecfg, "collecthome", null); 840 } else { 841 gsdlsite_collecthome = Utility.updatePropertyConfigFile( 842 gsdlsitecfg, "collecthome", coldir); // no file separator 843 // if gsdlsite.cfg does not exist (if using server.exe for instance), the above method will just return 844 } 845 } 846 } 847 848 /** depending on the version of GS being run, return the path to the current GS' installation's gsdl(3)site.cfg */ 849 public static String getGsdlSiteConfigFile() { 850 if(Gatherer.GS3) { // web/WEB-INF/cgi/gsdl3site.cfg 851 return Configuration.gsdl3_path + File.separator + "WEB-INF" 852 + File.separator + "cgi" + File.separator + "gsdl3site.cfg"; 853 } else { // cgi-bin/gsdlsite.cfg 854 return Configuration.gsdl_path + File.separator 855 + "cgi-bin" + File.separator + "gsdlsite.cfg"; 856 } 857 } 837 858 838 859 public static void collectDirectoryHasChanged( … … 885 906 return; 886 907 } 887 888 String gsdlsitecfg = ""; 889 if(Gatherer.GS3) { // web/WEB-INF/cgi/gsdl3site.cfg 890 gsdlsitecfg = Configuration.gsdl3_path + File.separator + "WEB-INF" 891 + File.separator + "cgi" + File.separator + "gsdl3site.cfg"; 892 } else { // cgi-bin/gsdlsite.cfg 893 gsdlsitecfg = Configuration.gsdl_path + File.separator 894 + "cgi-bin" + File.separator + "gsdlsite.cfg"; 895 } 896 908 897 909 // non-destructive update of gsdl(3)site.cfg (comments preserved) 898 910 String collectDir = Gatherer.getCollectDirectoryPath(); 899 911 //collectDir = "\"" + collectDir.substring(0, collectDir.length()-1) + "\""; // remove file separator at end 900 912 collectDir = collectDir.substring(0, collectDir.length()-1); // remove file separator at end 901 Utility.updatePropertyConfigFile(g sdlsitecfg, "collecthome", collectDir);913 Utility.updatePropertyConfigFile(getGsdlSiteConfigFile(), "collecthome", collectDir); 902 914 // if gsdlsite.cfg does not exist (if using server.exe for instance), the above method will just return 903 915
Note:
See TracChangeset
for help on using the changeset viewer.