irods
4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems. Fossies Dox: irods-4.2.8.tar.gz ("unofficial" and yet experimental doxygen-generated source code documentation) 
|
Go to the documentation of this file.
34 #include <boost/lexical_cast.hpp>
35 #include <boost/function.hpp>
36 #include <boost/any.hpp>
73 std::string str_array;
75 for(
const auto& el : boost::any_cast<
const std::vector<boost::any>&>( _array ) ) {
77 str_array += boost::any_cast< const std::string& >(el);
79 catch (
const boost::bad_any_cast& ) {
80 rodsLog(
LOG_ERROR,
"%s - failed to cast rule base file name entry to string", __PRETTY_FUNCTION__);
86 str_array = str_array.substr( 0, str_array.size() - 1 );
88 }
catch(
const boost::bad_any_cast& ) {
95 const boost::any& _array,
96 const std::string& _instance_name ) {
98 const auto& arr = boost::any_cast<const std::vector<boost::any>&>( _array );
99 for (
const auto& elem : arr ) {
101 const auto& tmp = boost::any_cast<const std::string&>(elem);
103 }
catch ( boost::bad_any_cast& ) {
106 "%s - failed to cast regex to string",
111 }
catch (
const boost::bad_any_cast& ) {
112 std::stringstream msg;
113 msg <<
"[" << _instance_name <<
"] failed to any_cast a std::vector<boost::any>&";
144 for(
const auto& el : re_plugin_arr ) {
145 const auto& plugin_config = boost::any_cast<const std::unordered_map<std::string, boost::any>&>(el);
147 if( inst_name == _instance_name) {
162 "failed to initialize native rule engine" );
177 "No regexes found in server config - using default regexes: [%s], [%s], [%s]",
188 }
catch (
const boost::bad_any_cast&
e) {
190 }
catch (
const std::out_of_range&
e) {
194 std::stringstream msg;
195 msg <<
"failed to find configuration for re-irods plugin ["
196 << _instance_name <<
"]";
215 "rule engine xre has not initialized, skip rule [%s]",
224 "looking up rule name %s, found = %d",
242 "rule engine xre has not initialized, skip rule [%s]",
249 "applying rule %s, params %ld",
255 if(!(err = _eff_hdlr(
"unsafe_ms_ctx", &rei)).ok()) {
259 struct all_resources{
271 std::stringstream expr;
275 for (
auto itr =
begin(_ps);itr!=
end(_ps);++itr ) {
277 snprintf(arg, 10,
"*ARG%d", i);
278 if(i!=0) expr <<
",";
286 rodsLog(
LOG_ERROR,
"unsupported argument for calling re rules from the rule language");
290 if( 0 == param.size() ) {
294 else if( 1 == param.size() ) {
301 for(
auto i : param ) {
302 addKeyVal( kvp, i.first.c_str(), i.second.c_str() );
314 for (
auto itr =
begin(_ps);itr!=
end(_ps);++itr ) {
316 snprintf(arg, 10,
"*ARG%d", i);
317 if(itr->type() ==
typeid(std::string)) {
318 }
else if(itr->type() ==
typeid(std::string*)) {
320 if(msParam !=
NULL) {
321 *boost::any_cast<std::string*>(*itr) =
reinterpret_cast<char *
>(msParam->
inOutStruct);
327 rodsLog(
LOG_DEBUG,
"only string arguments are supported for returning from xre rules to the calling rule");
334 "rule engine return %d", ret);
338 if( _rn.substr(0,4) ==
"pep_" ) {
339 if( rei && rei->
rsComm ) {
345 std::stringstream msg;
346 msg <<
"applyRuleUpdateParams failed for rule " << _rn;
348 return ERROR(ret, msg.str());
356 const std::string& _rt,
358 const std::string& _out_desc,
364 "rule engine xre has not initialized, skip rule [%s]",
371 if(!(err = _eff_hdlr(
"unsafe_ms_ctx", &rei)).ok()) {
377 "applying rule %s, params %ld",
388 std::stringstream msg;
389 msg <<
"execMyRule failed for rule " << _rt;
399 const std::string& _rt,
406 "rule engine xre has not initialized, skip rule [%s]",
413 if(!(err = _eff_hdlr(
"unsafe_ms_ctx", &rei)).ok()) {
419 "applying rule %s, params %ld",
423 std::string rule_text =
"{" + _rt +
"}";
427 (
char*)rule_text.c_str(),
434 std::stringstream msg;
435 msg <<
"computeExpression failed for input " << _rt;
446 const std::string& _context ) {
void rodsLog(int level, const char *formatStr,...)
int msiSplitPathByKey(msParam_t *inpPath, msParam_t *inpKey, msParam_t *outParentColl, msParam_t *outChildName, ruleExecInfo_t *rei)
irods::error exec_rule_expression(irods::default_re_ctx &, const std::string &_rt, msParamArray_t *_ms_params, irods::callback _eff_hdlr)
int msiStrCat(msParam_t *targParam, msParam_t *srcParam, ruleExecInfo_t *rei)
rulefmapdef_t coreRuleFuncMapDef
int addKeyVal(keyValPair_t *condInput, const char *keyWord, const char *value)
std::map< std::string, std::string > serialized_parameter_t
const std::string CFG_RE_PEP_REGEX_SET_KW("regexes_for_supported_peps")
const void * lookupFromEnv(Env *env, const char *key)
static RuleExistsHelper * Instance()
int msiSplitPath(msParam_t *inpPath, msParam_t *outParentColl, msParam_t *outChildName, ruleExecInfo_t *rei)
#define THROW(_code, _msg)
int GlobalAllRuleExecFlag
msParam_t * getMsParamByLabel(msParamArray_t *msParamArray, const char *label)
int msiGetStdoutInExecCmdOut(msParam_t *inpExecCmdOut, msParam_t *outStr, ruleExecInfo_t *rei)
irods::error list_rules(irods::default_re_ctx &, std::vector< std::string > &rule_vec)
msrvcStruct_t coreMsrvcStruct
ruleStruct_t appRuleStrct
const std::string CFG_PLUGIN_CONFIGURATION_KW("plugin_configuration")
irods::ms_table & get_microservice_table()
int msiExit(msParam_t *inpParam1, msParam_t *inpParam2, ruleExecInfo_t *rei)
const std::string MICROSERVICE_RULE_REGEX
const std::string PLUGIN_TYPE_RULE_ENGINE("rule_engines")
const std::string CFG_RE_RULEBASE_SET_KW("re_rulebase_set")
@ SYS_INVALID_INPUT_PARAM
auto end(const collection_iterator &) noexcept -> const collection_iterator
const std::string CFG_RE_FUNCTION_NAME_MAPPING_SET_KW("re_function_name_mapping_set")
auto begin(collection_iterator _iter) noexcept -> collection_iterator
int clearMsParamArray(msParamArray_t *msParamArray, int freeStruct)
int msiGetSessionVarValue(msParam_t *inpVar, msParam_t *outputMode, ruleExecInfo_t *rei)
#define REDEBUG_STACK_SIZE_FULL
irods::error exec_rule_text(irods::default_re_ctx &, const std::string &_rt, msParamArray_t *_ms_params, const std::string &_out_desc, irods::callback _eff_hdlr)
void initialize_microservice_table()
#define REDEBUG_STACK_SIZE_CURR
RuleEngineStatus ruleEngineStatus
ruleStruct_t coreRuleStrct
const std::string STATIC_PEP_RULE_REGEX
int computeExpression(char *expr, msParamArray_t *msParamArray, ruleExecInfo_t *rei, int reiSaveFlag, char *res)
irods::error start(irods::default_re_ctx &, const std::string &_instance_name)
int msiGetStderrInExecCmdOut(msParam_t *inpExecCmdOut, msParam_t *outStr, ruleExecInfo_t *rei)
const std::string CFG_INSTANCE_NAME_KW("instance_name")
error add_operation(const std::string &_op, std::function< error(types_t...)> _f)
int msiAddKeyValToMspStr(msParam_t *keyStr, msParam_t *valStr, msParam_t *msKeyValStr, ruleExecInfo_t *rei)
void registerRuleRegex(const std::string &_regex)
int execMyRule(char *ruleDef, msParamArray_t *inMsParamArray, const char *outParamsDesc, ruleExecInfo_t *rei)
struct reDebugStack reDebugStackCurr[1000]
#define ERROR(code_, message_)
error serialize_parameter(boost::any _in_param, serialized_parameter_t &_out_param)
rulefmapdef_t appRuleFuncMapDef
irods::error rule_exists(irods::default_re_ctx &, const std::string &_rn, bool &_ret)
void register_regexes_from_array(const boost::any &_array, const std::string &_instance_name)
int applyRuleUpdateParams(char *inAction, msParamArray_t *inMsParamArray, ruleExecInfo_t *rei, int reiSaveFlag)
static std::string local_instance_name
int initRuleEngine(const char *, rsComm_t *, const char *, const char *, const char *)
rulevardef_t appRuleVarDef
int msiStrchop(msParam_t *stringIn, msParam_t *stringOut, ruleExecInfo_t *rei)
const std::string CFG_SHARED_MEMORY_INSTANCE_KW("shared_memory_instance")
static std::string get_string_array_from_array(const boost::any &_array)
irods::error stop(irods::default_re_ctx &_u, const std::string &_instance_name)
const std::string CFG_RE_DATA_VARIABLE_MAPPING_SET_KW("re_data_variable_mapping_set")
int msiSubstr(msParam_t *stringIn, msParam_t *offset, msParam_t *length, msParam_t *stringOut, ruleExecInfo_t *rei)
int addMsParam(msParamArray_t *msParamArray, const char *label, const char *packInstruct, void *inOutStruct, bytesBuf_t *inpOutBuf)
rulevardef_t coreRuleVarDef
irods::error exec_rule(irods::default_re_ctx &, const std::string &_rn, std::list< boost::any > &_ps, irods::callback _eff_hdlr)
int msiStrlen(msParam_t *stringIn, msParam_t *lengthOut, ruleExecInfo_t *rei)
const std::string CFG_PLUGIN_SPECIFIC_CONFIGURATION_KW("plugin_specific_configuration")
int msiWriteRodsLog(msParam_t *inpParam1, msParam_t *outParam, ruleExecInfo_t *rei)
irods::pluggable_rule_engine< irods::default_re_ctx > * plugin_factory(const std::string &_inst_name, const std::string &_context)
int freeRErrorContent(rError_t *myError)
const std::string DYNAMIC_PEP_RULE_REGEX
char * reDebugStackFull[2000]
msrvcStruct_t appMsrvcStruct