Changeset 4332
- Timestamp:
- 2003-05-26T16:22:56+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/util/GSDLSiteConfig.java
r4298 r4332 2 2 3 3 import java.io.*; 4 import java.util. LinkedHashMap;4 import java.util.*; 5 5 6 6 public class GSDLSiteConfig … … 12 12 static final private String ENTERLIB = "enterlib"; 13 13 static final private String FALSE = "0"; 14 static final private String GSDL = "gsdl"; 14 15 static final private String GSDLSITE_CFG = "gsdlsite.cfg"; 15 16 static final private String PORTNUMBER = "portnumber"; … … 18 19 static final private String URL = "url"; 19 20 public GSDLSiteConfig(File server_exe) { 21 System.err.println("New GSDLSiteConfig for: " + server_exe.getAbsolutePath()); 20 22 gsdlsite_cfg = new File(server_exe.getParentFile(), GSDLSITE_CFG); 21 23 22 24 autoenter_initial = null; 23 25 load(); 24 if(autoenter_initial == null) { 25 autoenter_initial = get(AUTOENTER); 26 } 27 put(AUTOENTER, TRUE); 28 save(); 26 } 27 28 public boolean exists() { 29 return gsdlsite_cfg.exists(); 29 30 } 30 31 31 32 public String getURL() { 32 33 // URL is made from url and portnumber 33 String url = get(URL);34 String url = (String) get(URL); 34 35 if(url != null) { 35 36 StringBuffer temp = new StringBuffer(url); 36 37 temp.append(COLON); 37 temp.append(get(PORTNUMBER)); 38 temp.append(SEPARATOR); 39 temp.append(ENTERLIB); 38 temp.append((String)get(PORTNUMBER)); 39 String enterlib = (String)get(ENTERLIB); 40 if(enterlib == null || enterlib.length() == 0) { 41 // Use the default /gsdl and hope for the best. 42 temp.append(SEPARATOR); 43 temp.append(GSDL); 44 } 45 else { 46 if(!enterlib.startsWith(SEPARATOR)) { 47 temp.append(SEPARATOR); 48 } 49 temp.append(enterlib); 50 } 51 enterlib = null; 40 52 url = temp.toString(); 41 53 } 54 System.err.println("Found Local Library Address: " + url); 42 55 return url; 43 56 } 44 57 45 58 public void load() { 59 System.err.println("Load: " + gsdlsite_cfg.getAbsolutePath()); 46 60 clear(); 47 61 try { … … 68 82 69 83 /** Restore the autoenter value to its initial value, and remove url if present. */ 70 public void restore() { 84 public void restoreAutoEnter() { 85 System.err.println("Restore AutoEnter"); 71 86 put(AUTOENTER, autoenter_initial); 72 87 remove(URL); … … 74 89 } 75 90 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(); 99 } 100 76 101 private void save() { 102 System.err.println("Save: " + gsdlsite_cfg.getAbsolutePath()); 77 103 try { 78 104 BufferedWriter out = new BufferedWriter(new FileWriter(gsdlsite_cfg, false)); 79 105 for(Iterator keys = keySet().iterator(); keys.hasNext(); ) { 80 106 String key = (String) keys.next(); 81 String value = get(key); 107 String value = (String) get(key); 108 out.write(key, 0, key.length()); 82 109 if(value != null) { 83 84 } 85 else { 86 110 out.write('='); 111 out.write(value, 0, value.length()); 87 112 } 88 113 out.newLine(); … … 96 121 } 97 122 } 123 124 125 126 127
Note:
See TracChangeset
for help on using the changeset viewer.