Changeset 4669


Ignore:
Timestamp:
2003-06-16T09:58:50+12:00 (21 years ago)
Author:
jmt12
Message:

Local library stuff

File:
1 edited

Legend:

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

    r4620 r4669  
    4949import org.greenstone.gatherer.Configuration;
    5050import org.greenstone.gatherer.GAuthenticator;
     51import org.greenstone.gatherer.cdm.CommandTokenizer;
    5152import org.greenstone.gatherer.collection.CollectionManager;
    5253import org.greenstone.gatherer.file.FileManager;
     
    298299    }
    299300    if(assoc_man != null) {
    300         assoc_man.destroy();
     301        assoc_man.save();
    301302        assoc_man = null;
    302303    }
     
    684685        gsdlsite_cfg.set();
    685686        // Spawn server
    686         String[] command = new String[3];
     687        String[] command = new String[2];
    687688        command[0] = config.exec_file.getAbsolutePath();
    688         command[1] = "-config_file";
    689         command[2] = gsdlsite_cfg.getSiteConfigFilename();
     689        command[1] = gsdlsite_cfg.getSiteConfigFilename();
    690690        server = new ExternalApplication(command);
    691691        server.start();
     
    702702            // Ta-da. Now the url should be available.
    703703            config.exec_address = new URL(url);
     704
     705            // A quick test involves opening a connection to get the home page for this collection. If this fails then we try changing the url to be localhost.
     706            try {
     707            Gatherer.println("Try connecting to server on config url.");
     708            URLConnection connection = config.exec_address.openConnection();
     709            connection.getContent();
     710            }
     711            catch(IOException bad_url_connection) {
     712            try {
     713                Gatherer.println("Try connecting to server on local host.");
     714                config.exec_address = new URL(gsdlsite_cfg.getLocalHostURL());
     715                URLConnection connection = config.exec_address.openConnection();
     716                connection.getContent();
     717            }
     718            catch(IOException worse_url_connection) {
     719                Gatherer.println("Can't connect to server on either address.");
     720                config.exec_address = null;
     721                config.exec_file = null;
     722            }
     723            }
    704724        }
    705725        catch (Exception error) {
     
    769789     * @param command The initial command <strong>String</strong>.
    770790     */
    771     public ExternalApplication(String command) {
    772         this.command = new String[1];
    773         this.command[0] = command;
     791    public ExternalApplication(String large_command) {
     792        CommandTokenizer tokenizer = new CommandTokenizer(large_command);
     793        while(tokenizer.hasMoreTokens()) {
     794        if(command == null) {
     795            command = new String[1];
     796            command[0] = tokenizer.nextToken();
     797        }
     798        else {
     799            command = ArrayTools.add(command, tokenizer.nextToken());
     800        }
     801        }
    774802    }
    775803
Note: See TracChangeset for help on using the changeset viewer.