| 279 | | String[] query_arr = query_string.split("&"); |
|---|
| 280 | | boolean redirect = false; |
|---|
| 281 | | String href = null; |
|---|
| 282 | | String rl = null; |
|---|
| 283 | | for (int i=0;i<query_arr.length;i++){ |
|---|
| 284 | | if (query_arr[i].startsWith("el")){ |
|---|
| 285 | | if (query_arr[i].substring(query_arr[i].indexOf("=")+1,query_arr[i].length()).equals("direct")){ |
|---|
| 286 | | redirect = true; |
|---|
| 287 | | } |
|---|
| 288 | | }else if(query_arr[i].startsWith("href")){ |
|---|
| 289 | | href = query_arr[i].substring(query_arr[i].indexOf("=")+1,query_arr[i].length()); |
|---|
| 290 | | href = href.replaceAll("%2f", "/"); |
|---|
| 291 | | href = href.replaceAll("%7e", "~"); |
|---|
| 292 | | href = href.replaceAll("%3f", "?"); |
|---|
| 293 | | href = href.replaceAll("%3A", "\\:"); |
|---|
| 294 | | }else if(query_arr[i].startsWith("rl")){ |
|---|
| 295 | | rl = query_arr[i].substring(query_arr[i].indexOf("=")+1,query_arr[i].length()); |
|---|
| 296 | | } |
|---|
| | 279 | String[] query_arr = query_string.split("&"); |
|---|
| | 280 | boolean redirect = false; |
|---|
| | 281 | String href = null; |
|---|
| | 282 | String rl = null; |
|---|
| | 283 | for (int i=0;i<query_arr.length;i++){ |
|---|
| | 284 | if (query_arr[i].startsWith("el")){ |
|---|
| | 285 | if (query_arr[i].substring(query_arr[i].indexOf("=")+1,query_arr[i].length()).equals("direct")){ |
|---|
| | 286 | redirect = true; |
|---|
| | 287 | } |
|---|
| | 288 | }else if(query_arr[i].startsWith("href")){ |
|---|
| | 289 | href = query_arr[i].substring(query_arr[i].indexOf("=")+1,query_arr[i].length()); |
|---|
| | 290 | href = href.replaceAll("%2f", "/"); |
|---|
| | 291 | href = href.replaceAll("%7e", "~"); |
|---|
| | 292 | href = href.replaceAll("%3f", "?"); |
|---|
| | 293 | href = href.replaceAll("%3A", "\\:"); |
|---|
| | 294 | }else if(query_arr[i].startsWith("rl")){ |
|---|
| | 295 | rl = query_arr[i].substring(query_arr[i].indexOf("=")+1,query_arr[i].length()); |
|---|
| 298 | | //if query_string contains "el=", the web page will be redirected to the external URl, otherwise a greenstone page with an external URL will be displayed |
|---|
| 299 | | //"rl=0" this is an external link |
|---|
| 300 | | //"rl=1" this is an internal link |
|---|
| 301 | | if ((redirect) && (href != null) && (rl.equals("0"))){// This is an external link, the web page is re-directed to the external URL (&el=&rl=0&href="http://...") |
|---|
| 302 | | response.setContentType("text/xml"); |
|---|
| 303 | | response.sendRedirect(href); |
|---|
| 304 | | } |
|---|
| | 297 | } |
|---|
| | 298 | //if query_string contains "el=", the web page will be redirected to the external URl, otherwise a greenstone page with an external URL will be displayed |
|---|
| | 299 | //"rl=0" this is an external link |
|---|
| | 300 | //"rl=1" this is an internal link |
|---|
| | 301 | if ((redirect) && (href != null) && (rl.equals("0"))){// This is an external link, the web page is re-directed to the external URL (&el=&rl=0&href="http://...") |
|---|
| | 302 | response.setContentType("text/xml"); |
|---|
| | 303 | response.sendRedirect(href); |
|---|
| | 304 | } |
|---|
| 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."); |
|---|
| 355 | | session_ids_table = new Hashtable(); |
|---|
| 356 | | session.removeAttribute(GSXML.USER_SESSION_CACHE_ATT); |
|---|
| 357 | | } else { |
|---|
| 358 | | //clean up all cache info related to the collection |
|---|
| 359 | | //logger.info("clear cache for collection: " + collection); |
|---|
| 360 | | ArrayList cache_list = new ArrayList(session_ids_table.values()); |
|---|
| 361 | | for (int i=0; i<cache_list.size(); i++) { |
|---|
| 362 | | UserSessionCache cache = (UserSessionCache)cache_list.get(i); |
|---|
| 363 | | cache.cleanupCache(collection); |
|---|
| 364 | | } |
|---|
| 365 | | } |
|---|
| 366 | | should_cache = false; |
|---|
| | 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."); |
|---|
| | 355 | session_ids_table = new Hashtable(); |
|---|
| | 356 | session.removeAttribute(GSXML.USER_SESSION_CACHE_ATT); |
|---|
| | 357 | } else { |
|---|
| | 358 | //clean up all cache info related to the collection |
|---|
| | 359 | //logger.info("clear cache for collection: " + collection); |
|---|
| | 360 | ArrayList cache_list = new ArrayList(session_ids_table.values()); |
|---|
| | 361 | for (int i=0; i<cache_list.size(); i++) { |
|---|
| | 362 | UserSessionCache cache = (UserSessionCache)cache_list.get(i); |
|---|
| | 363 | cache.cleanupCache(collection); |
|---|
| 374 | | String name = (String)attributeNames.nextElement(); |
|---|
| 375 | | if (!name.equals (GSXML.USER_SESSION_CACHE_ATT) |
|---|
| 376 | | && !name.equals (GSParams.LANGUAGE) |
|---|
| 377 | | && !name.equals (GSXML.USER_ID_ATT)) { |
|---|
| 378 | | session.removeAttribute(name); |
|---|
| 379 | | } |
|---|
| 380 | | } |
|---|
| 381 | | |
|---|
| | 374 | String name = (String)attributeNames.nextElement(); |
|---|
| | 375 | if (!name.equals (GSXML.USER_SESSION_CACHE_ATT) |
|---|
| | 376 | && !name.equals (GSParams.LANGUAGE) |
|---|
| | 377 | && !name.equals (GSXML.USER_ID_ATT)) { |
|---|
| | 378 | session.removeAttribute(name); |
|---|
| | 379 | } |
|---|
| | 380 | } |
|---|
| | 381 | |
|---|
| 392 | | String key_str = valid_site_name + collection; |
|---|
| 393 | | if (session_ids_table.containsKey(sid)) { |
|---|
| 394 | | session_cache = (UserSessionCache)session_ids_table.get(sid); |
|---|
| 395 | | param_table = session_cache.getParamsTable(); |
|---|
| 396 | | logger.info("collections in table: " + tableToString(param_table)); |
|---|
| 397 | | if (param_table.containsKey(key_str)) { |
|---|
| 398 | | //logger.info("existing table: " + collection); |
|---|
| 399 | | table = (Hashtable)param_table.get(key_str); |
|---|
| 400 | | } else { |
|---|
| 401 | | table = new Hashtable(); |
|---|
| 402 | | param_table.put(key_str, table); |
|---|
| 403 | | //logger.info("new table: " + collection); |
|---|
| 404 | | } |
|---|
| 405 | | } else { |
|---|
| 406 | | param_table = new Hashtable(); |
|---|
| 407 | | table = new Hashtable(); |
|---|
| 408 | | param_table.put(key_str, table); |
|---|
| 409 | | session_cache = new UserSessionCache(sid, param_table); |
|---|
| 410 | | session_ids_table.put(sid, session_cache); |
|---|
| 411 | | session.setAttribute(GSXML.USER_SESSION_CACHE_ATT, session_cache); |
|---|
| 412 | | //logger.info("new session id"); |
|---|
| 413 | | } |
|---|
| | 392 | String key_str = valid_site_name + collection; |
|---|
| | 393 | if (session_ids_table.containsKey(sid)) { |
|---|
| | 394 | session_cache = (UserSessionCache)session_ids_table.get(sid); |
|---|
| | 395 | param_table = session_cache.getParamsTable(); |
|---|
| | 396 | logger.info("collections in table: " + tableToString(param_table)); |
|---|
| | 397 | if (param_table.containsKey(key_str)) { |
|---|
| | 398 | //logger.info("existing table: " + collection); |
|---|
| | 399 | table = (Hashtable)param_table.get(key_str); |
|---|
| | 400 | } else { |
|---|
| | 401 | table = new Hashtable(); |
|---|
| | 402 | param_table.put(key_str, table); |
|---|
| | 403 | //logger.info("new table: " + collection); |
|---|
| | 404 | } |
|---|
| | 405 | } else { |
|---|
| | 406 | param_table = new Hashtable(); |
|---|
| | 407 | table = new Hashtable(); |
|---|
| | 408 | param_table.put(key_str, table); |
|---|
| | 409 | session_cache = new UserSessionCache(sid, param_table); |
|---|
| | 410 | session_ids_table.put(sid, session_cache); |
|---|
| | 411 | session.setAttribute(GSXML.USER_SESSION_CACHE_ATT, session_cache); |
|---|
| | 412 | //logger.info("new session id"); |
|---|
| | 413 | } |
|---|
| 467 | | Enumeration keys = table.keys (); |
|---|
| 468 | | while(keys.hasMoreElements ()) { |
|---|
| 469 | | String name = (String)keys.nextElement(); |
|---|
| 470 | | session.setAttribute(name, (String)table.get(name)); |
|---|
| 471 | | } |
|---|
| | 467 | Enumeration keys = table.keys (); |
|---|
| | 468 | while(keys.hasMoreElements ()) { |
|---|
| | 469 | String name = (String)keys.nextElement(); |
|---|
| | 470 | session.setAttribute(name, (String)table.get(name)); |
|---|
| | 471 | } |
|---|
| 508 | | if(table == null) { |
|---|
| 509 | | logger.info("cached table is null"); |
|---|
| 510 | | return; |
|---|
| 511 | | } |
|---|
| 512 | | if (table.size() == 0) { |
|---|
| 513 | | logger.info("cached table size is zero"); |
|---|
| 514 | | return; |
|---|
| 515 | | } |
|---|
| 516 | | int num_cached_coll = 0; |
|---|
| 517 | | ArrayList cache_list = new ArrayList(table.values()); |
|---|
| 518 | | for (int i=0; i<cache_list.size(); i++) { |
|---|
| 519 | | num_cached_coll += ((UserSessionCache)cache_list.get(i)).tableSize(); |
|---|
| 520 | | } |
|---|
| 521 | | logger.info("Number of sessions : total number of cached collection info = " + table.size() + " : " + num_cached_coll); |
|---|
| | 508 | if(table == null) { |
|---|
| | 509 | logger.info("cached table is null"); |
|---|
| | 510 | return; |
|---|
| | 511 | } |
|---|
| | 512 | if (table.size() == 0) { |
|---|
| | 513 | logger.info("cached table size is zero"); |
|---|
| | 514 | return; |
|---|
| | 515 | } |
|---|
| | 516 | int num_cached_coll = 0; |
|---|
| | 517 | ArrayList cache_list = new ArrayList(table.values()); |
|---|
| | 518 | for (int i=0; i<cache_list.size(); i++) { |
|---|
| | 519 | num_cached_coll += ((UserSessionCache)cache_list.get(i)).tableSize(); |
|---|
| | 520 | } |
|---|
| | 521 | logger.info("Number of sessions : total number of cached collection info = " + table.size() + " : " + num_cached_coll); |
|---|