diff --git a/plugins/microservices/src/msi_preconditions.hpp b/server/core/include/irods/msi_preconditions.hpp similarity index 100% rename from plugins/microservices/src/msi_preconditions.hpp rename to server/core/include/irods/msi_preconditions.hpp diff --git a/server/re/CMakeLists.txt b/server/re/CMakeLists.txt index 9ca2aac0a4..d4415d7dd3 100644 --- a/server/re/CMakeLists.txt +++ b/server/re/CMakeLists.txt @@ -2,6 +2,7 @@ add_library( irods_server_re OBJECT "${CMAKE_CURRENT_SOURCE_DIR}/src/extractAvuMS.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/src/genquery2.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/genQueryMS.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/icatAdminMS.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/icatGeneralMS.cpp" diff --git a/server/re/include/irods/msi_genquery2.hpp b/server/re/include/irods/msi_genquery2.hpp new file mode 100644 index 0000000000..0256caa352 --- /dev/null +++ b/server/re/include/irods/msi_genquery2.hpp @@ -0,0 +1,6 @@ +#ifndef IRODS_MSI_GENQUERY2_HPP +#define IRODS_MSI_GENQUERY2_HPP + + + +#endif // IRODS_MSI_GENQUERY2_HPP diff --git a/server/re/include/irods/reAction.hpp b/server/re/include/irods/reAction.hpp index a29788cd90..93649c73cb 100644 --- a/server/re/include/irods/reAction.hpp +++ b/server/re/include/irods/reAction.hpp @@ -12,6 +12,7 @@ #include "irods/reNaraMetaData.hpp" #include "irods/reIn2p3SysRule.hpp" #include "irods/irods_ms_plugin.hpp" +#include "irods/msi_genquery2.hpp" int msiRollback( ruleExecInfo_t *rei ); int msiSetACL( msParam_t *recursiveFlag, msParam_t *accessLevel, msParam_t *userName, diff --git a/server/re/src/msi_genquery2.cpp b/server/re/src/msi_genquery2.cpp new file mode 100644 index 0000000000..7ab2b02859 --- /dev/null +++ b/server/re/src/msi_genquery2.cpp @@ -0,0 +1,88 @@ +#include "irods/msi_genquery2.hpp" + +#include "irods/irods_at_scope_exit.hpp" +#include "irods/rs_genquery2.hpp" +#include "irods/msParam.h" +#include "irods/irods_re_structs.hpp" +#include "irods/irods_logger.hpp" +//#include "irods/irods_plugin_context.hpp" +//#include "irods/irods_re_plugin.hpp" +#include "irods/irods_state_table.h" +#include "irods/rodsError.h" +#include "irods/rodsErrorTable.h" +#include "irods/msi_preconditions.hpp" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ + using log_msi = irods::experimental::log::microservice; + + // TODO Replace with process_stash, eventually. + struct genquery_context + { + nlohmann::json rows; + std::int32_t current_row = -1; + }; // struct genquery_context + + std::vector gq2_context; +} // anonymous namespace + +auto msi_genquery2_execute(MsParam* _handle, MsParam* _query_string, RuleExecInfo* _rei) -> int +{ + IRODS_MSI_REQUIRE_VALID_POINTER(_handle); + IRODS_MSI_REQUIRE_VALID_POINTER(_query_string); + IRODS_MSI_REQUIRE_VALID_POINTER(_rei); + + IRODS_MSI_REQUIRE_VALID_POINTER(_handle->type); + IRODS_MSI_REQUIRE_VALID_POINTER(_query_string->type); + + IRODS_MSI_REQUIRE_TYPE(_query_string->type, STR_MS_T); + + IRODS_MSI_REQUIRE_VALID_POINTER(_query_string->inOutStruct); + + GenQuery2Input input{}; + input.query_string = static_cast(_query_string->inOutStruct); + + char* results{}; + + if (const auto ec = rs_genquery2(_rei->rsComm, &input, &results); ec < 0) { + log_msi::error("Error while executing GenQuery2 query [error_code=[{}]].", ec); + return ec; + } + + gq2_context.push_back({.rows = nlohmann::json::parse(results), .current_row = -1}); + std::free(results); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc) + + // Return the handle to the caller. + fillStrInMsParam(_handle, std::to_string(gq2_context.size() - 1).c_str()); + + return 0; +} // msi_genquery2_execute + +auto msi_genquery2_next_row() -> int +{ + return 0; +} // msi_genquery2_next_row + +auto msi_genquery2_column() -> int +{ + return 0; +} // msi_genquery2_column + +auto msi_genquery2_destroy() -> int +{ + return 0; +} // msi_genquery2_destroy