Changeset 19543 for greenstone3


Ignore:
Timestamp:
2009-05-20T17:59:26+12:00 (15 years ago)
Author:
ak19
Message:

Adds url=URL_pending into the llssite.cfg/glisite.cfg file if the server has not yet been started. This is then used by GLI's LocalLibraryServer to work out whether it should luanch a GSI itself, or whether one was already inependently launched (from outside of GLI). If the latter case, GLI will use the GSI that's already open. If the server is never started by GSI server, then the URL-pending line that's still in the configFile is removed to restore the default state.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/src/java/org/greenstone/server/Server2.java

    r19470 r19543  
    2323{
    2424    private static final int WAITING_TIME = 10; // time to wait and check for whether the server is running
     25    private static final String URL_PENDING="URL_pending";
    2526
    2627    protected String libraryURL;
     
    100101                + PortFinder.PORTS_RESERVED + " - " + PortFinder.MAX_PORT + "]" );
    101102        quitPort = -1;
     103        }
     104    }
     105   
     106    // If the GSI is set to NOT autoenter/autostart the server, then write url=URL_PENDING out to the file.
     107    // When the user finally presses the Enter Library button and so has started up the server, the correct
     108    // url will be written out to the configfile.
     109    if(config_properties.getProperty(BaseServer.Property.AUTOSTART, "").equals("0")) {//if(configfile.endsWith("llssite.cfg")) {
     110        if(config_properties.getProperty("url") == null) {
     111        config_properties.setProperty("url", URL_PENDING);
     112        ScriptReadWrite scriptReadWrite = new ScriptReadWrite();
     113        ArrayList fileLines = scriptReadWrite.readInFile(BaseServer.config_properties_file);
     114        scriptReadWrite.replaceOrAddLine(fileLines, "url", URL_PENDING, true);
     115        scriptReadWrite.writeOutFile(config_properties_file, fileLines);
    102116        }
    103117    }
     
    250264    ScriptReadWrite scriptReadWrite = new ScriptReadWrite();
    251265    ArrayList fileLines = scriptReadWrite.readInFile(BaseServer.config_properties_file);
    252     if (fileLines.contains("url="+getBrowserURL())) {
    253         // would be last element, remove it:
    254         fileLines.remove(fileLines.size()-1);
     266
     267    // Remove the url=... line, start searching from the end
     268    boolean done = false;
     269    for (int i = fileLines.size()-1; i >= 0 && !done; i--) {
     270        String line = ((String) fileLines.get(i)).trim();
     271        if(line.startsWith("url=")) {
     272        fileLines.remove(i);
     273        done = true;
     274        }
    255275    }
    256276    scriptReadWrite.writeOutFile(config_properties_file, fileLines);
     
    273293    // 1. Test that the server is running at the libraryURL before writing it out to glisite.cfg/configfile
    274294    // A quick test involves opening a connection to get the home page for this collection
    275     if(libURL != null) {
     295    if(libURL != null && !libraryURL.equals(URL_PENDING)) {
    276296
    277297        boolean ready = false;
Note: See TracChangeset for help on using the changeset viewer.