Skip to content

Commit

Permalink
YDA-5282: lift embargo metadata already removed during publication up…
Browse files Browse the repository at this point in the history
…date
  • Loading branch information
lwesterhof committed Sep 25, 2023
1 parent 56641f4 commit 9de77ef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 31 deletions.
23 changes: 6 additions & 17 deletions publication.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
24 changes: 10 additions & 14 deletions tools/lift-embargos.r
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9de77ef

Please sign in to comment.