- Timestamp:
- 2008-08-21T13:24:40+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
greenstone3/trunk/src/java/org/greenstone/gsdl3/LibraryServlet.java
r16926 r16938 63 63 */ 64 64 protected Hashtable session_ids_table = new Hashtable(); 65 //this name is combined with the collection name and used for caching 66 protected String valid_site_name = ""; 67 65 68 66 /** the maximum interval that the cached info remains in session_ids_table (in seconds) 69 67 * This is set in web.xml … … 114 112 } 115 113 } 116 valid_site_name = (site_name != null)? site_name : remote_site_name;117 114 118 115 if (this.default_lang == null) { … … 344 341 String subaction = request.getParameter (GSParams.SUBACTION); 345 342 String collection = request.getParameter(GSParams.COLLECTION); 346 347 //specifically we clean up the cache session_ids_table if the two reconfigure command 348 //are issued: a=s&sa=c and a=s&sa=c&c=coll_name, in which case there is no caching action to be taken 343 String service = request.getParameter(GSParams.SERVICE); 344 345 // We clean up the cache session_ids_table if system 346 // commands are issued (and also don't need to do caching for this request) 349 347 boolean should_cache = true; 350 if(action != null && action.equals(GSParams.SYSTEM) 351 && subaction != null && subaction.equals(GSParams.CONFIGURE)) { 352 if (collection == null || collection.equals("")) { 353 //user reconfiugred the whole site, clean up all cached info 354 //logger.info("clear cache for the whole site."); 348 if(action != null && action.equals(GSParams.SYSTEM)) { 349 should_cache = false; 350 351 // we may want to remove all collection cache info, or just a specific collection 352 boolean clean_all = true; 353 String clean_collection = null; 354 // system commands are to activate/deactivate stuff 355 // collection param is in the sc parameter. 356 // don't like the fact that it is hard coded here 357 String coll = request.getParameter(GSParams.SYSTEM_CLUSTER); 358 if (coll != null && !coll.equals("")) { 359 clean_all = false; 360 clean_collection = coll; 361 } else { 362 // check other system types 363 if (subaction.equals("a") || subaction.equals("d")) { 364 String module_name = request.getParameter("sn"); 365 if (module_name != null && !module_name.equals("")) { 366 clean_all = false; 367 clean_collection = module_name; 368 } 369 } 370 } 371 if (clean_all) { 355 372 session_ids_table = new Hashtable(); 356 373 session.removeAttribute(GSXML.USER_SESSION_CACHE_ATT); 357 374 } else { 358 //clean up all cache info related to the collection 359 //logger.info("clear cache for collection: " + collection); 375 // just clean up info for clean_collection 360 376 ArrayList cache_list = new ArrayList(session_ids_table.values()); 361 377 for (int i=0; i<cache_list.size(); i++) { 362 378 UserSessionCache cache = (UserSessionCache)cache_list.get(i); 363 cache.cleanupCache(c ollection);379 cache.cleanupCache(clean_collection); 364 380 } 365 } 366 should_cache = false; 381 382 } 383 384 } 385 386 // cache_key is the collection name, or service name 387 String cache_key = collection; 388 if (cache_key == null || cache_key.equals("")) { 389 cache_key = service; 367 390 } 368 391 369 392 // logger.info("should_cache= " + should_cache); 393 370 394 //clear the collection-specific cache in the session, since we have no way to know whether this session is 371 395 //about the same collection as the last session or not. … … 382 406 // create a dumy collection name for Authentication 383 407 if (subaction != null && subaction.equals("authen")){ 384 c ollection= "0000000000";408 cache_key = "0000000000"; 385 409 } 386 410 … … 389 413 Hashtable table = null; 390 414 String sid = session.getId(); 391 if (should_cache == true && collection != null && !collection.equals("")) { 392 String key_str = valid_site_name + collection; 415 if (should_cache == true && cache_key != null && !cache_key.equals("")) { 393 416 if (session_ids_table.containsKey(sid)) { 394 417 session_cache = (UserSessionCache)session_ids_table.get(sid); 395 418 param_table = session_cache.getParamsTable(); 396 419 logger.info("collections in table: " + tableToString(param_table)); 397 if (param_table.containsKey( key_str)) {420 if (param_table.containsKey(cache_key)) { 398 421 //logger.info("existing table: " + collection); 399 table = (Hashtable)param_table.get( key_str);422 table = (Hashtable)param_table.get(cache_key); 400 423 } else { 401 424 table = new Hashtable(); 402 param_table.put( key_str, table);425 param_table.put(cache_key, table); 403 426 //logger.info("new table: " + collection); 404 427 } … … 406 429 param_table = new Hashtable(); 407 430 table = new Hashtable(); 408 param_table.put( key_str, table);431 param_table.put(cache_key, table); 409 432 session_cache = new UserSessionCache(sid, param_table); 410 433 session_ids_table.put(sid, session_cache); … … 417 440 // should we do all the following stuff if using default page? 418 441 // display the home page - the default page 419 action = "p"; 420 subaction = PageAction.HOME_PAGE; 421 422 xml_request.setAttribute (GSXML.ACTION_ATT, action); 423 xml_request.setAttribute (GSXML.SUBACTION_ATT, subaction); 424 425 } else { 426 442 xml_request.setAttribute (GSXML.ACTION_ATT, "p"); 443 xml_request.setAttribute (GSXML.SUBACTION_ATT, PageAction.HOME_PAGE); 444 } 445 else { 427 446 xml_request.setAttribute (GSXML.ACTION_ATT, action); 428 447 if (subaction != null) { 429 448 xml_request.setAttribute (GSXML.SUBACTION_ATT, subaction); 430 449 } 431 450 … … 438 457 while(params.hasMoreElements ()) { 439 458 String name = (String)params.nextElement (); 440 459 if (!name.equals (GSParams.ACTION) 441 460 && !name.equals (GSParams.SUBACTION) 442 461 && !name.equals (GSParams.LANGUAGE) … … 451 470 } 452 471 // either add it to the param list straight away, or save it to the session and add it later 453 if (this.params.shouldSave (name)) { 454 if (table != null) { 472 if (this.params.shouldSave (name) && table != null) { 455 473 table.put(name, value); 456 }457 474 } else { 458 475 Element param = this.doc.createElement (GSXML.PARAM_ELEM); … … 464 481 } 465 482 //put everything in the table into the session 483 // do we need to do this? why not just put from table into param list 466 484 if (table != null) { 467 485 Enumeration keys = table.keys (); … … 491 509 } 492 510 } 493 511 494 512 if (!output.equals ("html")) { 495 513 response.setContentType ("text/xml"); // for now use text … … 503 521 504 522 displaySize(session_ids_table); 505 } 523 } 524 506 525 //a debugging method 507 526 private void displaySize(Hashtable table) {
Note:
See TracChangeset
for help on using the changeset viewer.