From 9de77efd413ede613a5fd526787a41333c8bd91c Mon Sep 17 00:00:00 2001 From: Lazlo Westerhof Date: Mon, 25 Sep 2023 08:57:55 +0200 Subject: [PATCH] YDA-5282: lift embargo metadata already removed during publication update --- publication.py | 23 ++++++----------------- tools/lift-embargos.r | 24 ++++++++++-------------- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/publication.py b/publication.py index 7cd18aaed..ff5e2201c 100644 --- a/publication.py +++ b/publication.py @@ -1542,16 +1542,9 @@ def get_all_versions(ctx, path, doi): @rule.make() def rule_lift_embargos_on_data_access(ctx): - """ - PURPOSE: Find vault packages that have a data access embargo that can be lifted as the embargo expires. - - If lift_embargo_date < now: - - new landing page (add access link) - - secure copy new landing page to server - - set acls + """Find vault packages that have a data access embargo that can be lifted as the embargo expires. - If all went well => remove lift_embargo_date indication - If something went wrong leave lift_embargo_date so it will be dealt with again the next time around + If lift_embargo_date <= now, update publication. :param ctx: Combined type of a callback and rei struct @@ -1569,18 +1562,14 @@ def rule_lift_embargos_on_data_access(ctx): "COLL_NAME, META_COLL_ATTR_VALUE", "COLL_NAME like '" + "/{}/home/vault-%".format(zone) + "'" " AND META_COLL_ATTR_NAME = '" + constants.UUORGMETADATAPREFIX + 'lift_embargo_date' + "'" - " AND META_COLL_ATTR_VALUE > '{}'".format(datetime.now().strftime('%Y-%m-%d')), + " AND META_COLL_ATTR_VALUE <= '{}'".format(datetime.now().strftime('%Y-%m-%d')), genquery.AS_LIST, ctx ) for row in iter: vault_package = row[0] - log.write(ctx, "Lift embargo for package: " + vault_package) + log.write(ctx, "Lift embargo for vault package: " + vault_package) set_update_publication_state(ctx, vault_package) - publication_status = process_publication(ctx, vault_package) + process_publication(ctx, vault_package) - # If all went well remove the lift embargo attribute so it will not be selected again the next time around. - if publication_status == 'OK': - # Only remove when embargo was lifted successfully. - # Not removing will ensure the entire process is repeated again next time around - avu.rmw_from_coll(ctx, vault_package, constants.UUORGMETADATAPREFIX + 'lift_embargo_date', '%') + return 'OK' diff --git a/tools/lift-embargos.r b/tools/lift-embargos.r index 94f6d15c8..7f121d893 100644 --- a/tools/lift-embargos.r +++ b/tools/lift-embargos.r @@ -1,20 +1,16 @@ -# Lift embargo on data access when embargo date is passed +#!/usr/bin/irule -r irods_rule_engine_plugin-irods_rule_language-instance -F +# +# Lift embargo on data access when embargo date is passed. run { - uuGetUserType("$userNameClient#$rodsZoneClient", *usertype); + uuGetUserType("$userNameClient#$rodsZoneClient", *usertype); - if (*usertype != "rodsadmin") { - failmsg(-1, "This script needs to be run by a rodsadmin"); - } - - # Retrieve current timestamp. - msiGetIcatTime(*timestamp, "human"); - writeLine('stdout', '[' ++ *timestamp ++ '] Start finding data access under embargo that must be lifted'); - - *result = rule_lift_embargos_on_data_access(); - - writeLine('stdout', 'Status: Finished finding of data under embargo that must be lifted'); - writeLine('stdout', *result); + if (*usertype != "rodsadmin") { + failmsg(-1, "This script needs to be run by a rodsadmin"); + } + writeLine('stdout', 'Start finding vault packages under embargo that can be lifted'); + *result = rule_lift_embargos_on_data_access(); + writeLine('stdout', 'Finished finding vault packages under embargo that can be lifted with status *result'); } input null output ruleExecOut