{= # # # # save_db_data.cfv # # # include "templates.util.base_util"; include "templates.util.rbac.rbac_util"; include "templates.util.backup_util"; include "templates.util.profiles.get_profile_data_util"; debug_message("#### save_db_data.cfv START \n"); string profile_name = internal.profile_name; 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_config_feature_permission(session_id, profile_name, "database", "edit")) and get_is_valid_page_token(session_id, "database", page_token)) then ( debug_message("\n" . node_as_string("v.fp") . "\n"); string user_node_name = node_name(volatile.authenticated_user_node_path); string client_profiles_list_checksum = v.fp.profiles_list_checksum; # Get profiles checksum before the profile becomes saved! string profiles_list_checksum_before_profile_modification = get_profiles_list_checksum(session_id, is_root_admin, user_node_name); node profile = "profiles." . profile_name; string db_path = profile . ".database"; node item; # node options_node = db_path . ".options"; node server_node = db_path . ".options.server"; node tuning_node = db_path . ".tuning"; string password; foreach item "v.fp.server" ( if (node_name(item) ne "password") then ( set_subnode_value(server_node, node_name(item), @item); ) else ( # Save password encrypted password = @item; if (password ne "") then ( password = format(@item, "!encrypt"); ); @server_node{"password"} = password; ); ); foreach item "v.fp.tuning" ( if (node_name(item) ne "split_queries") then ( set_subnode_value(tuning_node, node_name(item), @item); ) else ( tuning_node . ".split_queries.method" = @("v.fp.tuning.split_queries.method"); tuning_node . ".split_queries.number_of_threads" = @("v.fp.tuning.split_queries.number_of_threads"); ); ); # KHP 08/Aug/2013 - Changed save_node() to save_and_backup_profile() # save_node(profile); save_and_backup_profile(profile_name, profile); # Get profile_changes_dat, also in case of an error! string profile_changes_dat = get_profiles_list_data_after_profiles_changes( session_id, is_root_admin, user_node_name, client_profiles_list_checksum, profiles_list_checksum_before_profile_modification, profile_name, "save_profile"); # # Response # string dat = "{"; dat .= add_json("profileChanges", profile_changes_dat, "obj"); dat = close_json(dat); "database.saveDatabaseResponse(" . dat . ")\n"; ) else ( # No permission to access this resource (URL) display_no_permission_html(); ); =}