Skip to content

Commit

Permalink
Made sure the "last export" time stamp does not get updated unless th…
Browse files Browse the repository at this point in the history
…e export

has succeeded. (#8484)
  • Loading branch information
landreev committed Jun 7, 2022
1 parent 365e7be commit a98074a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,30 +256,23 @@ public boolean onSuccess(CommandContext ctxt, Object r) {
}
}

exportMetadata(dataset);

ctxt.datasets().updateLastExportTimeStamp(dataset.getId());

return retVal;
}

/**
* Attempting to run metadata export, for all the formats for which we have
* metadata Exporters.
*/
private void exportMetadata(Dataset dataset) {

// Metadata export:

try {
ExportService instance = ExportService.getInstance();
instance.exportAllFormats(dataset);

ctxt.datasets().updateLastExportTimeStamp(dataset.getId());
} catch (Exception ex) {
// Something went wrong!
// Just like with indexing, a failure to export is not a fatal
// condition. We'll just log the error as a warning and keep
// going:
logger.log(Level.WARNING, "Dataset publication finalization: exception while exporting:{0}", ex.getMessage());
}
logger.warning("Finalization: exception caught while exporting: "+ex.getMessage());
// ... but it is important to only update the export time stamp if the
// export was indeed successful.
}

return retVal;
}

/**
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/edu/harvard/iq/dataverse/export/ExportService.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,16 @@ public void exportAllFormats(Dataset dataset) throws ExportException {
cacheExport(releasedVersion, formatName, datasetAsJson, e);

}
// Finally, if we have been able to successfully export in all available
// formats, we'll increment the "last exported" time stamp:
dataset.setLastExportTime(new Timestamp(new Date().getTime()));

} catch (ServiceConfigurationError serviceError) {
throw new ExportException("Service configuration error during export. " + serviceError.getMessage());
} catch (Exception e) {
e.printStackTrace();
logger.warning(e.getMessage());
} catch (RuntimeException e) {
//e.printStackTrace();
throw new ExportException("Unknown runtime exception exporting metadata. " + (e.getMessage() == null ? "" : e.getMessage()));
}
// Finally, if we have been able to successfully export in all available
// formats, we'll increment the "last exported" time stamp:

dataset.setLastExportTime(new Timestamp(new Date().getTime()));

}

Expand Down

0 comments on commit a98074a

Please sign in to comment.