Changeset 20899

Show
Ignore:
Timestamp:
03.11.2009 19:49:03 (10 years ago)
Author:
ak19
Message:

Updated so that the GSI dialog does not silently fail when it fails to launch the browser.

Location:
greenstone3/trunk/src/java/org/greenstone/server
Files:
2 modified

Legend:

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

    r20687 r20899  
    190190    String url = getBrowserURL(); 
    191191    //recordError("**** browserURL: " + url); 
    192     BrowserLauncher launcher = new BrowserLauncher(config_properties.getProperty(BaseServer.Property.BROWSER_PATH, ""),url); 
     192    BrowserLauncher launcher = new BrowserLauncher(config_properties.getProperty(BaseServer.Property.BROWSER_PATH, ""), 
     193                               url, 
     194                               dictionary.get("ServerSettings.NoBrowserFound"), 
     195                               dictionary.get("ServerSettings.BrowserLaunchFailed")); 
    193196        logger_.info(message); 
    194197 
  • greenstone3/trunk/src/java/org/greenstone/server/BrowserLauncher.java

    r18969 r20899  
    11package org.greenstone.server; 
    22 
     3import javax.swing.JOptionPane; 
    34import java.io.BufferedReader; 
    45import java.io.InputStream; 
     
    1011public class BrowserLauncher  
    1112    extends Thread { 
     13    private String browserNotFound; 
     14    private String browserLaunchFailed; 
    1215     
    1316    private String url = "about:blank" ; 
     
    2023    private String browserPath = "";  
    2124 
    22     public BrowserLauncher(String browserPath, String url) { 
     25    public BrowserLauncher(String browserPath, String url, String browserNotFound, String browserLaunchFailed) { 
    2326    this.url = url; 
     27    this.browserNotFound = browserNotFound; 
     28    this.browserLaunchFailed = browserLaunchFailed; 
    2429        this.browserPath = browserPath; 
    2530        //use the default browser 
     
    8691    if(command.equals("")) { 
    8792        state = LAUNCHFAILED; 
    88             logger.error("launching command is empty"); 
     93            logger.error("launching command is empty: no browser found."); 
     94        JOptionPane.showMessageDialog(null, browserNotFound, "Warning", JOptionPane.WARNING_MESSAGE); 
    8995        return; 
    9096    } 
    9197     
    9298        try { 
     99        int exitCode = 0; 
    93100        String prog_name = this.command.substring(0,this.command.indexOf(" ")); 
    94101        String lower_name = prog_name.toLowerCase(); 
     
    101108        Process process = rt.exec(new_command); 
    102109                state = LAUNCHSUCCESS; 
    103         int exitCode = process.waitFor(); 
     110        exitCode = process.waitFor(); 
    104111        logger.info("ExitCode:" + exitCode);               
    105112        if (exitCode != 0) { // if Netscape or mozilla was not open 
     
    108115            process = rt.exec(this.command); // try the original command 
    109116                    state = LAUNCHSUCCESS; 
    110             //for some reseaons the following part is not executed somtimes. 
     117            //for some reason the following part is not executed sometimes. 
    111118                    exitCode = process.waitFor(); 
    112                     logger.info("ExitCode:" + exitCode); 
    113119        } 
    114120        } else { 
     
    117123        Process process = rt.exec(this.command); 
    118124                state = LAUNCHSUCCESS; 
    119                 //for some reseaons the following part is not executed sometimes. 
    120                 int exitCode = process.waitFor(); 
    121         logger.info("ExitCode:" + exitCode); 
    122          
     125                //for some reason the following part is not executed sometimes. 
     126                exitCode = process.waitFor(); 
     127        } 
     128 
     129        logger.info("ExitCode:" + exitCode); 
     130        if (exitCode != 0) { // if trying to launch the browser above failed 
     131        logger.info(browserLaunchFailed); 
     132        JOptionPane.showMessageDialog(null, browserLaunchFailed, "Warning", JOptionPane.WARNING_MESSAGE); 
    123133        } 
    124134    }