{= # # # # check_pathname_and_data.cfv # Checks if the version 7 directory exists and responds # with information about existing profiles, schedules and users # # # # include "templates.util.base_util"; include "templates.util.rbac.rbac_util"; include "templates.util.encoding"; include "templates.admin_pages.import_data.import_data_util"; debug_message("\n#### check_pathname_and_data.cfv START\n\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 # if ((is_root_admin or get_admin_feature_permission(session_id, "import_data", "view")) and get_is_valid_page_token(session_id, "import_data", page_token)) then ( string lai_pathname_in_utf8 = v.fp.pathname; # LogAnalysisInfo pathname # string lai_pathname_in_local_code_page = convert_utf8_to_local_code_page(replace_all(lai_pathname_in_utf8, "\\", "\\\\")); string lai_pathname_in_local_code_page = convert_utf8_to_local_code_page(lai_pathname_in_utf8); bool is_valid_version_7_path = false; string v7_profiles_dat = "[]"; int v7_number_of_schedules = 0; int v7_number_of_users = 0; bool is_duplicate_users = false; string current_user_username; string error_message; string dir_divider = (if _PLATFORM eq "Win32" then "\\" else "/"); debug_message("#### lai_pathname_in_utf8: " . lai_pathname_in_utf8 . "\n"); if (file_exists(lai_pathname_in_local_code_page)) then ( # Make sure this is a version 7 directory by checking # for a file which exists in version 7 but not in version 8 # Remove trailing directory divider if it exists if (ends_with(lai_pathname_in_local_code_page, dir_divider)) then ( lai_pathname_in_local_code_page = replace_last(lai_pathname_in_local_code_page, dir_divider, ""); ); string error_handling_pathname = lai_pathname_in_local_code_page . dir_divider . "templates" . dir_divider . "shared" . dir_divider . "error_handling"; # debug_message("#### error_handling_pathname: " . error_handling_pathname . "\n"); if (file_exists(error_handling_pathname)) then ( # # Save the valid lai_pathname_in_utf8 in version 8 so that we can use it as default pathname # "system.import.version_7_log_analysis_info_pathname" = lai_pathname_in_utf8; save_node("system"); is_valid_version_7_path = true; ) else ( error_message = lang_admin.import.pathname_not_v7; ); ) else ( error_message = lang_admin.import.pathname_does_not_exist; ); # # # Get version 7 data # # if (is_valid_version_7_path) then ( # Create a version_8_profiles_lookup to check for duplicate profiles (Not anymore in use!) # delete_node("v.version_8_profiles_lookup"); # v.version_8_profiles_lookup = ""; # node profile_item; # foreach profile_item "profiles" ( # "v.version_8_profiles_lookup." . lowercase(@profile_item{"label"}) = node_name(profile_item); # ); # debug_message("\n" . node_as_string("v.version_8_profiles_lookup") . "\n"); v7_profiles_dat = import_data_get_v7_profiles_dat(lai_pathname_in_local_code_page, dir_divider); node schedule7 = import_data_get_schedule7_node(lai_pathname_in_local_code_page, dir_divider); v7_number_of_schedules = num_subnodes(schedule7); string version8_root_admin_username = @("users.root_admin.username"); string current_user_node_name = node_name(volatile.authenticated_user_node_path); current_user_username = @("users." . current_user_node_name . ".username"); node users7 = import_data_get_users7_node(lai_pathname_in_local_code_page, dir_divider, version8_root_admin_username, current_user_username); v7_number_of_users = num_subnodes(users7); is_duplicate_users = import_data_get_is_duplicate_users(users7); ); # # # Get version 8 profile data (required to check for existing database directories or database names) # # string v8_profiles_dat = import_data_get_v8_profiles_dat(); # # # # Response # # # string dat = '{'; dat .= add_json("isValid", is_valid_version_7_path, "bool"); dat .= add_json("v7profilesDb", v7_profiles_dat, "obj"); dat .= add_json("v8profilesDb", v8_profiles_dat, "obj"); dat .= add_json("v7numberOfSchedules", v7_number_of_schedules, "int"); dat .= add_json("v7numberOfUsers", v7_number_of_users, "int"); dat .= add_json("isDuplicateUsers", is_duplicate_users, "bool"); dat .= add_json("currentUserUsername", current_user_username, "string"); dat .= add_json("errorMsg", error_message, "string"); dat = close_json(dat); debug_message("#### is_valid_version_7_path: " . is_valid_version_7_path . "\n\n"); debug_message("#### v7_profiles_dat: " . v7_profiles_dat . "\n\n"); debug_message("#### v8_profiles_dat: " . v8_profiles_dat . "\n\n"); debug_message("#### v7_number_of_schedules: " . v7_number_of_schedules . "\n\n"); debug_message("#### v7_number_of_users: " . v7_number_of_users . "\n\n"); debug_message("#### is_duplicate_users: " . is_duplicate_users . "\n\n"); debug_message("#### error_message: " . error_message . "\n"); 'checkoutPathnameAndDataResponse(' . dat . ')\n'; ) else ( # No permission to access this resource (URL) display_no_permission_html(); ); =}