# # # # # delete_profile_util.cfv # # # # # handle_delete_profile_by_pathname() # handle_delete_profile_in_users() # handle_delete_profile_in_schedule() # handle_delete_profile_in_profiles_dashboard() # delete_database_directory() # # # # # handle_delete_profile_by_pathname() # # # subroutine(handle_delete_profile_by_pathname( string pathname), ( # This deletes the given pathname by moving it to TemporaryFiles if the pathnamne exists # The pathname already includes the profile_name directory, i.e.: # C:/LogAnalysisInfo/profiles_cache/profile_name # C:/LogAnalysisInfo/filters_cache/profile_name if (file_exists(pathname)) then ( # Move pathname to TemporaryFiles directory string checksum = md5_digest(pathname . now() . now_us()); string temporary_files_pathname = LOGANALYSISINFO_DIRECTORY . "TemporaryFiles/DeleteProfileData_" . checksum; move_file(pathname, temporary_files_pathname); ); )); # # # # handle_delete_profile_in_users() # # # subroutine(handle_delete_profile_in_users( string profile_name), ( node user_item; node access_item; node access; node user_access_profiles; node profile_item; bool is_modified_users = false; foreach user_item "users" ( if (user_item?{"access"}) then ( access = user_item{"access"}; foreach access_item access ( if (access_item?{"profiles"} and (num_subnodes(access_item{"profiles"}) > 0)) then ( user_access_profiles = access_item{"profiles"}; foreach profile_item user_access_profiles ( if (@profile_item eq profile_name) then ( delete_node(profile_item); is_modified_users = true; ); ); ); ); ); ); if (is_modified_users) then ( # One or more profiles have been removed in users, save users save_node("users"); ); )); # # # # handle_delete_profile_in_schedule() # # # subroutine(handle_delete_profile_in_schedule( string profile_name), ( node schedule_item; node actions; node action_item; bool is_deleted_schedule_action = false; foreach schedule_item "schedule" ( if (schedule_item?{"actions"}) then ( actions = schedule_item{"actions"}; foreach action_item actions ( if (action_item?{"profile"} and (@action_item{"profile"} eq profile_name)) then ( # Delete the action of the deleted profile delete_node(action_item); is_deleted_schedule_action = true; ); ); ); ); if (is_deleted_schedule_action) then ( save_node("schedule"); ); )); # # # # handle_delete_profile_in_profiles_dashboard() # # # subroutine(handle_delete_profile_in_profiles_dashboard( string profile_name), ( # This clears and deletes dependencies of the deleted profile # in profiles_dashboard. if (?("profiles_dashboard.columns") and num_subnodes("profiles_dashboard.columns") > 0) then ( node dashboard_columns = "profiles_dashboard.columns"; node column; string individual_profile_path; bool is_deleted_item = false; foreach column dashboard_columns ( if (@column{"profile_name"} eq profile_name) then ( # Clear header column data but don't delete the column. column{"profile_name"} = ""; column{"report_field"} = ""; column{"show_cell_labels"} = false; is_deleted_item = true; ); # Delete individual profile if it exists in column.profiles individual_profile_path = column . ".profiles." . profile_name; if (?(individual_profile_path)) then ( delete_node(individual_profile_path); is_deleted_item = true; ); ); if (is_deleted_item) then ( save_node("profiles_dashboard"); ); ); )); # # # # delete_database_directory() # # # subroutine(delete_database_directory( string profile_name), ( # This deletes the database directory of profile_name in # LogAnalysisInfo/Databases string db_dir_path = LOGANALYSISINFO_DIRECTORY . "Databases/" . profile_name; if (file_exists(db_dir_path)) then ( debug_message("Deleting db_dir_path: " . db_dir_path . "\n"); delete_directory(db_dir_path); ); ));