@@ -281,13 +281,12 @@ def _query_target_entity(self, entity_id):
281281 dict
282282 A dictionary containing all the properties the target entity.
283283 '''
284- def _get_entity_by_id_for_auth_level (self , entity_id : Annotated [ str , 32 ] , valid_user_token :Annotated [str , 32 ]
285- , user_info :dict ) -> dict :
284+ def _get_expanded_entity_for_auth_level (self , entity_dict : dict , valid_user_token :Annotated [str , 32 ]
285+ , user_info :dict ) -> dict :
286286
287287 # Use the internal token to query the target entity to assure it is returned. This way public
288288 # entities can be accessed even if valid_user_token is None.
289289 internal_token = self .authHelper .getProcessSecret ()
290- entity_dict = self ._query_target_entity (entity_id = entity_id )
291290 normalized_entity_type = entity_dict ['entity_type' ]
292291
293292 # Get the generated complete entity result from cache if exists
@@ -308,7 +307,7 @@ def _get_entity_by_id_for_auth_level(self, entity_id:Annotated[str, 32], valid_u
308307 # For non-public documents, reject the request if the user is not authorized
309308 if not public_entity :
310309 if valid_user_token is None :
311- raise entityEx .EntityForbiddenException (f"{ normalized_entity_type } for { entity_id } is not"
310+ raise entityEx .EntityForbiddenException (f"{ normalized_entity_type } for { entity_dict [ 'uuid' ] } is not"
312311 f" accessible without presenting a token." )
313312 if not user_authorized :
314313 raise entityEx .EntityForbiddenException (f"The requested { normalized_entity_type } has non-public data."
@@ -544,14 +543,18 @@ def get_expanded_dataset_metadata(self, dataset_id:Annotated[str, 32], valid_use
544543 , user_info :dict ) -> dict :
545544 # Retrieve the metadata dictionary for the Dataset, which will be expanded later to hold entries for the
546545 # associated data.
547- expanded_dataset_dict = self ._get_entity_by_id_for_auth_level (entity_id = dataset_id
548- , valid_user_token = valid_user_token
549- , user_info = user_info )
546+ dataset_dict = self ._query_target_entity (entity_id = dataset_id )
547+
550548 # Confirm the dataset_id passed in is for a Dataset entity.
551- if expanded_dataset_dict ['entity_type' ] not in ['Dataset' ,'Publication' ]:
552- raise entityEx .EntityBadRequestException ( f"Only Dataset provenance metadata can be retrieved."
553- f" An entity of type '{ expanded_dataset_dict ['entity_type' ]} '"
554- f" for uuid={ expanded_dataset_dict ['uuid' ]} is not supported." )
549+ if not self .schemaMgr .entity_type_instanceof ( entity_type = dataset_dict ['entity_type' ]
550+ , entity_class = 'Dataset' ):
551+ raise entityEx .EntityBadRequestException (f"Only Dataset provenance metadata can be retrieved."
552+ f" An entity of type '{ dataset_dict ['entity_type' ]} '"
553+ f" for uuid={ dataset_dict ['uuid' ]} is not supported." )
554+
555+ expanded_dataset_dict = self ._get_expanded_entity_for_auth_level ( entity_dict = dataset_dict
556+ , valid_user_token = valid_user_token
557+ , user_info = user_info )
555558
556559 # Determine if the entity is publicly visible base on its data, only.
557560 # To verify if a Collection is public, it is necessary to have its Datasets, which
0 commit comments