myTestRule {# Input parameters are:# Key-value buffer (may be empty)# Key# ValuemsiGetSystemTime(*Time, "human");msiAddKeyVal(*Keyval, "TimeStamp", *Time);msiAssociateKeyValuePairsToObj(*Keyval,*Coll,"-C");msiGetCollectionPSmeta(*Coll,*Buf);writeBytesBuf("stdout", *Buf);}INPUT *Coll="/$rodsZoneClient/home/$userNameClient/sub1"OUTPUT ruleExecOut
gijs@dop232:~$ irule -F myTestRule.rremote addresses: 127.0.0.1 ERROR: rcExecMyRule error. status = -1097000 NO_RULE_OR_MSI_FUNCTION_FOUND_ERRLevel 0: DEBUG: error: cannot find rule for action "msiGetCollectionPSmeta" available: 102.line 8, col 1msiGetCollectionPSmeta(*Coll,*Buf);^
addAVUMetadataToColl(*Coll, *Attname, *Attvalue, *Attunit, *Status) { # add metadata to a collection *Status = "1"; # msiSetAVU("-C", *Coll, *Attname, *Attvalue, *Attunit); msiAddKeyVal(*keyval, *Attname, *Attvalue); writeKeyValPairs('stdout', *keyval, " is : "); # msiAddKeyVal(*Keyval, *Attname, *Attvalue); # msiAssociateKeyValuePairsToObj(*Keyval,*Coll,"-C"); *Status = "0"; }
May 24 07:29:39 pid:29899 NOTICE: msiWriteRodsLog message: Collection created: /tempZone/home/rods/sub1 <- 123, 345,May 24 07:29:39 pid:29899 remote addresses: 127.0.0.1, 192.168.102.1 ERROR: rsExecMyRule : -1822000, [-] /home/irodsbuild/irods/server/re/include/irods_re_plugin.hpp:238:irods::error irods::pluggable_rule_engine<std::__1::tuple<> >::exec_rule_text(std::string, T &, irods::callback, As &&...) [T = std::__1::tuple<>, As = <std::__1::tuple<>, irods::callback, MsParamArray *, std::__1::basic_string<char> *, RuleExecInfo *>] : status [INVALID_ANY_CAST] errno [] -- message [failed to extract exec_rule_text operation from instance [irods_rule_engine_plugin-irods_rule_language-instance] exception message [boost::bad_any_cast: failed conversion using boost::any_cast]]
Pluggable Rule Engine - Seventh plugin interface now supports writing rule engines for any language. The iRODS Rule Language has been moved to a plugin, alongside a default policy C++ rule engine.
Hello,
The source for msiGetCollectionPSmeta and other legacy microservices can be found at https://github.com/DICE-UNC/microservices.
Please note that this package was last built for iRODS 4.1 and would likely need updating to work with 4.2. It contains microservices that came standard with iRODS 2 and 3 (hence their use in the book) but have been deprecated and are no longer supported by the iRODS consortium. They will be removed from any future installments of the microservice workbook.
Back to your example, to get the metadata associated with an object you can define and execute a query, which is now easy to do with the rule language, e.g:
msiSplitPath(*obj_path, *coll_name, *obj_name);
foreach(*row in select META_DATA_ATTR_NAME, META_DATA_ATTR_VALUE, META_DATA_ATTR_UNITS where COLL_NAME =*coll_name and DATA_NAME =*obj_name) {
writeLine('serverlog', 'ATTRIBUTE=[*row.META_DATA_ATTR_NAME]')
writeLine('serverlog', 'VALUE=[*row.META_DATA_ATTR_VALUE]')
#etc...
}
Antoine