Skip to content

Commit fb7d153

Browse files
committed
update api curate archiving to also use obsolete
1 parent caf85cd commit fb7d153

3 files changed

Lines changed: 35 additions & 22 deletions

File tree

src/main/java/edu/harvard/iq/dataverse/DatasetPage.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,10 +3032,7 @@ public String updateCurrentVersion() {
30323032
}
30333033
} else if(status.equals(DatasetVersion.ARCHIVAL_STATUS_SUCCESS)) {
30343034
//Not automatically replacing the old archival copy as creating it is expensive
3035-
JsonObject archivalLocation = JsonUtil.getJsonObject(updateVersion.getArchivalCopyLocation());
3036-
JsonObjectBuilder job = Json.createObjectBuilder(archivalLocation);
3037-
job.add(DatasetVersion.ARCHIVAL_STATUS,DatasetVersion.ARCHIVAL_STATUS_OBSOLETE);
3038-
updateVersion.setArchivalCopyLocation(JsonUtil.prettyPrint(job.build()));
3035+
updateVersion.setArchivalStatus(DatasetVersion.ARCHIVAL_STATUS_OBSOLETE);
30393036
datasetVersionService.persistArchivalCopyLocation(updateVersion);
30403037
datasetVersionService.merge(updateVersion);
30413038
}

src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,14 @@ public void setArchivalCopyLocation(String location) {
414414
this.archivalCopyLocation = location;
415415
populateArchivalStatus(true);
416416
}
417+
418+
public void setArchivalStatus(String status) {
419+
populateArchivalStatus(false);
420+
JsonObjectBuilder job = Json.createObjectBuilder(archivalStatus);
421+
job.add(DatasetVersion.ARCHIVAL_STATUS, status);
422+
archivalStatus = job.build();
423+
archivalCopyLocation = JsonUtil.prettyPrint(archivalStatus);
424+
}
417425

418426
public String getDeaccessionLink() {
419427
return deaccessionLink;

src/main/java/edu/harvard/iq/dataverse/api/Datasets.java

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,24 +1273,32 @@ public Response publishDataset(@Context ContainerRequestContext crc, @PathParam(
12731273
DatasetVersion updateVersion = ds.getLatestVersion();
12741274
AbstractSubmitToArchiveCommand archiveCommand = ArchiverUtil.createSubmitToArchiveCommand(className, createDataverseRequest(user), updateVersion);
12751275
if (archiveCommand != null) {
1276-
// Delete the record of any existing copy since it is now out of date/incorrect
1277-
dv.setArcivalCopyLocation(null);
1278-
datasetVersionSvc.persistArchivalCopyLocation(updateVersion);
1279-
/*
1280-
* Then try to generate and submit an archival copy. Note that running this
1281-
* command within the CuratePublishedDatasetVersionCommand was causing an error:
1282-
* "The attribute [id] of class
1283-
* [edu.harvard.iq.dataverse.DatasetFieldCompoundValue] is mapped to a primary
1284-
* key column in the database. Updates are not allowed." To avoid that, and to
1285-
* simplify reporting back to the GUI whether this optional step succeeded, I've
1286-
* pulled this out as a separate submit().
1287-
*/
1288-
try {
1289-
commandEngine.submitAsync(archiveCommand);
1290-
successMsg = BundleUtil.getStringFromBundle("datasetversion.archive.inprogress");
1291-
} catch (CommandException ex) {
1292-
successMsg = BundleUtil.getStringFromBundle("datasetversion.update.archive.failure") + " - " + ex.toString();
1293-
logger.severe(ex.getMessage());
1276+
String status = updateVersion.getArchivalCopyLocationStatus();
1277+
if((status==null) || status.equals(DatasetVersion.ARCHIVAL_STATUS_FAILURE)){
1278+
// Otherwise, delete the record of any existing copy since it is now out of
1279+
// date/incorrect
1280+
updateVersion.setArchivalCopyLocation(null);
1281+
datasetVersionSvc.persistArchivalCopyLocation(updateVersion);
1282+
/*
1283+
* Then try to generate and submit an archival copy. Note that running this
1284+
* command within the CuratePublishedDatasetVersionCommand was causing an error:
1285+
* "The attribute [id] of class
1286+
* [edu.harvard.iq.dataverse.DatasetFieldCompoundValue] is mapped to a primary
1287+
* key column in the database. Updates are not allowed." To avoid that, and to
1288+
* simplify reporting back to the GUI whether this optional step succeeded, I've
1289+
* pulled this out as a separate submit().
1290+
*/
1291+
try {
1292+
commandEngine.submitAsync(archiveCommand);
1293+
successMsg = BundleUtil.getStringFromBundle("datasetversion.archive.inprogress");
1294+
} catch (CommandException ex) {
1295+
successMsg = BundleUtil.getStringFromBundle("datasetversion.update.archive.failure") + " - " + ex.toString();
1296+
logger.severe(ex.getMessage());
1297+
}
1298+
} else if(status.equals(DatasetVersion.ARCHIVAL_STATUS_SUCCESS)) {
1299+
//Not automatically replacing the old archival copy as creating it is expensive
1300+
updateVersion.setArchivalStatus(DatasetVersion.ARCHIVAL_STATUS_OBSOLETE);
1301+
datasetVersionSvc.persistArchivalCopyLocation(updateVersion);
12941302
}
12951303
}
12961304
} catch (CommandException ex) {

0 commit comments

Comments
 (0)