Changeset 32447 for main/trunk

Show
Ignore:
Timestamp:
13.09.2018 13:57:44 (12 months ago)
Author:
kjdon
Message:

initialise params class earlier, so we can pass to MR as well as to recpt. - services now need to add any params that they want saving in the session

Files:
1 modified

Legend:

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

    r32362 r32447  
    223223        this.recept.setConfigParams(config_params); 
    224224 
     225        // the params arg thingy 
     226 
     227        String params_name = (String) config.getInitParameter("params_class"); 
     228        if (params_name == null) 
     229        { 
     230            this.params = new GSParams(); 
     231        } 
     232        else 
     233        { 
     234            try 
     235            { 
     236                this.params = (GSParams) Class.forName("org.greenstone.gsdl3.util." + params_name).newInstance(); 
     237            } 
     238            catch (Exception e) 
     239            { 
     240                System.err.println("LibraryServlet configure exception when trying to use a new params thing " + params_name + ": " + e.getMessage()); 
     241                e.printStackTrace(); 
     242                this.params = new GSParams(); 
     243            } 
     244        } 
     245         
    225246        // the receptionist uses a MessageRouter or Communicator to send its requests to. We either create a MessageRouter here for the designated site (if site_name set), or we create a Communicator for a remote site. The is given to the Receptionist, and the servlet never talks to it again directly. 
    226247        if (site_name != null) 
     
    248269            message_router.setSiteName(site_name); 
    249270            message_router.setLibraryName(library_name); 
     271            message_router.setParams(this.params); 
    250272            message_router.configure(); 
    251273            this.recept.setMessageRouter(message_router); 
     
    253275        else 
    254276        { 
     277          // TODO: what do we do about params here? 
    255278            // talking to a remote site, create a communicator 
    256279            Communicator communicator = null; 
     
    280303        } 
    281304 
    282         // the params arg thingy 
    283  
    284         String params_name = (String) config.getInitParameter("params_class"); 
    285         if (params_name == null) 
    286         { 
    287             this.params = new GSParams(); 
    288         } 
    289         else 
    290         { 
    291             try 
    292             { 
    293                 this.params = (GSParams) Class.forName("org.greenstone.gsdl3.util." + params_name).newInstance(); 
    294             } 
    295             catch (Exception e) 
    296             { 
    297                 System.err.println("LibraryServlet configure exception when trying to use a new params thing " + params_name + ": " + e.getMessage()); 
    298                 e.printStackTrace(); 
    299                 this.params = new GSParams(); 
    300             } 
    301         } 
    302         // pass it to the receptionist 
     305        // pass params to the receptionist 
    303306        this.recept.setParams(this.params); 
    304307        this.recept.configure(); 
     
    842845    { 
    843846        //Check if we need to login or logout 
    844         String username = getFirstParam("username", queryMap); 
    845         String password = getFirstParam("password", queryMap); 
    846         String logout = getFirstParam("logout", queryMap); 
     847        String username = getFirstParam(GSParams.USERNAME, queryMap); 
     848        String password = getFirstParam(GSParams.PASSWORD, queryMap); 
     849        String logout = getFirstParam(GSParams.LOGOUT, queryMap); 
    847850 
    848851        if (logout != null)