Source:
public Dataset save(CommandContext ctxt) throws CommandException { Timestamp updateTime = new Timestamp(new Date().getTime()); theDataset.getEditVersion().setLastUpdateTime(updateTime); theDataset.getEditVersion().setInReview(false); theDataset.setModificationTime(updateTime); Dataset savedDataset = ctxt.em().merge(theDataset); ctxt.em().flush(); DatasetVersionUser ddu = ctxt.datasets().getDatasetVersionUser(theDataset.getLatestVersion(), this.getUser()); WorkflowComment workflowComment = new WorkflowComment(new WorkflowAction(theDataset.getEditVersion(), RETURN_TO_AUTHOR), comment, (AuthenticatedUser) this.getUser()); ctxt.datasets().addWorkflowComment(workflowComment); if (ddu != null) { ddu.setLastUpdateDate(updateTime); ctxt.em().merge(ddu); } else { DatasetVersionUser datasetDataverseUser = new DatasetVersionUser(); datasetDataverseUser.setDatasetVersion(savedDataset.getLatestVersion()); datasetDataverseUser.setLastUpdateDate((Timestamp) updateTime); String id = getUser().getIdentifier(); id = id.startsWith("@") ? id.substring(1) : id; AuthenticatedUser au = ctxt.authentication().getAuthenticatedUser(id); datasetDataverseUser.setAuthenticatedUser(au); ctxt.em().merge(datasetDataverseUser); } List<AuthenticatedUser> authUsers = ctxt.permissions().getUsersWithPermissionOn(Permission.PublishDataset, savedDataset); List<AuthenticatedUser> editUsers = ctxt.permissions().getUsersWithPermissionOn(Permission.EditDataset, savedDataset); for (AuthenticatedUser au : authUsers) { editUsers.remove(au); } for (AuthenticatedUser au : editUsers) { ctxt.notifications().sendNotification(au, new Timestamp(new Date().getTime()), UserNotification.Type.RETURNEDDS, savedDataset.getLatestVersion().getId(), comment); } boolean doNormalSolrDocCleanUp = true; Future<String> indexingResult = ctxt.index().indexDataset(savedDataset, doNormalSolrDocCleanUp); return savedDataset; }

Target:
public Dataset save(CommandContext ctxt) throws CommandException { Timestamp updateTime = new Timestamp(new Date().getTime()); theDataset.getEditVersion().setLastUpdateTime(updateTime); theDataset.getEditVersion().setInReview(false); theDataset.setModificationTime(updateTime); Dataset savedDataset = ctxt.em().merge(theDataset); ctxt.em().flush(); DatasetVersionUser ddu = ctxt.datasets().getDatasetVersionUser(theDataset.getLatestVersion(), this.getUser()); WorkflowComment workflowComment = new WorkflowComment(theDataset.getEditVersion(), WorkflowComment.Type.RETURN_TO_AUTHOR, comment, (AuthenticatedUser) this.getUser()); ctxt.datasets().addWorkflowComment(workflowComment); if (ddu != null) { ddu.setLastUpdateDate(updateTime); ctxt.em().merge(ddu); } else { DatasetVersionUser datasetDataverseUser = new DatasetVersionUser(); datasetDataverseUser.setDatasetVersion(savedDataset.getLatestVersion()); datasetDataverseUser.setLastUpdateDate(updateTime); String id = getUser().getIdentifier(); id = id.startsWith("@") ? id.substring(1) : id; AuthenticatedUser au = ctxt.authentication().getAuthenticatedUser(id); datasetDataverseUser.setAuthenticatedUser(au); ctxt.em().merge(datasetDataverseUser); } List<AuthenticatedUser> reviewers = ctxt.permissions().getUsersWithPermissionOn(Permission.PublishDataset, savedDataset); List<AuthenticatedUser> authors = ctxt.permissions().getUsersWithPermissionOn(Permission.EditDataset, savedDataset); for (AuthenticatedUser au : reviewers) { authors.remove(au); } for (AuthenticatedUser au : authors) { ctxt.notifications().sendNotification(au, new Timestamp(new Date().getTime()), UserNotification.Type.RETURNEDDS, savedDataset.getLatestVersion().getId(), comment); } boolean doNormalSolrDocCleanUp = true; Future<String> indexingResult = ctxt.index().indexDataset(savedDataset, doNormalSolrDocCleanUp); return savedDataset; }