{= # # # get_db_info_data.cfv # # include "templates.util.base_util"; include "templates.util.database"; include "templates.util.encoding"; debug_message("\n#### get_db_info_data.cfv START \n\n"); # # # Utilities # # subroutine(get_db_info_data_item_dat( string item_name, string item_label, string item_value), ( string item_dat = "{"; item_dat .= add_json("name", item_name, "string"); # We require the item_name to check last_modification_time_localtime on client side item_dat .= add_json("label", item_label, "string"); item_dat .= add_json("value", item_value, "string"); item_dat = close_json(item_dat); item_dat; )); # # # Get database info data # # string session_id = volatile.session_id; bool is_root_admin = get_is_root_admin(); bool is_view_permission = is_root_admin; string profile_name = internal.profile_name; string page_token = v.sys.page_token; if (!is_root_admin) then ( # # Check if the user has permission to view this data # node super_role = get_super_role_of_profile(session_id, profile_name); is_view_permission = (?(super_role . ".reports.database_info")); ); if (is_view_permission and get_is_valid_page_token(session_id, "statistics", page_token)) then ( delete_node("volatile.database_info"); # Note, get_date_info=false so that get_database_info returns immediately because we assume xrefs to be up to date anyway. get_database_info(profile_name, "volatile.database_info", false); node db_info = "volatile.database_info"; debug_message("\n#### get_db_info_data.cfv - database_info:\n" . node_as_string(db_info) . "\n"); bool is_real_time_processing = get_is_real_time_processing(profile_name); bool database_is_building = get_database_is_building(profile_name, db_info); bool no_date_range = if (db_info?{"no_date_range"}) then (@db_info{"no_date_range"}) else (false); string last_modification_time_localtime; string earliest_date_time; string latest_date_time; if (db_info?{"last_modification_time_localtime"} and (@db_info{"last_modification_time_localtime"} ne "")) then ( last_modification_time_localtime = format(@db_info{"last_modification_time_localtime"}, "date_time"); ) else ( last_modification_time_localtime = "-"; ); if (!no_date_range) then ( if (db_info?{"earliest_date_time"} and (@db_info{"earliest_date_time"} ne "")) then ( earliest_date_time = format(@db_info{"earliest_date_time"}, "date_time"); ) else ( earliest_date_time = "-"; ); if (db_info?{"latest_date_time"} and (@db_info{"latest_date_time"} ne "")) then ( latest_date_time = format(@db_info{"latest_date_time"}, "date_time"); ) else ( latest_date_time = "-"; ); ) else ( # No date/time data in database, this is i.e. the case if all log entries have been rejected # and there is no more date information. earliest_date_time = lang_stats.general.no_date_information_in_database; latest_date_time = lang_stats.general.no_date_information_in_database; ); string db_info_dat = "["; db_info_dat .= get_db_info_data_item_dat("last_modification_time_localtime", lang_stats.database_info.last_modified, last_modification_time_localtime) . ","; db_info_dat .= get_db_info_data_item_dat("earliest_date_time", lang_stats.database_info.earliest_log_entry, earliest_date_time) . ","; db_info_dat .= get_db_info_data_item_dat("latest_date_time", lang_stats.database_info.latest_log_entry, latest_date_time); db_info_dat .= "]"; # # # Send response # # string dat = "{"; dat .= add_json("isRealTimeProcessing", is_real_time_processing, "bool"); dat .= add_json("databaseIsBuilding", database_is_building, "bool"); dat .= add_json("dbInfoDat", db_info_dat, "obj"); dat = close_json(dat); debug_message("#### dat:\n" . dat . "\n"); "databaseInfo.getDbInfoDataResponse(" . dat . ")\n"; ) else ( # No permission to view this resource (URL) display_no_permission_html(); ); =}