From 0c3522b7a8138f0dce6c29a081b74a72847f2552 Mon Sep 17 00:00:00 2001 From: ricardo Date: Tue, 8 Oct 2019 10:23:03 -0500 Subject: [PATCH 1/3] Changes to send app and email notification to the user when ingest process has finished. --- .../iq/dataverse/FileDownloadServiceBean.java | 2 +- .../harvard/iq/dataverse/MailServiceBean.java | 40 ++++++++++++--- .../iq/dataverse/UserNotification.java | 2 +- .../UserNotificationServiceBean.java | 18 ++++--- .../providers/builtin/DataverseUserPage.java | 4 ++ .../impl/SubmitDatasetForReviewCommand.java | 2 +- .../iq/dataverse/ingest/IngestMessage.java | 13 ++++- .../dataverse/ingest/IngestMessageBean.java | 49 +++++++++++++++---- .../dataverse/ingest/IngestServiceBean.java | 2 +- .../harvard/iq/dataverse/util/MailUtil.java | 2 + src/main/java/propertyFiles/Bundle.properties | 3 ++ src/main/webapp/dataverseuser.xhtml | 7 +++ 12 files changed, 117 insertions(+), 27 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/FileDownloadServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/FileDownloadServiceBean.java index 7ec462f1983..03b999042f0 100644 --- a/src/main/java/edu/harvard/iq/dataverse/FileDownloadServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/FileDownloadServiceBean.java @@ -473,7 +473,7 @@ public boolean requestAccess(Long fileId) { public void sendRequestFileAccessNotification(Dataset dataset, Long fileId, AuthenticatedUser requestor) { permissionService.getUsersWithPermissionOn(Permission.ManageDatasetPermissions, dataset).stream().forEach((au) -> { - userNotificationService.sendNotification(au, new Timestamp(new Date().getTime()), UserNotification.Type.REQUESTFILEACCESS, fileId, null, requestor); + userNotificationService.sendNotification(au, new Timestamp(new Date().getTime()), UserNotification.Type.REQUESTFILEACCESS, fileId, null, requestor, false); }); } diff --git a/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java index 0606a3a87f2..bcea95fd7cf 100644 --- a/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java @@ -114,6 +114,11 @@ public void sendMail(String host, String reply, String to, String subject, Strin private Session session; public boolean sendSystemEmail(String to, String subject, String messageText) { + return sendSystemEmail(to, subject, messageText, false); + } + + public boolean sendSystemEmail(String to, String subject, String messageText, boolean isHtmlContent) { + boolean sent = false; String rootDataverseName = dataverseService.findRootDataverse().getName(); @@ -136,7 +141,12 @@ public boolean sendSystemEmail(String to, String subject, String messageText) { } msg.setRecipients(Message.RecipientType.TO, recipients); msg.setSubject(subject, charset); - msg.setText(body, charset); + if (isHtmlContent) { + msg.setText(body, charset, "html"); + } else { + msg.setText(body, charset); + } + try { Transport.send(msg, recipients); sent = true; @@ -215,11 +225,15 @@ public Boolean sendNotificationEmail(UserNotification notification){ public Boolean sendNotificationEmail(UserNotification notification, String comment) { - return sendNotificationEmail(notification, comment, null); + return sendNotificationEmail(notification, comment, null, false); + } + + public Boolean sendNotificationEmail(UserNotification notification, String comment, boolean isHtmlContent) { + return sendNotificationEmail(notification, comment, null, isHtmlContent); } - - - public Boolean sendNotificationEmail(UserNotification notification, String comment, AuthenticatedUser requestor){ + + + public Boolean sendNotificationEmail(UserNotification notification, String comment, AuthenticatedUser requestor, boolean isHtmlContent){ boolean retval = false; String emailAddress = getUserEmailAddress(notification); @@ -230,7 +244,7 @@ public Boolean sendNotificationEmail(UserNotification notification, String comme String rootDataverseName = dataverseService.findRootDataverse().getName(); String subjectText = MailUtil.getSubjectTextBasedOnNotification(notification, rootDataverseName, objectOfNotification); if (!(messageText.isEmpty() || subjectText.isEmpty())){ - retval = sendSystemEmail(emailAddress, subjectText, messageText); + retval = sendSystemEmail(emailAddress, subjectText, messageText, isHtmlContent); } else { logger.warning("Skipping " + notification.getType() + " notification, because couldn't get valid message"); } @@ -530,6 +544,18 @@ public String getMessageTextBasedOnNotification(UserNotification userNotificatio String message = BundleUtil.getStringFromBundle("notification.email.apiTokenGenerated", Arrays.asList( userNotification.getUser().getFirstName(), userNotification.getUser().getFirstName() )); return message; + + case INGESTCOMPLETED: + dataset = (Dataset) targetObject; + + String ingestedCompletedMessage = messageText + BundleUtil.getStringFromBundle("notification.ingest.completed", Arrays.asList( + systemConfig.getDataverseSiteUrl(), + dataset.getGlobalIdString(), + dataset.getDisplayName(), + comment + )); + + return ingestedCompletedMessage; } return ""; @@ -572,6 +598,8 @@ private Object getObjectOfNotification (UserNotification userNotification){ return versionService.find(userNotification.getObjectId()); case APIGENERATED: return userNotification.getUser(); + case INGESTCOMPLETED: + return datasetService.find(userNotification.getObjectId()); } return null; diff --git a/src/main/java/edu/harvard/iq/dataverse/UserNotification.java b/src/main/java/edu/harvard/iq/dataverse/UserNotification.java index c28927f7cd3..b72473884b2 100644 --- a/src/main/java/edu/harvard/iq/dataverse/UserNotification.java +++ b/src/main/java/edu/harvard/iq/dataverse/UserNotification.java @@ -27,7 +27,7 @@ public class UserNotification implements Serializable { public enum Type { - ASSIGNROLE, REVOKEROLE, CREATEDV, CREATEDS, CREATEACC, MAPLAYERUPDATED, MAPLAYERDELETEFAILED, SUBMITTEDDS, RETURNEDDS, PUBLISHEDDS, REQUESTFILEACCESS, GRANTFILEACCESS, REJECTFILEACCESS, FILESYSTEMIMPORT, CHECKSUMIMPORT, CHECKSUMFAIL, CONFIRMEMAIL, APIGENERATED + ASSIGNROLE, REVOKEROLE, CREATEDV, CREATEDS, CREATEACC, MAPLAYERUPDATED, MAPLAYERDELETEFAILED, SUBMITTEDDS, RETURNEDDS, PUBLISHEDDS, REQUESTFILEACCESS, GRANTFILEACCESS, REJECTFILEACCESS, FILESYSTEMIMPORT, CHECKSUMIMPORT, CHECKSUMFAIL, CONFIRMEMAIL, APIGENERATED, INGESTCOMPLETED }; private static final long serialVersionUID = 1L; diff --git a/src/main/java/edu/harvard/iq/dataverse/UserNotificationServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/UserNotificationServiceBean.java index 6fcdf5069ef..76e79af3049 100644 --- a/src/main/java/edu/harvard/iq/dataverse/UserNotificationServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/UserNotificationServiceBean.java @@ -81,25 +81,29 @@ public UserNotification save(UserNotification userNotification) { public void delete(UserNotification userNotification) { em.remove(em.merge(userNotification)); - } + } public void sendNotification(AuthenticatedUser dataverseUser, Timestamp sendDate, Type type, Long objectId) { sendNotification(dataverseUser, sendDate, type, objectId, ""); } - + public void sendNotification(AuthenticatedUser dataverseUser, Timestamp sendDate, Type type, Long objectId, String comment) { - sendNotification(dataverseUser, sendDate, type, objectId, comment, null); + sendNotification(dataverseUser, sendDate, type, objectId, comment, null, false); } - - public void sendNotification(AuthenticatedUser dataverseUser, Timestamp sendDate, Type type, Long objectId, String comment, AuthenticatedUser requestor) { + + public void sendNotification(AuthenticatedUser dataverseUser, Timestamp sendDate, Type type, Long objectId, String comment, boolean isHtmlContent) { + sendNotification(dataverseUser, sendDate, type, objectId, comment, null, isHtmlContent); + } + + public void sendNotification(AuthenticatedUser dataverseUser, Timestamp sendDate, Type type, Long objectId, String comment, AuthenticatedUser requestor, boolean isHtmlContent) { UserNotification userNotification = new UserNotification(); userNotification.setUser(dataverseUser); userNotification.setSendDate(sendDate); userNotification.setType(type); userNotification.setObjectId(objectId); userNotification.setRequestor(requestor); - - if (mailService.sendNotificationEmail(userNotification, comment, requestor)) { + + if (mailService.sendNotificationEmail(userNotification, comment, requestor, isHtmlContent)) { logger.fine("email was sent"); userNotification.setEmailed(true); save(userNotification); diff --git a/src/main/java/edu/harvard/iq/dataverse/authorization/providers/builtin/DataverseUserPage.java b/src/main/java/edu/harvard/iq/dataverse/authorization/providers/builtin/DataverseUserPage.java index 0b404a446da..eebf79f05c8 100644 --- a/src/main/java/edu/harvard/iq/dataverse/authorization/providers/builtin/DataverseUserPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/authorization/providers/builtin/DataverseUserPage.java @@ -513,6 +513,10 @@ public void displayNotification() { case APIGENERATED: userNotification.setTheObject(userNotification.getUser()); break; + + case INGESTCOMPLETED: + userNotification.setTheObject(datasetService.find(userNotification.getObjectId())); + break; } userNotification.setDisplayAsRead(userNotification.isReadNotification()); diff --git a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SubmitDatasetForReviewCommand.java b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SubmitDatasetForReviewCommand.java index d1ea2aee89b..ad290fe221b 100644 --- a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SubmitDatasetForReviewCommand.java +++ b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SubmitDatasetForReviewCommand.java @@ -61,7 +61,7 @@ public Dataset save(CommandContext ctxt) throws CommandException { List authUsers = ctxt.permissions().getUsersWithPermissionOn(Permission.PublishDataset, savedDataset); for (AuthenticatedUser au : authUsers) { - ctxt.notifications().sendNotification(au, new Timestamp(new Date().getTime()), UserNotification.Type.SUBMITTEDDS, savedDataset.getLatestVersion().getId(), "", requestor); + ctxt.notifications().sendNotification(au, new Timestamp(new Date().getTime()), UserNotification.Type.SUBMITTEDDS, savedDataset.getLatestVersion().getId(), "", requestor, false); } // TODO: What should we do with the indexing result? Print it to the log? diff --git a/src/main/java/edu/harvard/iq/dataverse/ingest/IngestMessage.java b/src/main/java/edu/harvard/iq/dataverse/ingest/IngestMessage.java index f612f07c972..e9923012fad 100644 --- a/src/main/java/edu/harvard/iq/dataverse/ingest/IngestMessage.java +++ b/src/main/java/edu/harvard/iq/dataverse/ingest/IngestMessage.java @@ -44,7 +44,13 @@ public IngestMessage(int messageLevel) { this.messageLevel = messageLevel; datafile_ids = new ArrayList(); } - + + public IngestMessage(int messageLevel, Long authenticatedUserId) { + this.messageLevel = messageLevel; + this.authenticatedUserId = authenticatedUserId; + datafile_ids = new ArrayList(); + } + private int messageLevel = INGEST_MESAGE_LEVEL_INFO; private Long datasetId; @@ -52,6 +58,7 @@ public IngestMessage(int messageLevel) { private String versionNote; private String datasetVersionNumber; private List datafile_ids; + private Long authenticatedUserId; public String getVersionNote() { return versionNote; @@ -112,4 +119,8 @@ public void setFileIds(List file_ids) { public void addFileId(Long file_id) { datafile_ids.add(file_id); } + + public Long getAuthenticatedUserId() { + return authenticatedUserId; + } } diff --git a/src/main/java/edu/harvard/iq/dataverse/ingest/IngestMessageBean.java b/src/main/java/edu/harvard/iq/dataverse/ingest/IngestMessageBean.java index 4412eb0e778..3b65ff624a8 100644 --- a/src/main/java/edu/harvard/iq/dataverse/ingest/IngestMessageBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/ingest/IngestMessageBean.java @@ -20,12 +20,12 @@ package edu.harvard.iq.dataverse.ingest; -import edu.harvard.iq.dataverse.DatasetServiceBean; -import edu.harvard.iq.dataverse.DataFileServiceBean; -import edu.harvard.iq.dataverse.DataFile; -import edu.harvard.iq.dataverse.Dataset; -import edu.harvard.iq.dataverse.DatasetLock; +import edu.harvard.iq.dataverse.*; +import edu.harvard.iq.dataverse.authorization.AuthenticationServiceBean; +import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser; +import java.sql.Timestamp; +import java.time.Instant; import java.util.Iterator; import java.util.logging.Logger; import javax.ejb.ActivationConfigProperty; @@ -50,7 +50,9 @@ public class IngestMessageBean implements MessageListener { private static final Logger logger = Logger.getLogger(IngestMessageBean.class.getCanonicalName()); @EJB DatasetServiceBean datasetService; @EJB DataFileServiceBean datafileService; - @EJB IngestServiceBean ingestService; + @EJB IngestServiceBean ingestService; + @EJB UserNotificationServiceBean userNotificationService; + @EJB AuthenticationServiceBean authenticationServiceBean; public IngestMessageBean() { @@ -60,26 +62,37 @@ public IngestMessageBean() { public void onMessage(Message message) { IngestMessage ingestMessage = null; - Long datafile_id = null; + Long datafile_id = null; + AuthenticatedUser authenticatedUser = null; try { ObjectMessage om = (ObjectMessage) message; ingestMessage = (IngestMessage) om.getObject(); + authenticatedUser = authenticationServiceBean.findByID(ingestMessage.getAuthenticatedUserId()); + Iterator iter = ingestMessage.getFileIds().iterator(); - datafile_id = null; + datafile_id = null; + + StringBuilder sbIngestedFiles = new StringBuilder(); + sbIngestedFiles.append("
    "); while (iter.hasNext()) { datafile_id = (Long) iter.next(); logger.fine("Start ingest job;"); try { + + DataFile datafile = datafileService.find(datafile_id); + sbIngestedFiles.append(String.format("
  • %s
  • ", datafile.getCurrentName())); + if (ingestService.ingestAsTabular(datafile_id)) { //Thread.sleep(10000); logger.fine("Finished ingest job;"); } else { logger.warning("Error occurred during ingest job for file id " + datafile_id + "!"); } + } catch (Exception ex) { //ex.printStackTrace(); // TODO: @@ -92,6 +105,9 @@ public void onMessage(Message message) { logger.fine("looking up datafile for id " + datafile_id); DataFile datafile = datafileService.find(datafile_id); if (datafile != null) { + + sbIngestedFiles.append(String.format("
  • %s (Error)
  • ", datafile.getCurrentName())); + datafile.SetIngestProblem(); IngestReport errorReport = new IngestReport(); errorReport.setFailure(); @@ -117,6 +133,10 @@ public void onMessage(Message message) { } } } + + sbIngestedFiles.append("
"); + + Long objectId = null; // Remove the dataset lock: // (note that the assumption here is that all of the datafiles @@ -125,11 +145,22 @@ public void onMessage(Message message) { DataFile datafile = datafileService.find(datafile_id); if (datafile != null) { Dataset dataset = datafile.getOwner(); + objectId = dataset.getId(); if (dataset != null && dataset.getId() != null) { datasetService.removeDatasetLocks(dataset, DatasetLock.Reason.Ingest); } } - } + } + + userNotificationService.sendNotification( + authenticatedUser, + Timestamp.from(Instant.now()), + UserNotification.Type.INGESTCOMPLETED, + objectId, + sbIngestedFiles.toString(), + true + ); + } catch (JMSException ex) { ex.printStackTrace(); // error in getting object from message; can't send e-mail diff --git a/src/main/java/edu/harvard/iq/dataverse/ingest/IngestServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/ingest/IngestServiceBean.java index ac411d5e6bd..eb1b2b658d5 100644 --- a/src/main/java/edu/harvard/iq/dataverse/ingest/IngestServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/ingest/IngestServiceBean.java @@ -475,7 +475,7 @@ public int compare(DataFile d1, DataFile d2) { } }); - ingestMessage = new IngestMessage(IngestMessage.INGEST_MESAGE_LEVEL_INFO); + ingestMessage = new IngestMessage(IngestMessage.INGEST_MESAGE_LEVEL_INFO, user.getId()); for (int i = 0; i < count; i++) { ingestMessage.addFileId(scheduledFilesArray[i].getId()); } diff --git a/src/main/java/edu/harvard/iq/dataverse/util/MailUtil.java b/src/main/java/edu/harvard/iq/dataverse/util/MailUtil.java index 22d6afbec31..4146c1b55fa 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/MailUtil.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/MailUtil.java @@ -75,6 +75,8 @@ public static String getSubjectTextBasedOnNotification(UserNotification userNoti return BundleUtil.getStringFromBundle("notification.email.verifyEmail.subject", rootDvNameAsList); case APIGENERATED: return BundleUtil.getStringFromBundle("notification.email.apiTokenGenerated.subject", rootDvNameAsList); + case INGESTCOMPLETED: + return BundleUtil.getStringFromBundle("notification.email.ingestcompleted.subject", rootDvNameAsList); } return ""; } diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index ac2bdb9844e..c42b71cc6b0 100755 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -185,6 +185,7 @@ notification.dataset.management.title=Dataset Management - Dataset User Guide notification.wasSubmittedForReview={0} was submitted for review to be published in {1}. Don''t forget to publish it or send it back to the contributor, {2} ({3})\! notification.wasReturnedByReviewer={0} was returned by the curator of {1}. notification.wasPublished={0} was published in {1}. +notification.ingestCompleted=Dataset {1} ingest has finished. notification.worldMap.added={0}, dataset had WorldMap layer data added to it. notification.maplayer.deletefailed=Failed to delete the map layer associated with the restricted file {0} from WorldMap. Please try again, or contact WorldMap and/or Dataverse support. (Dataset: {1}) notification.generic.objectDeleted=The dataverse, dataset, or file for this notification has been deleted. @@ -197,6 +198,7 @@ notification.access.revoked.dataverse=You have been removed from a role in {0}. notification.access.revoked.dataset=You have been removed from a role in {0}. notification.access.revoked.datafile=You have been removed from a role in {0}. notification.checksumfail=One or more files in your upload failed checksum validation for dataset {1}. Please re-run the upload script. If the problem persists, please contact support. +notification.ingest.completed=Dataset {2} ingest process has successfully finished.

Ingested files:{3}
notification.mail.import.filesystem=Dataset {2} ({0}/dataset.xhtml?persistentId={1}) has been successfully uploaded and verified. notification.import.filesystem=Dataset {1} has been successfully uploaded and verified. notification.import.checksum={1}, dataset had file checksums added via a batch job. @@ -633,6 +635,7 @@ notification.email.create.account.subject={0}: Your account has been created notification.email.assign.role.subject={0}: You have been assigned a role notification.email.revoke.role.subject={0}: Your role has been revoked notification.email.verifyEmail.subject={0}: Verify your email address +notification.email.ingestcompleted.subject={0}: Your ingest has finished! notification.email.greeting=Hello, \n # Bundle file editors, please note that "notification.email.welcome" is used in a unit test notification.email.welcome=Welcome to {0}! Get started by adding or finding data. Have questions? Check out the User Guide at {1}/{2}/user or contact {3} at {4} for assistance. diff --git a/src/main/webapp/dataverseuser.xhtml b/src/main/webapp/dataverseuser.xhtml index c9c79fd1d8d..abd64177e88 100644 --- a/src/main/webapp/dataverseuser.xhtml +++ b/src/main/webapp/dataverseuser.xhtml @@ -324,6 +324,13 @@ + + + + + + + From f2b615b58099179d120ecbd825a2fd4993b78531 Mon Sep 17 00:00:00 2001 From: Danny Brooke Date: Fri, 11 Oct 2019 14:28:09 -0400 Subject: [PATCH 2/3] adding line for ingest notification --- doc/sphinx-guides/source/user/account.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/sphinx-guides/source/user/account.rst b/doc/sphinx-guides/source/user/account.rst index eaa86567265..f9180a530c3 100755 --- a/doc/sphinx-guides/source/user/account.rst +++ b/doc/sphinx-guides/source/user/account.rst @@ -158,6 +158,7 @@ You will receive a notification when: - You've created your account - You've created a dataverse or added a dataset - Another Dataverse user has requested access to a restricted file in one of your datasets +- A file in one of your datasets has finished the ingest process Notifications will only be emailed one time even if you haven't read the notification on the Dataverse site. From 857ab975a58a31a867968388feb67f2ea51cb1c0 Mon Sep 17 00:00:00 2001 From: ricardo Date: Mon, 14 Oct 2019 09:55:05 -0500 Subject: [PATCH 3/3] Changes to send app and email notification to the user when ingest process has finished with errors. --- .../edu/harvard/iq/dataverse/MailServiceBean.java | 12 ++++++++++++ .../edu/harvard/iq/dataverse/UserNotification.java | 2 +- .../providers/builtin/DataverseUserPage.java | 1 + .../iq/dataverse/ingest/IngestMessageBean.java | 10 ++++++++-- .../java/edu/harvard/iq/dataverse/util/MailUtil.java | 4 +++- src/main/java/propertyFiles/Bundle.properties | 7 +++++-- src/main/webapp/dataverseuser.xhtml | 7 +++++++ 7 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java index bcea95fd7cf..0397d795798 100644 --- a/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java @@ -556,6 +556,17 @@ public String getMessageTextBasedOnNotification(UserNotification userNotificatio )); return ingestedCompletedMessage; + case INGESTCOMPLETEDWITHERRORS: + dataset = (Dataset) targetObject; + + String ingestedCompletedWithErrorsMessage = messageText + BundleUtil.getStringFromBundle("notification.ingest.completedwitherrors", Arrays.asList( + systemConfig.getDataverseSiteUrl(), + dataset.getGlobalIdString(), + dataset.getDisplayName(), + comment + )); + + return ingestedCompletedWithErrorsMessage; } return ""; @@ -599,6 +610,7 @@ private Object getObjectOfNotification (UserNotification userNotification){ case APIGENERATED: return userNotification.getUser(); case INGESTCOMPLETED: + case INGESTCOMPLETEDWITHERRORS: return datasetService.find(userNotification.getObjectId()); } diff --git a/src/main/java/edu/harvard/iq/dataverse/UserNotification.java b/src/main/java/edu/harvard/iq/dataverse/UserNotification.java index b72473884b2..70b9cacf4e3 100644 --- a/src/main/java/edu/harvard/iq/dataverse/UserNotification.java +++ b/src/main/java/edu/harvard/iq/dataverse/UserNotification.java @@ -27,7 +27,7 @@ public class UserNotification implements Serializable { public enum Type { - ASSIGNROLE, REVOKEROLE, CREATEDV, CREATEDS, CREATEACC, MAPLAYERUPDATED, MAPLAYERDELETEFAILED, SUBMITTEDDS, RETURNEDDS, PUBLISHEDDS, REQUESTFILEACCESS, GRANTFILEACCESS, REJECTFILEACCESS, FILESYSTEMIMPORT, CHECKSUMIMPORT, CHECKSUMFAIL, CONFIRMEMAIL, APIGENERATED, INGESTCOMPLETED + ASSIGNROLE, REVOKEROLE, CREATEDV, CREATEDS, CREATEACC, MAPLAYERUPDATED, MAPLAYERDELETEFAILED, SUBMITTEDDS, RETURNEDDS, PUBLISHEDDS, REQUESTFILEACCESS, GRANTFILEACCESS, REJECTFILEACCESS, FILESYSTEMIMPORT, CHECKSUMIMPORT, CHECKSUMFAIL, CONFIRMEMAIL, APIGENERATED, INGESTCOMPLETED, INGESTCOMPLETEDWITHERRORS }; private static final long serialVersionUID = 1L; diff --git a/src/main/java/edu/harvard/iq/dataverse/authorization/providers/builtin/DataverseUserPage.java b/src/main/java/edu/harvard/iq/dataverse/authorization/providers/builtin/DataverseUserPage.java index eebf79f05c8..006056de348 100644 --- a/src/main/java/edu/harvard/iq/dataverse/authorization/providers/builtin/DataverseUserPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/authorization/providers/builtin/DataverseUserPage.java @@ -515,6 +515,7 @@ public void displayNotification() { break; case INGESTCOMPLETED: + case INGESTCOMPLETEDWITHERRORS: userNotification.setTheObject(datasetService.find(userNotification.getObjectId())); break; } diff --git a/src/main/java/edu/harvard/iq/dataverse/ingest/IngestMessageBean.java b/src/main/java/edu/harvard/iq/dataverse/ingest/IngestMessageBean.java index 3b65ff624a8..42dec6f1d46 100644 --- a/src/main/java/edu/harvard/iq/dataverse/ingest/IngestMessageBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/ingest/IngestMessageBean.java @@ -74,6 +74,8 @@ public void onMessage(Message message) { Iterator iter = ingestMessage.getFileIds().iterator(); datafile_id = null; + boolean ingestWithErrors = false; + StringBuilder sbIngestedFiles = new StringBuilder(); sbIngestedFiles.append("
    "); @@ -84,13 +86,15 @@ public void onMessage(Message message) { try { DataFile datafile = datafileService.find(datafile_id); - sbIngestedFiles.append(String.format("
  • %s
  • ", datafile.getCurrentName())); if (ingestService.ingestAsTabular(datafile_id)) { //Thread.sleep(10000); logger.fine("Finished ingest job;"); + sbIngestedFiles.append(String.format("
  • %s
  • ", datafile.getCurrentName())); } else { logger.warning("Error occurred during ingest job for file id " + datafile_id + "!"); + sbIngestedFiles.append(String.format("
  • %s (Error)
  • ", datafile.getCurrentName())); + ingestWithErrors = true; } } catch (Exception ex) { @@ -106,6 +110,8 @@ public void onMessage(Message message) { DataFile datafile = datafileService.find(datafile_id); if (datafile != null) { + ingestWithErrors = true; + sbIngestedFiles.append(String.format("
  • %s (Error)
  • ", datafile.getCurrentName())); datafile.SetIngestProblem(); @@ -155,7 +161,7 @@ public void onMessage(Message message) { userNotificationService.sendNotification( authenticatedUser, Timestamp.from(Instant.now()), - UserNotification.Type.INGESTCOMPLETED, + !ingestWithErrors ? UserNotification.Type.INGESTCOMPLETED : UserNotification.Type.INGESTCOMPLETEDWITHERRORS, objectId, sbIngestedFiles.toString(), true diff --git a/src/main/java/edu/harvard/iq/dataverse/util/MailUtil.java b/src/main/java/edu/harvard/iq/dataverse/util/MailUtil.java index 4146c1b55fa..7a144e65ee1 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/MailUtil.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/MailUtil.java @@ -76,7 +76,9 @@ public static String getSubjectTextBasedOnNotification(UserNotification userNoti case APIGENERATED: return BundleUtil.getStringFromBundle("notification.email.apiTokenGenerated.subject", rootDvNameAsList); case INGESTCOMPLETED: - return BundleUtil.getStringFromBundle("notification.email.ingestcompleted.subject", rootDvNameAsList); + return BundleUtil.getStringFromBundle("notification.email.ingestCompleted.subject", rootDvNameAsList); + case INGESTCOMPLETEDWITHERRORS: + return BundleUtil.getStringFromBundle("notification.email.ingestCompletedWithErrors.subject", rootDvNameAsList); } return ""; } diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index 4c2afaedcf9..0d17f2dcd06 100755 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -187,7 +187,8 @@ notification.dataset.management.title=Dataset Management - Dataset User Guide notification.wasSubmittedForReview={0} was submitted for review to be published in {1}. Don''t forget to publish it or send it back to the contributor, {2} ({3})\! notification.wasReturnedByReviewer={0} was returned by the curator of {1}. notification.wasPublished={0} was published in {1}. -notification.ingestCompleted=Dataset {1} ingest has finished. +notification.ingestCompleted=Dataset {1} ingest has successfully finished. +notification.ingestCompletedWithErrors=Dataset {1} ingest has finished with errors. notification.worldMap.added={0}, dataset had WorldMap layer data added to it. notification.maplayer.deletefailed=Failed to delete the map layer associated with the restricted file {0} from WorldMap. Please try again, or contact WorldMap and/or Dataverse support. (Dataset: {1}) notification.generic.objectDeleted=The dataverse, dataset, or file for this notification has been deleted. @@ -201,6 +202,7 @@ notification.access.revoked.dataset=You have been removed from a role in {0}. notification.access.revoked.datafile=You have been removed from a role in {0}. notification.checksumfail=One or more files in your upload failed checksum validation for dataset {1}. Please re-run the upload script. If the problem persists, please contact support. notification.ingest.completed=Dataset {2} ingest process has successfully finished.

    Ingested files:{3}
    +notification.ingest.completedwitherrors=Dataset {2} ingest process has finished with errors.

    Ingested files:{3}
    notification.mail.import.filesystem=Dataset {2} ({0}/dataset.xhtml?persistentId={1}) has been successfully uploaded and verified. notification.import.filesystem=Dataset {1} has been successfully uploaded and verified. notification.import.checksum={1}, dataset had file checksums added via a batch job. @@ -637,7 +639,8 @@ notification.email.create.account.subject={0}: Your account has been created notification.email.assign.role.subject={0}: You have been assigned a role notification.email.revoke.role.subject={0}: Your role has been revoked notification.email.verifyEmail.subject={0}: Verify your email address -notification.email.ingestcompleted.subject={0}: Your ingest has finished! +notification.email.ingestCompleted.subject={0}: Your ingest has successfully finished! +notification.email.ingestCompletedWithErrors.subject={0}: Your ingest has finished with errors! notification.email.greeting=Hello, \n # Bundle file editors, please note that "notification.email.welcome" is used in a unit test notification.email.welcome=Welcome to {0}! Get started by adding or finding data. Have questions? Check out the User Guide at {1}/{2}/user or contact {3} at {4} for assistance. diff --git a/src/main/webapp/dataverseuser.xhtml b/src/main/webapp/dataverseuser.xhtml index 63d93a72994..e35acbb73cf 100644 --- a/src/main/webapp/dataverseuser.xhtml +++ b/src/main/webapp/dataverseuser.xhtml @@ -332,6 +332,13 @@ + + + + + + +