Changeset 4357
- Timestamp:
- 2003-05-27T15:23:23+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/util/GSDLSiteConfig.java
r4332 r4357 8 8 private File gsdlsite_cfg; 9 9 private String autoenter_initial; 10 private String start_browser_initial; 11 12 static final public String ADD_COMMAND = "a=config&cmd=add-collection&c="; 13 static final public String RELEASE_COMMAND = "a=config&cmd=release-collection&c="; 14 static final public String QUIT_COMMAND = "a="; 15 10 16 static final private String AUTOENTER = "autoenter"; 11 17 static final private String COLON = ":"; … … 16 22 static final private String PORTNUMBER = "portnumber"; 17 23 static final private String SEPARATOR = "/"; 24 static final private String STARTBROWSER = "start_browser"; 18 25 static final private String TRUE = "1"; 19 26 static final private String URL = "url"; 27 20 28 public GSDLSiteConfig(File server_exe) { 21 System.err.println("New GSDLSiteConfig for: " + server_exe.getAbsolutePath());29 debug("New GSDLSiteConfig for: " + server_exe.getAbsolutePath()); 22 30 gsdlsite_cfg = new File(server_exe.getParentFile(), GSDLSITE_CFG); 23 31 24 32 autoenter_initial = null; 33 start_browser_initial = null; 25 34 load(); 26 35 } … … 48 57 } 49 58 temp.append(enterlib); 50 59 } 51 60 enterlib = null; 52 61 url = temp.toString(); 53 62 } 54 System.err.println("Found Local Library Address: " + url);63 debug("Found Local Library Address: " + url); 55 64 return url; 56 65 } 57 66 58 67 public void load() { 59 System.err.println("Load: " + gsdlsite_cfg.getAbsolutePath()); 60 clear(); 61 try { 62 BufferedReader in = new BufferedReader(new FileReader(gsdlsite_cfg)); 63 String line = null; 64 while((line = in.readLine()) != null) { 65 String key = null; 66 String value = null; 67 int index = -1; 68 if((index = line.indexOf("=")) != -1 && line.length() >= index + 1) { 69 key = line.substring(0, index); 70 value = line.substring(index + 1); 68 if(gsdlsite_cfg.exists()) { 69 debug("Load: " + gsdlsite_cfg.getAbsolutePath()); 70 clear(); 71 try { 72 BufferedReader in = new BufferedReader(new FileReader(gsdlsite_cfg)); 73 String line = null; 74 while((line = in.readLine()) != null) { 75 String key = null; 76 String value = null; 77 int index = -1; 78 if((index = line.indexOf("=")) != -1 && line.length() >= index + 1) { 79 key = line.substring(0, index); 80 value = line.substring(index + 1); 81 } 82 else { 83 key = line; 84 } 85 put(key, value); 71 86 } 72 else { 73 key = line; 74 } 75 put(key, value); 87 } 88 catch (Exception error) { 89 error.printStackTrace(); 76 90 } 77 91 } 78 catch (Exception error){79 error.printStackTrace();92 else { 93 debug("No GSDLsite.cfg file can be found!"); 80 94 } 81 95 } 82 96 83 97 /** Restore the autoenter value to its initial value, and remove url if present. */ 84 public void restoreAutoEnter() { 85 System.err.println("Restore AutoEnter"); 86 put(AUTOENTER, autoenter_initial); 87 remove(URL); 98 public void restore() { 99 debug("Restore Initial Settings"); 100 put(AUTOENTER, autoenter_initial); 101 put(STARTBROWSER, start_browser_initial); 102 remove(URL); 103 save(); 104 } 105 106 public void set() { 107 debug("Set Session Settings"); 108 if(autoenter_initial == null) { 109 autoenter_initial = (String) get(AUTOENTER); 110 debug("Remember autoenter was: " + autoenter_initial); 111 } 112 put(AUTOENTER, TRUE); 113 if(start_browser_initial == null) { 114 start_browser_initial = (String) get(STARTBROWSER); 115 debug("Remember start_browser was: " + start_browser_initial); 116 } 88 117 save(); 89 118 } 90 119 91 public void setAutoEnter() { 92 System.err.println("Set AutoEnter."); 93 if(autoenter_initial == null) { 94 autoenter_initial = (String) get(AUTOENTER); 95 System.err.println("Remember autoenter was: " + autoenter_initial); 96 } 97 put(AUTOENTER, TRUE); 98 save(); 120 private void debug(String message) { 121 System.err.println(message); 99 122 } 100 123 101 124 private void save() { 102 System.err.println("Save: " + gsdlsite_cfg.getAbsolutePath());125 debug("Save: " + gsdlsite_cfg.getAbsolutePath()); 103 126 try { 104 127 BufferedWriter out = new BufferedWriter(new FileWriter(gsdlsite_cfg, false));
Note:
See TracChangeset
for help on using the changeset viewer.