Skip to content

Commit

Permalink
Handle null modify date
Browse files Browse the repository at this point in the history
  • Loading branch information
qqmyers committed Oct 23, 2024
1 parent b822d99 commit 752a8dc
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import edu.harvard.iq.dataverse.DatasetLock;
import edu.harvard.iq.dataverse.DatasetVersion;
import edu.harvard.iq.dataverse.DatasetVersionDifference;
import edu.harvard.iq.dataverse.DatasetVersionModifiedDate;
import edu.harvard.iq.dataverse.FileMetadata;
import edu.harvard.iq.dataverse.authorization.Permission;
import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser;
Expand Down Expand Up @@ -127,8 +128,12 @@ public Dataset execute(CommandContext ctxt) throws CommandException {
logger.info("difference done at: " + (System.currentTimeMillis()-startTime));
//Will throw an IllegalCommandException if a system metadatablock is changed and the appropriate key is not supplied.
checkSystemMetadataKeyIfNeeded(dvDifference);

editVersion.setModifiedDate(ctxt.em().merge(editVersion.getModifiedDate()));
DatasetVersionModifiedDate mDate = editVersion.getModifiedDate();
if (mDate == null) {
mDate = new DatasetVersionModifiedDate();
}
mDate = ctxt.em().merge(mDate);
editVersion.setModifiedDate(mDate);
editVersion.setLastUpdateTime(getTimestamp());

registerExternalVocabValuesIfAny(ctxt, editVersion);
Expand All @@ -150,7 +155,7 @@ public Dataset execute(CommandContext ctxt) throws CommandException {

DatasetFieldUtil.tidyUpFields(editVersion.getDatasetFields(), true);
logger.info("locked and fields validated at: " + (System.currentTimeMillis()-startTime));
// Merge the new version into out JPA context, if needed.
// Merge the new version into our JPA context, if needed.
if (editVersion.getId() == null || editVersion.getId() == 0L) {
ctxt.em().persist(editVersion);
} else {
Expand Down

0 comments on commit 752a8dc

Please sign in to comment.