Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public Study updateStudyFromRegistration(
convertConsentGroupToDatasetProperties(cg));
DatasetServiceDAO.DatasetUpdate update =
createDatasetUpdate(
cg.getDatasetId(), user, datasetUpdate, files, uploadedFileCache);
cg.getDatasetId(), user, datasetUpdate, files, uploadedFileCache, idx);
datasetUpdates.add(update);
} catch (Exception e) {
logException(e);
Expand Down Expand Up @@ -267,7 +267,7 @@ public Dataset updateDataset(

try {
DatasetServiceDAO.DatasetUpdate datasetUpdates =
createDatasetUpdate(datasetId, user, update, files, uploadedFileCache);
createDatasetUpdate(datasetId, user, update, files, uploadedFileCache, 0);

// Update or create the objects in the database
datasetServiceDAO.updateDataset(datasetUpdates);
Expand Down Expand Up @@ -324,13 +324,14 @@ private DatasetServiceDAO.DatasetUpdate createDatasetUpdate(
User user,
DatasetUpdate datasetUpdate,
Map<String, FormDataBodyPart> files,
Map<String, BlobId> uploadedFileCache)
Map<String, BlobId> uploadedFileCache,
int idx)
throws IOException {

List<DatasetProperty> props = datasetUpdate.getDatasetProperties();

List<FileStorageObject> fileStorageObjects =
uploadFilesForDatasetUpdate(files, uploadedFileCache, user);
uploadFilesForDatasetUpdate(files, uploadedFileCache, user, idx);

return new DatasetServiceDAO.DatasetUpdate(
datasetId,
Expand Down Expand Up @@ -407,17 +408,21 @@ private List<FileStorageObject> uploadFilesForDataset(
}

private List<FileStorageObject> uploadFilesForDatasetUpdate(
Map<String, FormDataBodyPart> files, Map<String, BlobId> uploadedFileCache, User user)
Map<String, FormDataBodyPart> files,
Map<String, BlobId> uploadedFileCache,
User user,
int idx)
throws IOException {
List<FileStorageObject> updateDatasetFSOs = new ArrayList<>();

if (files.containsKey(String.format(NIH_INSTITUTIONAL_CERTIFICATION_NAME, 0))) {
Copy link
Contributor Author

@otchet-broad otchet-broad Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the core of the bug. When multiple datasets are updated, we can have multiple files submitted. Assuming the files key was always consentGroups[**0**].nihInstitutionalCertificationFile is incorrect. The update payload might be just a change for consentGroup[5], or a case where multiple consentGroup entries are updated at the same time.

Given this bug I've made https://broadworkbench.atlassian.net/browse/DT-2759

String fileKey = String.format(NIH_INSTITUTIONAL_CERTIFICATION_NAME, idx);
FormDataBodyPart fileToUpdate = files.get(fileKey);
if (fileToUpdate != null) {
updateDatasetFSOs.add(
uploadFile(
files,
uploadedFileCache,
user,
String.format(NIH_INSTITUTIONAL_CERTIFICATION_NAME, 0),
fileKey,
FileCategory.NIH_INSTITUTIONAL_CERTIFICATION));
}

Expand All @@ -440,8 +445,8 @@ private List<FileStorageObject> uploadFilesForStudy(
Map<String, FormDataBodyPart> files, Map<String, BlobId> uploadedFileCache, User user)
throws IOException {
List<FileStorageObject> studyFSOs = new ArrayList<>();

if (files.containsKey(ALTERNATIVE_DATA_SHARING_PLAN_NAME)) {
FormDataBodyPart alternateSharingPlanFile = files.get(ALTERNATIVE_DATA_SHARING_PLAN_NAME);
if (alternateSharingPlanFile != null) {
studyFSOs.add(
uploadFile(
files,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public Study updateStudy(
studyUpdate.userId,
datasetUpdate.dacId,
datasetUpdate.props,
studyUpdate.files,
datasetUpdate.files,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing the studyUpdate files into the dataset updates (and inserts ~L271) was also problematic. The files would be uploaded to GCS but the FSOs wouldn't be recorded.

false);
}
for (DatasetServiceDAO.DatasetInsert insert : datasetInserts) {
Expand All @@ -268,7 +268,7 @@ public Study updateStudy(
insert.dataUse,
studyUpdate.userId,
insert.props,
studyUpdate.files);
insert.files);
}
handle.commit();
});
Expand Down
Loading
Loading