- Timestamp:
- 2009-03-10T13:42:44+13:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/greenstone/LocalLibraryServer.java
r18136 r18650 45 45 static final private String QUIT_COMMAND = "?a=config&cmd=kill"; 46 46 47 static private GSDLSiteConfig gsdlsite_cfg_file = null;47 static private LLSSiteConfig llssite_cfg_file = null; 48 48 static private File local_library_server_file = null; 49 49 … … 97 97 { 98 98 if (!running) return false; 99 gsdlsite_cfg_file.load();100 if ( gsdlsite_cfg_file.getURL() == null) return false;99 llssite_cfg_file.load(); 100 if (llssite_cfg_file.getURL() == null) return false; 101 101 return true; 102 102 } … … 124 124 125 125 // Check if the server is already running 126 gsdlsite_cfg_file = new GSDLSiteConfig(local_library_server_file);127 String url = gsdlsite_cfg_file.getURL();126 llssite_cfg_file = new LLSSiteConfig(local_library_server_file); 127 String url = llssite_cfg_file.getURL(); 128 128 if (url != null) { 129 129 // If it is already running then set the Greenstone web server address and we're done … … 139 139 140 140 // Configure the server for immediate entry 141 // gsdlsite_cfg_file.set();141 //llssite_cfg_file.set(); 142 142 143 143 // Spawn local library server process 144 String local_library_server_command = local_library_server_file.getAbsolutePath() + " " + gsdlsite_cfg_file.getSiteConfigFilename();144 String local_library_server_command = local_library_server_file.getAbsolutePath() + " " + llssite_cfg_file.getSiteConfigFilename(); 145 145 Gatherer.spawnApplication(local_library_server_command); 146 146 147 147 // Wait until program has started, by reloading and checking the URL field 148 gsdlsite_cfg_file.load();148 llssite_cfg_file.load(); 149 149 int attempt_count = 0; 150 while ( gsdlsite_cfg_file.getURL() == null) {150 while (llssite_cfg_file.getURL() == null) { 151 151 new OneSecondWait(); // Wait one second (give or take) 152 gsdlsite_cfg_file.load();152 llssite_cfg_file.load(); 153 153 attempt_count++; 154 154 … … 165 165 // Ta-da. Now the url should be available 166 166 try { 167 Configuration.library_url = new URL( gsdlsite_cfg_file.getURL());167 Configuration.library_url = new URL(llssite_cfg_file.getURL()); 168 168 } 169 169 catch (MalformedURLException exception) { … … 180 180 try { 181 181 // If this fails then we try changing the url to be localhost 182 Configuration.library_url = new URL( gsdlsite_cfg_file.getLocalHostURL());182 Configuration.library_url = new URL(llssite_cfg_file.getLocalHostURL()); 183 183 DebugStream.println("Try connecting to server on local host: '" + Configuration.library_url + "'"); 184 184 URLConnection connection = Configuration.library_url.openConnection(); … … 206 206 207 207 // Wait until program has stopped, by reloading and checking the URL field 208 gsdlsite_cfg_file.load();208 llssite_cfg_file.load(); 209 209 int attempt_count = 0; 210 while ( gsdlsite_cfg_file.getURL() != null) {210 while (llssite_cfg_file.getURL() != null) { 211 211 new OneSecondWait(); // Wait one second (give or take) 212 gsdlsite_cfg_file.load();212 llssite_cfg_file.load(); 213 213 attempt_count++; 214 214 … … 223 223 } 224 224 225 // Restore the gsdlsite_cfg.226 gsdlsite_cfg_file.restore();225 // Restore the llssite_cfg. 226 llssite_cfg_file.restore(); 227 227 228 228 // If the local server is still running then our changed values will get overwritten. 229 if ( gsdlsite_cfg_file.getURL() != null) {229 if (llssite_cfg_file.getURL() != null) { 230 230 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("Server.QuitManual"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 231 231 } … … 236 236 static public void checkServerRunning() { 237 237 if (!running) return; // don't worry about it if its not supposed to be running 238 gsdlsite_cfg_file.load();239 if ( gsdlsite_cfg_file.getURL() == null) {238 llssite_cfg_file.load(); 239 if (llssite_cfg_file.getURL() == null) { 240 240 // need to restart the server again 241 gsdlsite_cfg_file.set();241 llssite_cfg_file.set(); 242 242 243 243 // Spawn local library server process 244 String local_library_server_command = local_library_server_file.getAbsolutePath() + " " + gsdlsite_cfg_file.getSiteConfigFilename();244 String local_library_server_command = local_library_server_file.getAbsolutePath() + " " + llssite_cfg_file.getSiteConfigFilename(); 245 245 Gatherer.spawnApplication(local_library_server_command); 246 246 … … 262 262 263 263 264 static public class GSDLSiteConfig264 static public class LLSSiteConfig 265 265 extends LinkedHashMap { 266 private File gsdlsite_cfg;266 private File llssite_cfg; 267 267 private File glisite_cfg; 268 268 private String autoenter_initial; … … 275 275 static final private String GLISITE_CFG = "glisite.cfg"; 276 276 static final private String GSDL = "gsdl"; 277 static final private String GSDLSITE_CFG = "gsdlsite.cfg";277 static final private String LLSSITE_CFG = "llssite.cfg"; 278 278 static final private String LOCAL_HOST = "http://localhost"; 279 279 static final private String PORTNUMBER = "portnumber"; … … 284 284 static final private String URL = "url"; 285 285 286 public GSDLSiteConfig(File server_exe) {287 debug("New GSDLSiteConfig for: " + server_exe.getAbsolutePath());286 public LLSSiteConfig(File server_exe) { 287 debug("New LLSSiteConfig for: " + server_exe.getAbsolutePath()); 288 288 289 gsdlsite_cfg = new File(server_exe.getParentFile(), GSDLSITE_CFG);289 llssite_cfg = new File(server_exe.getParentFile(), LLSSITE_CFG); 290 290 glisite_cfg = new File(server_exe.getParentFile(), GLISITE_CFG); 291 291 … … 293 293 if(glisite_cfg.exists()) { 294 294 configFile = glisite_cfg; 295 } else if( gsdlsite_cfg.exists()) {296 configFile = gsdlsite_cfg;295 } else if(llssite_cfg.exists()) { 296 configFile = llssite_cfg; 297 297 } else { 298 debug("Neither the file glisite.cfg nor GSDLsite.cfg can be found!");298 debug("Neither the file glisite.cfg nor llssite.cfg can be found!"); 299 299 } 300 300 … … 329 329 330 330 public boolean exists() { 331 return gsdlsite_cfg.exists();331 return llssite_cfg.exists(); 332 332 } 333 333 … … 449 449 450 450 private void save() { 451 //debug("Save: " + gsdlsite_cfg.getAbsolutePath());451 //debug("Save: " + llssite_cfg.getAbsolutePath()); 452 452 debug("Save: " + glisite_cfg.getAbsolutePath()); 453 453 try { 454 //BufferedWriter out = new BufferedWriter(new FileWriter( gsdlsite_cfg, false));454 //BufferedWriter out = new BufferedWriter(new FileWriter(llssite_cfg, false)); 455 455 BufferedWriter out = new BufferedWriter(new FileWriter(glisite_cfg, false)); 456 456 for(Iterator keys = keySet().iterator(); keys.hasNext(); ) {
Note:
See TracChangeset
for help on using the changeset viewer.