Changeset 4986 for trunk/gsdl3


Ignore:
Timestamp:
2003-07-21T09:32:15+12:00 (21 years ago)
Author:
kjdon
Message:

now use GSParams class instead of GSCGI class

File:
1 edited

Legend:

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

    r4690 r4986  
    2727   
    2828    /** the receptionist to send messages to */
    29     protected WebReceptionist recept=null;
     29    protected Receptionist recept=null;
    3030    /** the default language - is specified by setting a servlet param,
    3131     * otherwise DEFAULT_LANG is used*/
     
    4040    /** the cgi stuff - the Receptionist can add new args to this
    4141     * its used by the servlet to determine what args to save */
    42     protected GSCGI cgi = null;
     42    //protected GSCGI cgi = null;
     43    protected GSParams params = null;
    4344    /** initialise the servlet
    4445     */
     
    7778    // new message router - create it and pass reference to recept.
    7879    // the servlet wont use this directly
    79     String mr_name = (String)config.getInitParameter("messagerouter");
     80    String mr_name = (String)config.getInitParameter("messagerouter_class");
    8081    MessageRouter message_router = null;
    8182    if (mr_name == null) { // just use the normal MR
     
    9697   
    9798    // the receptionist -the servlet will talk to this
    98     String recept_name = (String)config.getInitParameter("receptionist");
     99    String recept_name = (String)config.getInitParameter("receptionist_class");
    99100    if (recept_name == null) {
    100101        this.recept = new DefaultReceptionist();
    101102    } else {
    102103        try {
    103         this.recept = (WebReceptionist)Class.forName("org.greenstone.gsdl3.core."+recept_name).newInstance();
     104        this.recept = (Receptionist)Class.forName("org.greenstone.gsdl3.core."+recept_name).newInstance();
    104105        } catch (Exception e) { // cant use this new one, so use normal one
    105106        System.out.println("LibraryServlet configure exception when trying to use a new Receptionist "+recept_name+": "+e.getMessage());
     
    110111    this.recept.setConfigParams(config_params);
    111112    this.recept.setMessageRouter(message_router);
    112     this.recept.configure();
    113     // the cgi arg thingy
    114    
    115     String cgi_name = (String)config.getInitParameter("cgiargs");
    116     if (cgi_name == null) {
    117         this.cgi = new GSCGI();
     113    // the params arg thingy
     114   
     115    String params_name = (String)config.getInitParameter("params_class");
     116    if (params_name == null) {
     117        this.params = new GSParams();
    118118    } else {
    119119        try {
    120         this.cgi = (GSCGI)Class.forName("org.greenstone.gsdl3.util."+cgi_name).newInstance();
     120        this.params = (GSParams)Class.forName("org.greenstone.gsdl3.util."+params_name).newInstance();
    121121        } catch (Exception e) {
    122         System.out.println("LibraryServlet configure exception when trying to use a new cgi thing "+cgi_name+": "+e.getMessage());
     122        System.out.println("LibraryServlet configure exception when trying to use a new params thing "+params_name+": "+e.getMessage());
    123123        e.printStackTrace();
    124         this.cgi = new GSCGI();
     124        this.params = new GSParams();
    125125        }
    126126    }
    127127    // pass it to the receptionist
    128     this.recept.setCGI(this.cgi);
     128    this.recept.setParams(this.params);
     129    this.recept.configure();
     130   
    129131    }
    130132   
     
    147149    PrintWriter out = response.getWriter();
    148150
    149     String lang = request.getParameter(GSCGI.LANGUAGE_ARG);
     151    String lang = request.getParameter(GSParams.LANGUAGE);
    150152    if (lang==null || lang.equals("")) {
    151153        // try the session cached lang
    152         lang = (String)session.getAttribute(GSCGI.LANGUAGE_ARG);
     154        lang = (String)session.getAttribute(GSParams.LANGUAGE);
    153155        if (lang==null || lang.equals("")) {
    154156        // still not set, use the default
     
    158160   
    159161    // set the lang in the session
    160     session.setAttribute(GSCGI.LANGUAGE_ARG, lang);
    161 
    162     String output = request.getParameter(GSCGI.OUTPUT_ARG);
     162    session.setAttribute(GSParams.LANGUAGE, lang);
     163
     164    String output = request.getParameter(GSParams.OUTPUT);
    163165    if (output==null || output.equals("")) {
    164166        output = "html"; // uses html by default
     
    172174   
    173175   
    174     String action = request.getParameter(GSCGI.ACTION_ARG);
    175     String subaction = request.getParameter(GSCGI.SUBACTION_ARG);
     176    String action = request.getParameter(GSParams.ACTION);
     177    String subaction = request.getParameter(GSParams.SUBACTION);
    176178    if (action==null || action.equals("")) {
    177179        // should we do all the following stuff if using default page?
     
    197199        while(params.hasMoreElements()) {
    198200        String name = (String)params.nextElement();
    199         if (!name.equals(GSCGI.ACTION_ARG) && !name.equals(GSCGI.SUBACTION_ARG) && !name.equals(GSCGI.LANGUAGE_ARG) && !name.equals(GSCGI.OUTPUT_ARG)) {// we have already dealt with these
     201        if (!name.equals(GSParams.ACTION) && !name.equals(GSParams.SUBACTION) && !name.equals(GSParams.LANGUAGE) && !name.equals(GSParams.OUTPUT)) {// we have already dealt with these
    200202            String value="";
    201203            String [] values = request.getParameterValues(name);
     
    207209            }
    208210            // either add it to the param list straight away, or save it to the session and add it later
    209             if (this.cgi.shouldSave(name)) {           
     211            if (this.params.shouldSave(name)) {         
    210212            session.setAttribute(name, value);
    211213            } else {
     
    223225        String name = (String)params.nextElement();
    224226       
    225         if ( !name.equals(GSCGI.LANGUAGE_ARG) ) { // lang is stored but we dont want it in the param list cos its already in the request
     227        if ( !name.equals(GSParams.LANGUAGE) ) { // lang is stored but we dont want it in the param list cos its already in the request
    226228           
    227229            Element param = this.doc.createElement(GSXML.PARAM_ELEM);
Note: See TracChangeset for help on using the changeset viewer.