Changeset 33256 for main/trunk


Ignore:
Timestamp:
2019-07-01T10:51:32+12:00 (5 years ago)
Author:
kjdon
Message:

additional debug statements which need removing later. PLus, changed when we add defaault params to the table. not only do it for a new session id, but need to do it for each new table. otherwise only the first collection will get the default parameter.

File:
1 edited

Legend:

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

    r33175 r33256  
    445445        session.setMaxInactiveInterval(session_expiration);
    446446        String uid = session.getId();
    447 
     447        logger.error("uid = "+uid);
    448448        request.setCharacterEncoding("UTF-8");
    449449        response.setContentType("text/html;charset=UTF-8");
     
    464464        userContext.setLanguage(lang);
    465465        userContext.setUserID(uid);
    466 
     466        logger.error ("setting user context "+ uid);
    467467        if (request.getAuthType() != null)
    468468        {
    469469            //Get the username
    470             userContext.setUsername(request.getUserPrincipal().getName());
     470          userContext.setUsername(request.getUserPrincipal().getName());
     471          logger.error("adding username "+request.getUserPrincipal().getName());
    471472
    472473            //Get the groups for the user
     
    607608        }
    608609       
    609         // logger.info("should_cache= " + should_cache);
    610 
     610         logger.error("should_cache= " + should_cache);
     611         logger.error("cache key = " + cache_key);
    611612        //clear the collection-specific cache in the session, since we have no way to know whether this session is
    612613        //about the same collection as the last session or not.
     
    618619            {
    619620                session.removeAttribute(name);
     621                logger.error("XXX removing "+name+" from the session");
    620622            }
    621623        }
     
    624626        Hashtable<String, Hashtable<String, String>> param_table = null;
    625627        Hashtable<String, String> table = null;
     628        boolean new_table = false;
    626629        String sid = session.getId();
    627630        if (should_cache == true && cache_key != null && !cache_key.equals(""))
     
    629632            if (session_ids_table.containsKey(sid))
    630633            {
     634              logger.error("cache contains sesion id");
    631635                session_cache = session_ids_table.get(sid);
    632636                param_table = session_cache.getParamsTable();
    633637                if (param_table.containsKey(cache_key))
    634638                {
    635                     //logger.info("existing table: " + collection);
     639                    logger.error("existing table: " + cache_key);
    636640                    table = param_table.get(cache_key);
    637641                }
     
    640644                    table = new Hashtable<String, String>();
    641645                    param_table.put(cache_key, table);
    642                     //logger.info("new table: " + collection);
     646                    logger.error("new table: " + cache_key);
     647                    new_table = true;
    643648                }
    644649            }
    645650            else
    646651            {
     652              logger.error("cache doesn't contain session id");
    647653                param_table = new Hashtable<String, Hashtable<String, String>>();
    648654                table = new Hashtable<String, String>();
     
    651657                session_ids_table.put(sid, session_cache);
    652658                session.setAttribute(GSXML.USER_SESSION_CACHE_ATT, session_cache);
    653 
    654                 // here we add in default params?
    655                 ArrayList<String> defp = this.gs_params.getParamsWithDefaults();
    656                 Iterator i = this.gs_params.getParamsWithDefaults().iterator();
    657                 while (i.hasNext()) {
    658                     String p = (String)i.next();
    659                     String v = this.gs_params.getParamDefault(p);
    660                     if (!p.equals(GSParams.ACTION) && !p.equals(GSParams.SUBACTION) && !p.equals(GSParams.LANGUAGE) && !p.equals(GSParams.OUTPUT)) {
    661                     table.put(p,v);
    662                     }
    663                 }
    664                
    665             }
     659                new_table = true;
     660            }
     661
     662            // here we add in default params if we have a new table
     663            ArrayList<String> defp = this.gs_params.getParamsWithDefaults();
     664            Iterator i = this.gs_params.getParamsWithDefaults().iterator();
     665            while (i.hasNext()) {
     666              String p = (String)i.next();
     667              String v = this.gs_params.getParamDefault(p);
     668              if (!p.equals(GSParams.ACTION) && !p.equals(GSParams.SUBACTION) && !p.equals(GSParams.LANGUAGE) && !p.equals(GSParams.OUTPUT)) {
     669                logger.error("adding to new table default param "+p+", "+v);
     670                table.put(p,v);
     671              }
     672            }
     673           
     674       
    666675        }
    667676
     
    695704                {// we have already dealt with these
    696705
     706                  logger.error("query map:" + name);
    697707                    String value = "";
    698708                    String[] values = queryMap.get(name);
     
    708718                    if (this.gs_params.shouldSave(name) && table != null)
    709719                    {
     720                      logger.error("adding to table");
    710721                        table.put(name, value);
    711722                    }
    712723                    else
    713724                    {
     725                      logger.error("adding param to xml param list");
    714726                        Element param = msg_doc.createElement(GSXML.PARAM_ELEM);
    715727                        param.setAttribute(GSXML.NAME_ATT, name);
     
    731743                {
    732744                    String name = keys.nextElement();
     745                    logger.error("adding from table to session "+name);
    733746                    session.setAttribute(name, table.get(name));
    734747                }
     
    737750            // put in all the params from the session cache
    738751            Enumeration params = session.getAttributeNames();
     752            logger.error("add in session attributes");
    739753            while (params.hasMoreElements())
    740754            {
    741755                String name = (String) params.nextElement();
    742 
     756                logger.error("session attribute "+name);
    743757                if (!name.equals(GSXML.USER_SESSION_CACHE_ATT) && !name.equals(GSParams.LANGUAGE) && !name.equals(GSXML.USER_ID_ATT))
    744758                {
Note: See TracChangeset for help on using the changeset viewer.