2323import provenance
2424import schema
2525import schema_transformations
26+ import vault
2627from util import *
2728
2829
@@ -45,7 +46,7 @@ def execute_transformation(ctx: rule.Context, metadata_path: str, transform: Cal
4546 new_path = '{}/yoda-metadata[{}].json' .format (coll , str (int (time .time ())))
4647 # print('TRANSFORMING in vault <{}> -> <{}>'.format(metadata_path, new_path))
4748 jsonutil .write (ctx , new_path , metadata )
48- copy_acls_from_parent (ctx , new_path , "default" )
49+ vault . copy_acls_from_parent (ctx , new_path , "default" )
4950 provenance .log_action (ctx , "system" , coll , "updated metadata schema" )
5051 log .write (ctx , "Transformed %s" % (new_path ))
5152 else :
@@ -163,44 +164,6 @@ def rule_get_transformation_info(ctx: rule.Context, json_path: str) -> Tuple[str
163164 return output
164165
165166
166- def copy_acls_from_parent (ctx : rule .Context , path : str , recursive_flag : str ) -> None :
167- """
168- When inheritance is missing we need to copy ACLs when introducing new data in vault package.
169-
170- :param ctx: Combined type of a ctx and rei struct
171- :param path: Path of object that needs the permissions of parent
172- :param recursive_flag: Either "default" for no recursion or "recursive"
173- """
174- parent = os .path .dirname (path )
175-
176- iter = genquery .row_iterator (
177- "COLL_ACCESS_NAME, COLL_ACCESS_USER_ID" ,
178- "COLL_NAME = '" + parent + "'" ,
179- genquery .AS_LIST , ctx
180- )
181-
182- for row in iter :
183- access_name = row [0 ]
184- user_id = int (row [1 ])
185-
186- user_name = user .name_from_id (ctx , user_id )
187-
188- # iRODS keeps ACLs for deleted users in the iCAT database (https://github.com/irods/irods/issues/7778),
189- # so we need to skip ACLs referring to users that no longer exist.
190- if user_name == "" :
191- continue
192-
193- if access_name == "own" :
194- log .write (ctx , "iiCopyACLsFromParent: granting own to <" + user_name + "> on <" + path + "> with recursiveFlag <" + recursive_flag + ">" )
195- msi .set_acl (ctx , recursive_flag , "own" , user_name , path )
196- elif access_name == "read_object" :
197- log .write (ctx , "iiCopyACLsFromParent: granting read to <" + user_name + "> on <" + path + "> with recursiveFlag <" + recursive_flag + ">" )
198- msi .set_acl (ctx , recursive_flag , "read" , user_name , path )
199- elif access_name == "modify_object" :
200- log .write (ctx , "iiCopyACLsFromParent: granting write to <" + user_name + "> on <" + path + "> with recursiveFlag <" + recursive_flag + ">" )
201- msi .set_acl (ctx , recursive_flag , "write" , user_name , path )
202-
203-
204167@rule .make (inputs = [0 , 1 , 2 , 3 ], outputs = [])
205168def rule_batch_transform_vault_metadata (ctx : rule .Context , coll_id_s : str , batch_s : str , pause_s : str , delay_s : str ) -> None :
206169 """
@@ -328,7 +291,7 @@ def rule_batch_vault_metadata_correct_orcid_format(ctx: rule.Context, coll_id_s:
328291 new_path = '{}/yoda-metadata[{}].json' .format (coll , str (int (time .time ())))
329292 log .write (ctx , 'TRANSFORMING in vault <{}> -> <{}>' .format (metadata_path , new_path ))
330293 jsonutil .write (ctx , new_path , result ['metadata' ])
331- copy_acls_from_parent (ctx , new_path , "default" )
294+ vault . copy_acls_from_parent (ctx , new_path , "default" )
332295 provenance .log_action (ctx , "system" , coll , "updated person identifier metadata" )
333296 log .write (ctx , "Transformed ORCIDs for: %s" % (new_path ))
334297 elif result ['data_changed' ]:
0 commit comments