Skip to content

Commit

Permalink
Still review changes...
Browse files Browse the repository at this point in the history
  • Loading branch information
FifthPotato committed Jan 25, 2024
1 parent bb0de4e commit dcdab03
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ namespace
auto check_operation_for_violations(const std::string& _object_name, ruleExecInfo_t& rei) -> irods::error
{
const auto config = load_plugin_config(rei);
if(config == std::nullopt) {
if (config == std::nullopt) {
return CODE(RULE_ENGINE_CONTINUE);
}
}
const auto prefixes_iter = config->find("prefixes");
if (prefixes_iter == config->cend()) {
return CODE(RULE_ENGINE_CONTINUE);
Expand All @@ -121,10 +121,7 @@ namespace
return CODE(RULE_ENGINE_CONTINUE);
}
const auto admin_iter = config->find("admin_only");
if (admin_iter == config->cend()) {
return CODE(RULE_ENGINE_CONTINUE);
}
if (admin_iter->get<bool>()) {
if (admin_iter != config->cend() && admin_iter->get<bool>()) {

This comment has been minimized.

Copy link
@trel

trel Jan 25, 2024

Member

the return CODE(RULE_ENGINE_CONTINUE is gone... just making sure this was intentional.

This comment has been minimized.

Copy link
@alanking

alanking Jan 25, 2024

Contributor

I think that was in response to this comment: #65 (comment) (Or @FifthPotato noticed and fixed it)

return user_is_administrator(*rei.rsComm);
}

Expand All @@ -149,7 +146,8 @@ namespace
return ERROR(CAT_INSUFFICIENT_PRIVILEGE_LEVEL, "User is not allowed to modify metadata");
}

auto handle_pep_api_mod_avu_metadata_pre(std::list<boost::any>& _rule_arguments, irods::callback _effect_handler) -> irods::error
auto handle_pep_api_mod_avu_metadata_pre(std::list<boost::any>& _rule_arguments, irods::callback _effect_handler)
-> irods::error
{
try {
auto* input = boost::any_cast<modAVUMetadataInp_t*>(*std::next(std::begin(_rule_arguments), 2));
Expand Down Expand Up @@ -218,8 +216,8 @@ namespace
return CODE(RULE_ENGINE_CONTINUE);
}

auto handle_pep_api_atomic_apply_metadata_operations_pre(std::list<boost::any>& _rule_arguments, irods::callback _effect_handler)
-> irods::error
auto handle_pep_api_atomic_apply_metadata_operations_pre(std::list<boost::any>& _rule_arguments,
irods::callback _effect_handler) -> irods::error
{
auto is_input_valid = [](const bytesBuf_t* _input) -> std::tuple<bool, std::string> {
if (!_input) {
Expand Down Expand Up @@ -251,7 +249,8 @@ namespace

auto& rei = get_rei(_effect_handler);
for (auto&& op : operations) {
const auto err_code = check_operation_for_violations(op.at("attribute").get_ref<const std::string&>(), rei);
const auto err_code =
check_operation_for_violations(op.at("attribute").get_ref<const std::string&>(), rei);
if (!err_code.ok()) {
return err_code;
}
Expand All @@ -260,7 +259,9 @@ namespace
return CODE(RULE_ENGINE_CONTINUE);
}
catch (const json::exception& e) {
log_re::error({{"log_message", "Failed to parse input into JSON"}, {"error_message", e.what()}, {"rule_engine_plugin", "metadata_guard"}});
log_re::error({{"log_message", "Failed to parse input into JSON"},
{"error_message", e.what()},
{"rule_engine_plugin", "metadata_guard"}});
}
catch (const std::exception& e) {
log_re::error({{"log_message", e.what()}, {"rule_engine_plugin", "metadata_guard"}});
Expand All @@ -275,8 +276,9 @@ namespace
{
static const std::unordered_map<std::string,
std::function<irods::error(std::list<boost::any>&, irods::callback)>>
lookup_table{{"pep_api_mod_avu_metadata_pre", handle_pep_api_mod_avu_metadata_pre},
{"pep_api_atomic_apply_metadata_operations_pre", handle_pep_api_atomic_apply_metadata_operations_pre}};
lookup_table{
{"pep_api_mod_avu_metadata_pre", handle_pep_api_mod_avu_metadata_pre},
{"pep_api_atomic_apply_metadata_operations_pre", handle_pep_api_atomic_apply_metadata_operations_pre}};

static const auto rule_iterator = lookup_table.find(_rule_name);

Expand Down

0 comments on commit dcdab03

Please sign in to comment.