Ignore:
Timestamp:
2009-04-16T12:43:08+12:00 (15 years ago)
Author:
ak19
Message:

Fixed a bug I introduced into the functioning of GLI with Windows' Local Library Server when writing the code for GLI working with Linux' local server: testServerRunning() method now throws an exception rather than processing it itself. This exception is once again handled by start() the way it used to, whereas checkServerRunning() deals with such an exception differently.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gli/trunk/src/org/greenstone/gatherer/greenstone/LocalLibraryServer.java

    r18987 r19003  
    200200   
    201201    // Wait until program has started
    202     testServerRunning(); // will set running = true when the server is up and running successfully
     202    try {
     203        testServerRunning(); // will set running = true when the server is up and running successfully
     204    } catch (IOException bad_url_connection) {
     205        try {
     206        // If this fails then we try changing the url to be localhost
     207        Configuration.library_url = new URL(llssite_cfg_file.getLocalHostURL());
     208        DebugStream.println("Try connecting to server on local host: '" + Configuration.library_url + "'");
     209        URLConnection connection = Configuration.library_url.openConnection();
     210        connection.getContent();
     211        running = true;
     212       
     213        } catch (IOException worse_url_connection) {
     214        DebugStream.println("Can't connect to server on either address.");
     215        Configuration.library_url = null;
     216        running = false;
     217        }
     218    }
    203219    }
    204220
     
    273289    // This method first tests whether there is a URL in the llssite_cfg_file
    274290    // and after that appears, it tests whether the URL is functional.
    275     static private void testServerRunning() {
     291    static private void testServerRunning() throws IOException {
    276292    // Wait until program has started, by reloading and checking the URL field
    277293    llssite_cfg_file.load(false);
     
    305321        URLConnection connection = Configuration.library_url.openConnection();
    306322        connection.getContent();
     323        running = true;
    307324    }
    308325    catch (IOException bad_url_connection) {
    309         try {
    310         // If this fails then we try changing the url to be localhost
    311         Configuration.library_url = new URL(llssite_cfg_file.getLocalHostURL());
    312         DebugStream.println("Try connecting to server on local host: '" + Configuration.library_url + "'");
    313         URLConnection connection = Configuration.library_url.openConnection();
    314         connection.getContent();
    315        
    316         }
    317         catch (IOException worse_url_connection) {
    318         DebugStream.println("Can't connect to server on either address.");
    319         Configuration.library_url = null;
    320         return;
    321         }
    322     }
    323 
    324     running = true;
     326        throw bad_url_connection;
     327    }
     328
     329   
    325330    }
    326331
     
    345350        running = false;
    346351        Gatherer.spawnApplication(local_library_server_command, ID);
    347         testServerRunning(); // don't return until the webserver is up and running
     352        try {
     353        testServerRunning(); // don't return until the webserver is up and running
     354        } catch (IOException bad_url_connection) {
     355        DebugStream.println("Can't connect to server on address " + Configuration.library_url);
     356        running = false;
     357        }
    348358    }
    349359    }
Note: See TracChangeset for help on using the changeset viewer.