6666import jakarta .ws .rs .container .ContainerRequestContext ;
6767import jakarta .ws .rs .core .*;
6868import jakarta .ws .rs .core .Response .Status ;
69+ import org .apache .commons .lang .exception .ExceptionUtils ;
6970import org .apache .commons .lang3 .StringUtils ;
7071import org .eclipse .microprofile .openapi .annotations .Operation ;
7172import org .eclipse .microprofile .openapi .annotations .media .Content ;
102103import edu .harvard .iq .dataverse .engine .command .exception .PermissionException ;
103104import edu .harvard .iq .dataverse .dataset .DatasetType ;
104105import edu .harvard .iq .dataverse .dataset .DatasetTypeServiceBean ;
105-
106106import static edu .harvard .iq .dataverse .util .json .JsonPrinter .*;
107107import static edu .harvard .iq .dataverse .util .json .NullSafeJsonBuilder .jsonObjectBuilder ;
108108
@@ -2059,6 +2059,10 @@ public Response createAssignment(@Context ContainerRequestContext crc, RoleAssig
20592059 return ok (
20602060 json (execCommand (new AssignRoleCommand (assignee , theRole , dataset , createDataverseRequest (getRequestUser (crc )), privateUrlToken ))));
20612061 } catch (WrappedResponse ex ) {
2062+ if (ExceptionUtils .getRootCause (ex ).getMessage ().contains ("duplicate key" )) {
2063+ // concurrent update
2064+ return error (Status .CONFLICT , BundleUtil .getStringFromBundle ("datasets.api.grant.role.assignee.has.role.error" ));
2065+ }
20622066 List <String > args = Arrays .asList (ex .getMessage ());
20632067 logger .log (Level .WARNING , BundleUtil .getStringFromBundle ("datasets.api.grant.role.cant.create.assignment.error" , args ));
20642068 return ex .getResponse ();
@@ -2964,7 +2968,7 @@ public Response getCompareVersions(@Context ContainerRequestContext crc, @PathPa
29642968 return wr .getResponse ();
29652969 }
29662970 }
2967-
2971+
29682972 @ GET
29692973 @ AuthRequired
29702974 @ Path ("{id}/versions/compareSummary" )
@@ -3020,7 +3024,7 @@ public Response getCompareVersionsSummary(@Context ContainerRequestContext crc,
30203024 return wr .getResponse ();
30213025 }
30223026 }
3023-
3027+
30243028 private JsonObject getDeaccessionJson (DatasetVersion dv ) {
30253029
30263030 JsonObjectBuilder compositionBuilder = Json .createObjectBuilder ();
@@ -3036,7 +3040,7 @@ private JsonObject getDeaccessionJson(DatasetVersion dv) {
30363040 JsonObject json = Json .createObjectBuilder ()
30373041 .add ("deaccessioned" , compositionBuilder )
30383042 .build ();
3039-
3043+
30403044 return json ;
30413045 }
30423046
@@ -4454,7 +4458,7 @@ public Response monitorGlobusDownload(@Context ContainerRequestContext crc, @Pat
44544458 return badRequest ("Error parsing json body" );
44554459
44564460 }
4457-
4461+
44584462 // Async Call
44594463 globusService .globusDownload (jsonObject , dataset , authUser );
44604464
@@ -4957,7 +4961,7 @@ public Response getDatasetVersionInternalCitation(@Context ContainerRequestConte
49574961 }
49584962 }
49594963
4960- /**
4964+ /**
49614965 * Returns one of the DataCitation.Format types as a raw file download (not wrapped in our ok json)
49624966 * @param crc
49634967 * @param datasetId
@@ -5533,7 +5537,7 @@ public Response addVersionNote(@Context ContainerRequestContext crc, @PathParam(
55335537 @ Path ("{id}/versions/{versionId}/versionNote" )
55345538 public Response deleteVersionNote (@ Context ContainerRequestContext crc , @ PathParam ("id" ) String datasetId , @ PathParam ("versionId" ) String versionId , @ Context UriInfo uriInfo , @ Context HttpHeaders headers ) throws WrappedResponse {
55355539 if (!FeatureFlags .VERSION_NOTE .enabled ()) {
5536- return notFound (BundleUtil .getStringFromBundle ("datasets.api.addVersionNote.notEnabled" ));
5540+ return notFound (BundleUtil .getStringFromBundle ("datasets.api.addVersionNote.notEnabled" ));
55375541 }
55385542 if (!DS_VERSION_DRAFT .equals (versionId )) {
55395543 AuthenticatedUser user = getRequestAuthenticatedUserOrDie (crc );
0 commit comments