Changeset 19547 for gli


Ignore:
Timestamp:
2009-05-21T16:44:28+12:00 (15 years ago)
Author:
ak19
Message:

Fixed up loose ends: restarting an external server - just as relaunching a server from within GLI - will work with the previewbutton.

Location:
gli/trunk/src/org/greenstone/gatherer
Files:
2 edited

Legend:

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

    r19544 r19547  
    415415    String url = llssite_cfg_file.getURL();
    416416    if(url != null) {
     417        if(isURLPending()) {
     418        running = false;
     419        return;
     420        }
     421
     422        // else, valid URL:
    417423        try {
    418424        Configuration.library_url = new URL(url);
     
    422428        exception.printStackTrace();
    423429        }
    424     } else {
    425         // need to restart the server again
    426  
    427         // if we were running an independently launched GSI before, but the GSI has been
    428         // exited, it would need to be relaunched, but from within GLI (dependent) this time.
    429         if(llssite_cfg_file.isIndependentGSI()) {
    430         // first save the current configFile (llssite.cfg), then set to use glisite.cfg
    431         llssite_cfg_file.save();
    432         llssite_cfg_file.relaunchAsDependentGSI(local_library_server_file);
     430    }
     431    else { // NO URL in current ConfigFile, check the other configfile for a URL
     432        // to see if the server was restarted using that file.
     433        // Otherwise need to restart the server again with GLIsite.cfg
     434        llssite_cfg_file.save(); // save the configfile, because we may be reloading another
     435
     436        if(llssite_cfg_file.usingLLS_configFile()) { // if a GSI is already using llssite_cfg, this would have loaded it in
     437        if(isURLPending()) {
     438            running = false;
     439        } else {
     440            running = true;
     441        }
     442        return; // don't need to launch the server, one has been independently launched
    433443        } else {
    434         // We were using glisite.cfg before, don't need to swap config files
    435         llssite_cfg_file.set();
    436         }
    437         // Spawn local library server process
    438         String local_library_server_command = local_library_server_file.getAbsolutePath() + getExtraLaunchArguments(llssite_cfg_file);
    439         running = false;
    440         Gatherer.spawnApplication(local_library_server_command, ID);
    441         try {
    442         testServerRunning(); // don't return until the webserver is up and running
    443         } catch (IOException bad_url_connection) {
    444         DebugStream.println("Can't connect to server on address " + Configuration.library_url);
     444        // else we try using the glisite configfile
     445        llssite_cfg_file.useGLISiteCfg(local_library_server_file);
     446            //llssite_cfg_file.set();
     447       
     448        // Spawn local library server process
     449        String local_library_server_command = local_library_server_file.getAbsolutePath() + getExtraLaunchArguments(llssite_cfg_file);
    445450        running = false;
     451        Gatherer.spawnApplication(local_library_server_command, ID);
     452        try {
     453            testServerRunning(); // don't return until the webserver is up and running
     454        } catch (IOException bad_url_connection) {
     455            DebugStream.println("Can't connect to server on address " + Configuration.library_url);
     456            running = false;
     457        }
    446458        }
    447459    }
     
    492504    static final public String URL_PENDING = "URL_pending";
    493505
     506   
    494507    public LLSSiteConfig(File server_exe) {
    495508        debug("New LLSSiteConfig for: " + server_exe.getAbsolutePath());
     
    508521        // else we try using the glisite configfile
    509522        useGLISiteCfg(server_exe);
    510         }
    511 
    512         if(configFile != null && configFile.exists()) {
    513         System.err.println("Using configfile: " + configFile);
    514         lastModified = configFile.lastModified();
    515523        }
    516524    }
     
    542550        configFile = glisite_cfg;
    543551        load(false); // force reload
     552        lastModified = configFile.lastModified();
    544553        }
    545554    }
     
    552561     * and, if so, it would have loaded in the llssite_cfg configFile.
    553562     */
    554     private boolean usingLLS_configFile() {
     563    public boolean usingLLS_configFile() {
    555564        if(!llssite_cfg.exists()) {
    556565        return false;
    557566        }
    558567
    559         // check if the configfile contains the URL line
     568        // Now to check if the configfile contains the URL line
    560569        configFile = llssite_cfg;
    561570        load(false); // force load
     
    567576        }
    568577
     578        lastModified = configFile.lastModified();
    569579        //System.err.println("***** we're using llssite_configfile, url:" + getURL());
    570580        return true;
     
    575585    public boolean isIndependentGSI() {
    576586        return (configFile == llssite_cfg);
    577     }
    578 
    579     /** Call this when an independently launched GSI server has been stopped
    580      * (one using llssite_cfg) and GLI needs to next launch another server.
    581      * In such a case, since GLI itself is relaunching the GSI, we use glisite_cfg.
    582     */
    583     public void relaunchAsDependentGSI(File server_exe) {
    584         useGLISiteCfg(server_exe);
    585587    }
    586588
  • gli/trunk/src/org/greenstone/gatherer/gui/PreviewButton.java

    r19544 r19547  
    9191    // !! Don't like this here
    9292    LocalLibraryServer.checkServerRunning();
     93    if(LocalLibraryServer.isURLPending()) {
     94        // Remind the user to press Enter Library, and return from this method
     95        JOptionPane.showMessageDialog(Gatherer.g_man,
     96                      Dictionary.get("General.LLS_Not_Started"),
     97                      Dictionary.get("General.LLS_Not_Started_Title"),
     98                      JOptionPane.ERROR_MESSAGE);
     99        preview_address = null;
     100        return;   
     101    }
    93102   
    94103    // FLI or GLI for GS2 case (no library_url)
     
    135144        Gatherer.c_man.saveCollection();
    136145       
    137         if(LocalLibraryServer.isURLPending()) {
    138         // Remind the user to press Enter Library, and return from this method
    139         JOptionPane.showMessageDialog(Gatherer.g_man,
    140                           Dictionary.get("General.LLS_Not_Started"),
    141                           Dictionary.get("General.LLS_Not_Started_Title"),
    142                           JOptionPane.ERROR_MESSAGE);
    143         return;
    144        
    145         } else {
    146         configureHomeURL();
    147         }
     146        configureHomeURL();
    148147       
    149148        if (Gatherer.GS3) {
     
    152151        Gatherer.configGS3Server(Configuration.site_name, ServletConfiguration.ADD_COMMAND + Gatherer.c_man.getLoadedCollectionName());
    153152        }
    154         Gatherer.spawnBrowser(preview_address);
     153        if(preview_address != null) {
     154        Gatherer.spawnBrowser(preview_address);
     155        }
    155156
    156157    }
Note: See TracChangeset for help on using the changeset viewer.