-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb0de4e
commit dcdab03
Showing
1 changed file
with
15 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
|
@@ -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.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
alanking
Contributor
|
||
return user_is_administrator(*rei.rsComm); | ||
} | ||
|
||
|
@@ -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)); | ||
|
@@ -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) { | ||
|
@@ -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; | ||
} | ||
|
@@ -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"}}); | ||
|
@@ -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); | ||
|
||
|
the
return CODE(RULE_ENGINE_CONTINUE
is gone... just making sure this was intentional.