@@ -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