Ignore:
Timestamp:
2004-08-04T16:40:46+12:00 (20 years ago)
Author:
kjdon
Message:

reworked this so it gets gsdl3home from a config file rather than in the code. the site name still needs to be hardcoded, but this can be done in advance - therefore don't need SOAPServerLocalsite.java.in

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/SOAPServer.java.in

    r6442 r7859  
    2121import org.greenstone.gsdl3.core.*;
    2222import org.w3c.dom.Element;
     23import java.io.File;
     24import java.io.BufferedReader;
     25import java.io.FileReader;
     26import java.net.URL;
     27
    2328/**
    2429 * The server side of a SOAP connection
     
    3237    implements ModuleInterface {
    3338 
     39    private String config_file_name = "SOAPServer.cfg";
     40   
    3441  /** The message router we're talking to */
    3542    MessageRouter mr_=null;
     
    3744  /** The no-args constructor */
    3845    public SOAPServer() {
     46    // find out gsdl3home
     47    URL url = ClassLoader.getSystemResource(config_file_name);
     48    if (url == null) {
     49        System.err.println("Couldn't find the config file "+config_file_name+". Can't initialise the SOAP server");
     50        return;
     51    }
     52    String gsdl3_home = readInFile(url);
     53    if (gsdl3_home == null || gsdl3_home.equals("")) {
     54        return;
     55    }
     56    String site_home=gsdl3_home+File.separator+"web"+File.separator+"sites"+File.separator+"@sitename@";
     57   
     58    File site_file = new File(site_home);
     59    if (!site_file.isDirectory()) {
     60        System.err.println("The site directory "+site_file.getPath()+" doesn't exist. Can't initialsie the SOAP server.");
     61        return;
     62    }       
    3963    mr_ = new MessageRouter();
    40     String site_home="@gsdl3home@/web/sites/@sitename@";
    4164    mr_.setSiteHome(site_home);
    4265    mr_.configure();
    43     }
     66    }
     67   
    4468   
    4569    /** Process a String request */
     
    5377    return mr_.process(xml_in);
    5478    }
     79
     80    private String readInFile(URL url) {
     81   
     82    try {
     83        BufferedReader reader = new BufferedReader(new FileReader(url.getFile()));
     84        String line = reader.readLine();
     85        line = line.trim();
     86        return line;
     87    } catch (Exception e) {
     88        System.err.println("Exception occurred when reading in the file "+url.getFile()+": "+e);
     89    }
     90    return null;
     91    }
     92
    5593}
    5694
Note: See TracChangeset for help on using the changeset viewer.