{= # # # clear_caches.cfv # # include "templates.util.base_util"; include "templates.util.rbac.rbac_util"; debug_message("\n\n#### clear_caches.cfv \n\n"); # debug_message("\n" . node_as_string("v.fp") . "\n"); string session_id = volatile.session_id; bool is_root_admin = get_is_root_admin(); string page_token = v.fp.page_token; # # Check RBAC permissions (only root admin can convert profiles) # if (is_root_admin and get_is_valid_page_token(session_id, "tools", page_token)) then ( # # Clear the caches # subroutine(delete_cached_files( string main_directory), ( debug_message("\n#### delete_cached_files() \n"); debug_message("#### main_directory: " . main_directory . "\n"); if (file_exists(main_directory)) then ( node dir_contents = new_node(); get_directory_contents(main_directory, dir_contents); debug_message("#### dir_contents:\n" . node_as_string(dir_contents) . "\n"); node item; string type; string pathname; foreach item dir_contents ( type = @item{"type"}; pathname = @item{"pathname"}; if (type eq "directory") then ( delete_directory(pathname); ) else ( delete_file(pathname); ); ); ); )); string LAI = LOGANALYSISINFO_DIRECTORY; delete_cached_files(LAI . "profiles_cache"); delete_cached_files(LAI . "WebServerRoot/csv_export"); delete_cached_files(LAI . "WebServerRoot/graphs"); delete_cached_files(LAI . "WebServerRoot/session_files"); # Note, it is important to clear the sessions_cache because it contains # profiles list information which must be cleared. delete_cached_files(LAI . "sessions_cache"); # # Send response # 'tools.clearCachesResponse()'; ) else ( # No permission to view this resource (URL) display_no_permission_html(); ); =}