@@ -298,8 +298,9 @@ def halt_DOI_if_unpublished_dataset(property_key, normalized_entity_type, reques
298298 # simply get the existing, distinct 'data_access_level' setting for all the Datasets in the Collection
299299 distinct_dataset_statuses = schema_neo4j_queries .get_collection_datasets_statuses (neo4j_driver_instance
300300 ,existing_data_dict ['uuid' ])
301- if len ( distinct_dataset_statuses ) != 1 or \
302- distinct_dataset_statuses [0 ].lower () != SchemaConstants .DATASET_STATUS_PUBLISHED :
301+ PUBLIC_STATUSES = {SchemaConstants .DATASET_STATUS_PUBLISHED , 'retracted' }
302+
303+ if not all (status .lower () in PUBLIC_STATUSES for status in distinct_dataset_statuses ):
303304 raise ValueError (f"Unable to modify existing { existing_data_dict ['entity_type' ]} "
304305 f" { existing_data_dict ['uuid' ]} for DOI since it contains unpublished Datasets." )
305306
@@ -416,6 +417,7 @@ def validate_dataset_status_value(property_key, normalized_entity_type, request,
416417 accepted_status_values = [
417418 'new' , 'processing' , 'published' , 'qa' , 'error' , 'hold' , 'invalid' , 'submitted' , 'incomplete' , 'approval'
418419 ]
420+ # Retracted intentionally omitted. Status will be set to retracted only on a manual basis
419421 new_status = new_data_dict [property_key ].lower ()
420422
421423 if new_status not in accepted_status_values :
@@ -426,7 +428,7 @@ def validate_dataset_status_value(property_key, normalized_entity_type, request,
426428
427429 # If status == 'Published' already in Neo4j, then fail for any changes at all
428430 # Because once published, the dataset should be read-only
429- if existing_data_dict ['status' ].lower () == SchemaConstants .DATASET_STATUS_PUBLISHED :
431+ if existing_data_dict ['status' ].lower () in [ SchemaConstants .DATASET_STATUS_PUBLISHED , 'retracted' ] :
430432 raise ValueError (f"The status of this { normalized_entity_type } is already 'Published', status change is not allowed" )
431433
432434 # HTTP header names are case-insensitive
@@ -480,6 +482,7 @@ def validate_status_changed(property_key, normalized_entity_type, request, exist
480482 The json data in request body, already after the regular validations
481483"""
482484def validate_if_retraction_permitted (property_key , normalized_entity_type , request , existing_data_dict , new_data_dict ):
485+ # This validator is currently unused. Keeping it in case we decide we want an api endpoint for retraction at some point.
483486 if 'status' not in existing_data_dict :
484487 raise KeyError ("Missing 'status' key in 'existing_data_dict' during calling 'validate_if_retraction_permitted()' validator method." )
485488
@@ -506,27 +509,6 @@ def validate_if_retraction_permitted(property_key, normalized_entity_type, reque
506509 raise ValueError ("Permission denied, retraction is not allowed" )
507510
508511
509- """
510- Validate the sub_status field is also provided when Dataset.retraction_reason is provided on update via PUT
511-
512- Parameters
513- ----------
514- property_key : str
515- The target property key
516- normalized_type : str
517- Submission
518- request: Flask request object
519- The instance of Flask request passed in from application request
520- existing_data_dict : dict
521- A dictionary that contains all existing entity properties
522- new_data_dict : dict
523- The json data in request body, already after the regular validations
524- """
525- def validate_sub_status_provided (property_key , normalized_entity_type , request , existing_data_dict , new_data_dict ):
526- if 'sub_status' not in new_data_dict :
527- raise ValueError ("Missing sub_status field when retraction_reason is provided" )
528-
529-
530512"""
531513Validate the reaction_reason field is also provided when Dataset.sub_status is provided on update via PUT
532514
@@ -548,31 +530,6 @@ def validate_retraction_reason_provided(property_key, normalized_entity_type, re
548530 raise ValueError ("Missing retraction_reason field when sub_status is provided" )
549531
550532
551- """
552- Validate the provided value of Dataset.sub_status on update via PUT
553-
554- Parameters
555- ----------
556- property_key : str
557- The target property key
558- normalized_type : str
559- Submission
560- request: Flask request object
561- The instance of Flask request passed in from application request
562- existing_data_dict : dict
563- A dictionary that contains all existing entity properties
564- new_data_dict : dict
565- The json data in request body, already after the regular validations
566- """
567- def validate_retracted_dataset_sub_status_value (property_key , normalized_entity_type , request , existing_data_dict , new_data_dict ):
568- # Use lowercase for comparison
569- accepted_sub_status_values = ['retracted' ]
570- sub_status = new_data_dict [property_key ].lower ()
571-
572- if sub_status not in accepted_sub_status_values :
573- raise ValueError ("Invalid sub_status value of the Dataset to be retracted" )
574-
575-
576533"""
577534Validate the provided value of Upload.status on update via PUT
578535
@@ -1019,7 +976,7 @@ def _validate_application_header(applications_allowed, request_headers):
1019976def _is_entity_locked_against_update (existing_entity_dict ):
1020977 entity_type = existing_entity_dict ['entity_type' ]
1021978 if entity_type in ['Publication' ,'Dataset' ]:
1022- if 'status' in existing_entity_dict and existing_entity_dict ['status' ] == 'Published' :
979+ if 'status' in existing_entity_dict and existing_entity_dict ['status' ] in [ 'Published' , 'Retracted' ] :
1023980 raise schema_errors .LockedEntityUpdateException (f"Permission denied to change a published/public { entity_type } ." )
1024981 elif entity_type in ['Donor' ,'Sample' ]:
1025982 if 'data_access_level' in existing_entity_dict and existing_entity_dict ['data_access_level' ] == 'public' :
0 commit comments