Skip to content

Commit

Permalink
added an upfront locks check to the /addGlobusFiles api #10623
Browse files Browse the repository at this point in the history
  • Loading branch information
landreev committed Aug 23, 2024
1 parent d223a8f commit 0ca5e62
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/api/Datasets.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
import java.util.stream.Collectors;

import static edu.harvard.iq.dataverse.api.ApiConstants.*;
import edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException;
import static edu.harvard.iq.dataverse.util.json.JsonPrinter.*;
import static edu.harvard.iq.dataverse.util.json.NullSafeJsonBuilder.jsonObjectBuilder;
import static jakarta.ws.rs.core.Response.Status.BAD_REQUEST;
Expand Down Expand Up @@ -4045,7 +4046,16 @@ public Response addGlobusFilesToDataset(@Context ContainerRequestContext crc,
return badRequest(BundleUtil.getStringFromBundle("datasets.api.globusuploaddisabled"));
}

// @todo check if the dataset is already locked!
// Check if the dataset is already locked
// We are reusing the code and logic used by various command to determine
// if there are any locks on the dataset that would prevent the current
// users from modifying it:
try {
DataverseRequest dataverseRequest = createDataverseRequest(authUser);
permissionService.checkEditDatasetLock(dataset, dataverseRequest, new UpdateDatasetVersionCommand(dataset, dataverseRequest));
} catch (IllegalCommandException icex) {
return error(Response.Status.FORBIDDEN, "Dataset " + datasetId + " is locked: " + icex.getLocalizedMessage());
}

JsonObject jsonObject = null;
try {
Expand Down

0 comments on commit 0ca5e62

Please sign in to comment.