Пример #1
0
    void server_properties::capture() {
        // if a json version exists, then attempt to capture
        // that
        std::string svr_cfg;
        irods::error ret = irods::get_full_path_for_config_file(
                               "server_config.json",
                               svr_cfg );
        if ( ret.ok() ) {
            capture_json( svr_cfg );

            std::string db_cfg;
            ret = irods::get_full_path_for_config_file(
                      "database_config.json",
                      db_cfg );
            if ( ret.ok() ) {
                capture_json( db_cfg );
            }

        }
        else {
            capture_legacy();
        }
        captured_ = true;

    } // capture
    error environment_properties::capture() {
        std::string json_file, json_session_file;
        error ret = get_json_environment_file(
                        json_file,
                        json_session_file );

        bool do_parse_legacy = false;
        if ( ret.ok() ) {
            if ( fs::exists( json_file ) ) {
                ret = capture_json( json_file );
                if ( !ret.ok() ) {
                    // debug - irods::log( PASS( ret ) );
                    do_parse_legacy = true;

                }
                else {
                    config_props_.set< std::string >(
                        CFG_IRODS_ENVIRONMENT_FILE_KW,
                        json_file );
                    ret = capture_json( json_session_file );
                    if ( !ret.ok() ) {
                        // debug - irods::log( PASS( ret ) );

                    }

                    config_props_.set< std::string >(
                        CFG_IRODS_SESSION_ENVIRONMENT_FILE_KW,
                        json_session_file );

                }

            }
            else {
                do_parse_legacy = true;

            }

        }
        else {
            do_parse_legacy = true;

        }

        if ( do_parse_legacy ) {
            std::string legacy_file, legacy_session_file;
            ret = get_legacy_environment_file(
                      legacy_file,
                      legacy_session_file );
            if ( ret.ok() ) {
                ret = capture_legacy( legacy_file );
                if ( !ret.ok() ) {
                    // debug - irods::log( PASS( ret ) );

                }
                config_props_.set< std::string >(
                    CFG_IRODS_ENVIRONMENT_FILE_KW,
                    legacy_file );

                // session file ( written by icd ) already moved to json
                ret = capture_json( legacy_session_file );
                if ( !ret.ok() ) {
                    // debug - irods::log( PASS( ret ) );

                }

                config_props_.set< std::string >(
                    CFG_IRODS_SESSION_ENVIRONMENT_FILE_KW,
                    legacy_session_file );

            }
            else {
                // debug - irods::log( PASS( ret ) );

            }

        } // do parse legacy

        // set the captured flag so we no its already been captured
        captured_ = true;
        return ret;

    } // capture