Changeset 4620


Ignore:
Timestamp:
2003-06-12T17:55:59+12:00 (21 years ago)
Author:
jmt12
Message:

2030134: The code is now in place for GLI to create its own site config file so as to avoid the 'GLI crashes leaving gsdlsite.cfg in inconsistant state which subsequently causes problems in GSDL and GLI' bug.

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

Legend:

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

    r4594 r4620  
    163163    }
    164164    try {
    165                 // Create log
     165        // Create log
    166166        log = new Log();
    167                 // Load Config
     167        // Load Config
    168168        loadConfig(gsdl_path, exec_path, perl_path);
    169169
    170                 // Read Dictionary
     170        // Read Dictionary
    171171        dictionary = new Dictionary(config.getLocale("general.locale", true), config.getFont("general.font", true));
    172172
    173                 // If we were given a server run it if neccessary.
     173        // If we were given a server run it if neccessary.
    174174        if(config.exec_file != null) {
    175175        startServerEXE();
    176176        }
    177177
    178                 // Having loaded the configuration (necessary to determine if certain warnings have been disabled) and dictionary, we now check if the necessary path variables have been provided.
     178        // Having loaded the configuration (necessary to determine if certain warnings have been disabled) and dictionary, we now check if the necessary path variables have been provided.
    179179
    180180        if(config.exec_file == null && config.exec_address == null) {
     
    184184        missingGSDL(dictionary);
    185185        }
    186                 // Perl path is a little different as it is perfectly ok to start the Gatherer without providing a perl path
     186        // Perl path is a little different as it is perfectly ok to start the Gatherer without providing a perl path
    187187        boolean found_perl = false;
    188188        if(config.perl_path != null) {
     
    275275    }
    276276    }
    277     /** Writes a message to the debug filestream.
    278      * @param message The message as a <strong>String</strong>.
    279      */
    280     //   public void debug(String message) {
    281     //debug(null, message);
    282     //  }
    283     /** Writes a message to the debug filestream.
    284      * @param error The <strong>Exception</strong> associated with this message, or <i>null</i> for no exception.
    285      * @param message The message as a <strong>String</strong>.
    286      * @see java.io.FileOutputStream
    287      * @see java.io.PrintStream
    288      * @see java.lang.Exception
    289      */
    290     //  public void debug(Exception exception, String message) {
    291     //if(message != null) {
    292     //    Gatherer.println(message);
    293     //}
    294     //if(exception != null) {
    295     //    Gatherer.printStackTrace(exception);
    296     //}
    297     // }
     277
    298278    /** Exits the Gatherer after ensuring that things needing saving are saved.
    299279     * @see java.io.FileOutputStream
     
    704684        gsdlsite_cfg.set();
    705685        // Spawn server
    706         server = new ExternalApplication(config.exec_file.getAbsolutePath());
     686        String[] command = new String[3];
     687        command[0] = config.exec_file.getAbsolutePath();
     688        command[1] = "-config_file";
     689        command[2] = gsdlsite_cfg.getSiteConfigFilename();
     690        server = new ExternalApplication(command);
    707691        server.start();
     692        command = null;
    708693        // Now we have to wait until program has started. We do this by reloading and checking
    709694        try {
     
    780765    private Process process = null;
    781766    /** The initial command string given to this sub-process. */
    782     private String command = null;
     767    private String[] command = null;
    783768    /** Constructor.
    784769     * @param command The initial command <strong>String</strong>.
    785770     */
    786771    public ExternalApplication(String command) {
     772        this.command = new String[1];
     773        this.command[0] = command;
     774    }
     775
     776    public ExternalApplication(String[] command) {
    787777        this.command = command;
    788778    }
     
    797787        // Call an external process using the args.
    798788        try {
    799         println("Running " + command);
     789        StringBuffer whole_command = new StringBuffer();
     790        for(int i = 0; i < command.length; i++) {
     791            whole_command.append(command[i]);
     792            whole_command.append(" ");
     793        }
     794        println("Running " + whole_command.toString());
     795        whole_command = null;
    800796        Runtime rt = Runtime.getRuntime();
    801797        process = rt.exec(command);
  • trunk/gli/src/org/greenstone/gatherer/util/GSDLSiteConfig.java

    r4384 r4620  
    77    extends LinkedHashMap {
    88    private File gsdlsite_cfg;
     9    private File glisite_cfg;
    910    private String autoenter_initial;
    1011    private String start_browser_initial;
     
    1314    static final public String RELEASE_COMMAND = "?a=config&cmd=release-collection&c=";
    1415    static final public String QUIT_COMMAND = "?a=config&cmd=kill";
    15 
     16   
    1617    static final private String AUTOENTER = "autoenter";
    1718    static final private String COLON = ":";
    1819    static final private String ENTERLIB = "enterlib";
    1920    static final private String FALSE = "0";
     21    static final private String GLISITE = null ;//"glisite.cfg";
    2022    static final private String GSDL = "gsdl";
    2123    static final private String GSDLSITE_CFG = "gsdlsite.cfg";
     
    2931    debug("New GSDLSiteConfig for: " + server_exe.getAbsolutePath());
    3032    gsdlsite_cfg = new File(server_exe.getParentFile(), GSDLSITE_CFG);
    31          
     33    //glisite_cfg = new File(server_exe.getParentFile(), GLISITE_CFG);
    3234    autoenter_initial = null;
    3335    start_browser_initial = null;
     
    3739    public boolean exists() {
    3840    return gsdlsite_cfg.exists();
     41    }
     42
     43    public String getSiteConfigFilename() {
     44    //return GLISITE_CFG;
     45    return GSDLSITE_CFG;
    3946    }
    4047
     
    97104    /** Restore the autoenter value to its initial value, and remove url if present. */
    98105    public void restore() {
    99     debug("Restore Initial Settings");
    100     put(AUTOENTER, autoenter_initial);
    101     put(STARTBROWSER, start_browser_initial);
    102     remove(URL);
    103     save();
     106    if(glisite_cfg != null) {
     107        // Delete the file
     108        glisite_cfg.delete();
     109    }
     110    else {
     111        debug("Restore Initial Settings");
     112        put(AUTOENTER, autoenter_initial);
     113        put(STARTBROWSER, start_browser_initial);
     114        remove(URL);
     115        save();
     116    }
    104117    }
    105118
     
    125138    private void save() {
    126139    debug("Save: " + gsdlsite_cfg.getAbsolutePath());
     140    //debug("Save: " + glisite_cfg.getAbsolutePath());
    127141    try {
    128142        BufferedWriter out = new BufferedWriter(new FileWriter(gsdlsite_cfg, false));
     143        //BufferedWriter out = new BufferedWriter(new FileWriter(glisite_cfg, false));
    129144        for(Iterator keys = keySet().iterator(); keys.hasNext(); ) {
    130145        String key = (String) keys.next();
Note: See TracChangeset for help on using the changeset viewer.