Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
Restored nl.knaw.dans.ingest.core.service.DepositIngestTask#getDoi. F…
Browse files Browse the repository at this point in the history
…or SWORD-datasets we must always use dansSwordToken when looking up the target of an update-deposit,

both in migration as well when processing SWORD deposits. For the migration of non-SWORD datasets this will not work. There we must use dansBagId. This will only work
for two version-datasets, because it is not possible to find datasets by metadata values from earlier versions.
  • Loading branch information
janvanmansum committed Mar 15, 2024
1 parent b85af12 commit 7223571
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,11 @@ public OffsetDateTime getCreatedInstant() {
}

String resolveDoi(Deposit deposit) throws IOException, DataverseException {
var items = datasetService.searchDatasets("dansSwordToken", deposit.getVaultMetadata().getSwordToken());
return getDoi("dansSwordToken", deposit.getVaultMetadata().getSwordToken());
}

String getDoi(String key, String value) throws IOException, DataverseException {
var items = datasetService.searchDatasets(key, value);

if (items.size() != 1) {
throw new FailedDepositException(deposit, String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,17 @@ void validateDeposit() {
);
}
}

@Override
String resolveDoi(Deposit deposit) throws IOException, DataverseException {
if (deposit.getVaultMetadata().getSwordToken() != null) {
// Migration of SWORD datasets
return getDoi("dansSwordToken", deposit.getVaultMetadata().getSwordToken());
} else {
// Migration of other datasets. This will only work if there are two versions, because search only works for the latest version of a dataset,
// so dansBagId in earlier versions will not be found.
return getDoi("dansBagId", deposit.getIsVersionOf());
}
}
}

0 comments on commit 7223571

Please sign in to comment.