Skip to content

Commit

Permalink
More review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
FifthPotato committed Jan 22, 2024
1 parent 7854beb commit c05d157
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
shutil.copy2(cls.temp_path,cls.IRODS_CONFIG_FILE_PATH)
shutil.copy2(cls.temp_path,cls.IRODS_CONFIG_FILE_PATH)

def test_guard_atomic_operations_admin_only(self):
# set metadata_guard config AVU on collection to admin_only and irods:: as protected prefix
Expand Down
1 change: 1 addition & 0 deletions packaging/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /etc/irods
chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /usr/lib/irods/plugins/rule_engines/libirods_rule_engine_plugin-metadata_guard.so
chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /var/lib/irods
chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /var/lib/irods/scripts
chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /var/lib/irods/scripts/irods_prc_tests
chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /var/lib/irods/scripts/irods_prc_tests/test_rule_engine_plugin_metadata_guard_atomic.py
chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /var/lib/irods/scripts/irods
chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /var/lib/irods/scripts/irods/test
Expand Down
25 changes: 11 additions & 14 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ namespace

auto list_rules(irods::default_re_ctx&, std::vector<std::string>& _rules) -> irods::error
{
_rules.push_back("pep_api_mod_avu_metadata_pre");
_rules.push_back("pep_api_mod_avu_metadata_pre");
_rules.push_back("pep_api_atomic_apply_metadata_operations_pre");
return SUCCESS();
}
Expand Down Expand Up @@ -147,7 +147,7 @@ namespace
try {
auto* input = boost::any_cast<modAVUMetadataInp_t*>(*std::next(std::begin(_rule_arguments), 2));
auto& rei = get_rei(_effect_handler);
const auto config = load_plugin_config(rei);
const auto config = load_plugin_config(rei);

if (!config) {
return CODE(RULE_ENGINE_CONTINUE);
Expand Down Expand Up @@ -205,8 +205,8 @@ namespace
// clang-format on
}
catch (const std::exception& e) {
log_re::error({{"log_message", e.what()}, {"rule_engine_plugin", "metadata_guard"}});
}
log_re::error({{"log_message", e.what()}, {"rule_engine_plugin", "metadata_guard"}});
}
return CODE(RULE_ENGINE_CONTINUE);
}

Expand Down Expand Up @@ -243,17 +243,14 @@ namespace
json input = json::parse(input_bb_casted, input_bb_casted + input_bb->len);

const auto& operations = input.at("operations");
std::vector<irods::error> op_codes;

std::transform(operations.begin(), operations.end(), std::back_inserter(op_codes), [&rei](json op) {
return rule_logic(op.at("attribute").get_ref<const std::string&>(), rei);
});
if (const auto& ret = std::find_if(
op_codes.begin(), op_codes.end(), [&op_codes](const irods::error& err) { return !err.ok(); });
ret != op_codes.end())
{
return *ret;

for (auto&& op : operations) {
const auto& err_code = rule_logic(op.at("attribute").get_ref<const std::string&>(), rei);
if (!err_code.ok()) {
return err_code;
}
}

return CODE(RULE_ENGINE_CONTINUE);
}
catch (const json::parse_error& e) {
Expand Down

0 comments on commit c05d157

Please sign in to comment.