Skip to content

Commit

Permalink
better Globus service availability checks #10623
Browse files Browse the repository at this point in the history
  • Loading branch information
landreev committed Aug 21, 2024
1 parent b3f79fe commit 1acae68
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/main/java/edu/harvard/iq/dataverse/api/Datasets.java
Original file line number Diff line number Diff line change
Expand Up @@ -3908,7 +3908,7 @@ public Response requestGlobusUpload(@Context ContainerRequestContext crc, @PathP

if (!systemConfig.isGlobusUpload()) {
return error(Response.Status.SERVICE_UNAVAILABLE,
BundleUtil.getStringFromBundle("datasets.api.globusdownloaddisabled"));
BundleUtil.getStringFromBundle("datasets.api.globusuploaddisabled"));
}

// -------------------------------------
Expand Down Expand Up @@ -4008,11 +4008,6 @@ public Response addGlobusFilesToDataset(@Context ContainerRequestContext crc,

logger.info(" ==== (api addGlobusFilesToDataset) jsonData ====== " + jsonData);

if (!systemConfig.isHTTPUpload()) {
// @todo why isHTTPUpload()? - shouldn't it be checking isGlobusUpload() here?
return error(Response.Status.SERVICE_UNAVAILABLE, BundleUtil.getStringFromBundle("file.api.httpDisabled"));
}

// -------------------------------------
// (1) Get the user from the API key
// -------------------------------------
Expand All @@ -4035,6 +4030,21 @@ public Response addGlobusFilesToDataset(@Context ContainerRequestContext crc,
return wr.getResponse();
}

// Is Globus upload service available?

// ... on this Dataverse instance?
if (!systemConfig.isGlobusUpload()) {
return error(Response.Status.SERVICE_UNAVAILABLE, BundleUtil.getStringFromBundle("file.api.globusUploadDisabled"));
}

// ... and on this specific Dataset?
String storeId = dataset.getEffectiveStorageDriverId();
// acceptsGlobusTransfers should only be true for an S3 or globus store
if (!GlobusAccessibleStore.acceptsGlobusTransfers(storeId)
&& !GlobusAccessibleStore.allowsGlobusReferences(storeId)) {
return badRequest(BundleUtil.getStringFromBundle("datasets.api.globusuploaddisabled"));
}

// @todo check if the dataset is already locked!

JsonObject jsonObject = null;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/propertyFiles/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,7 @@ file.fromWebloaderAfterCreate.tip=An option to upload a folder of files will be
file.fromWebloader=Upload a Folder

file.api.httpDisabled=File upload via HTTP is not available for this installation of Dataverse.
file.api.globusUploadDisabled=File upload via Globus is not available for this installation of Dataverse.
file.api.alreadyHasPackageFile=File upload via HTTP disabled since this dataset already contains a package file.
file.replace.original=Original File
file.editFiles=Edit Files
Expand Down

0 comments on commit 1acae68

Please sign in to comment.