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 e76e2c5696b..d64a1f7cce1 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/MailUtil.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/MailUtil.java @@ -32,6 +32,12 @@ public static InternetAddress parseSystemAddress(String systemEmail) { public static String getSubjectTextBasedOnNotification(UserNotification userNotification, Object objectOfNotification) { List rootDvNameAsList = Arrays.asList(BrandingUtil.getInstallationBrandName()); + String datasetDisplayName = ""; + + if (objectOfNotification != null && (objectOfNotification instanceof Dataset) ) { + datasetDisplayName = ((Dataset)objectOfNotification).getDisplayName(); + } + switch (userNotification.getType()) { case ASSIGNROLE: return BundleUtil.getStringFromBundle("notification.email.assign.role.subject", rootDvNameAsList); @@ -46,23 +52,23 @@ public static String getSubjectTextBasedOnNotification(UserNotification userNoti case REJECTFILEACCESS: return BundleUtil.getStringFromBundle("notification.email.rejected.file.access.subject", rootDvNameAsList); case DATASETCREATED: - return BundleUtil.getStringFromBundle("notification.email.dataset.created.subject", Arrays.asList(rootDvNameAsList.get(0), ((Dataset)objectOfNotification).getDisplayName())); + return BundleUtil.getStringFromBundle("notification.email.dataset.created.subject", Arrays.asList(rootDvNameAsList.get(0), datasetDisplayName)); case CREATEDS: - return BundleUtil.getStringFromBundle("notification.email.create.dataset.subject", rootDvNameAsList); + return BundleUtil.getStringFromBundle("notification.email.create.dataset.subject", Arrays.asList(rootDvNameAsList.get(0), datasetDisplayName)); case SUBMITTEDDS: - return BundleUtil.getStringFromBundle("notification.email.submit.dataset.subject", rootDvNameAsList); + return BundleUtil.getStringFromBundle("notification.email.submit.dataset.subject", Arrays.asList(rootDvNameAsList.get(0), datasetDisplayName)); case PUBLISHEDDS: - return BundleUtil.getStringFromBundle("notification.email.publish.dataset.subject", rootDvNameAsList); + return BundleUtil.getStringFromBundle("notification.email.publish.dataset.subject", Arrays.asList(rootDvNameAsList.get(0), datasetDisplayName)); case PUBLISHFAILED_PIDREG: - return BundleUtil.getStringFromBundle("notification.email.publishFailure.dataset.subject", rootDvNameAsList); + return BundleUtil.getStringFromBundle("notification.email.publishFailure.dataset.subject", Arrays.asList(rootDvNameAsList.get(0), datasetDisplayName)); case RETURNEDDS: - return BundleUtil.getStringFromBundle("notification.email.returned.dataset.subject", rootDvNameAsList); + return BundleUtil.getStringFromBundle("notification.email.returned.dataset.subject", Arrays.asList(rootDvNameAsList.get(0), datasetDisplayName)); case WORKFLOW_SUCCESS: - return BundleUtil.getStringFromBundle("notification.email.workflow.success.subject", rootDvNameAsList); + return BundleUtil.getStringFromBundle("notification.email.workflow.success.subject", Arrays.asList(rootDvNameAsList.get(0), datasetDisplayName)); case WORKFLOW_FAILURE: - return BundleUtil.getStringFromBundle("notification.email.workflow.failure.subject", rootDvNameAsList); + return BundleUtil.getStringFromBundle("notification.email.workflow.failure.subject", Arrays.asList(rootDvNameAsList.get(0), datasetDisplayName)); case STATUSUPDATED: - return BundleUtil.getStringFromBundle("notification.email.status.change.subject", rootDvNameAsList); + return BundleUtil.getStringFromBundle("notification.email.status.change.subject", Arrays.asList(rootDvNameAsList.get(0), datasetDisplayName)); case CREATEACC: return BundleUtil.getStringFromBundle("notification.email.create.account.subject", rootDvNameAsList); case CHECKSUMFAIL: @@ -115,13 +121,13 @@ 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", Arrays.asList(rootDvNameAsList.get(0), datasetDisplayName)); case INGESTCOMPLETEDWITHERRORS: - return BundleUtil.getStringFromBundle("notification.email.ingestCompletedWithErrors.subject", rootDvNameAsList); + return BundleUtil.getStringFromBundle("notification.email.ingestCompletedWithErrors.subject", Arrays.asList(rootDvNameAsList.get(0), datasetDisplayName)); case DATASETMENTIONED: return BundleUtil.getStringFromBundle("notification.email.datasetWasMentioned.subject", rootDvNameAsList); } return ""; } -} \ No newline at end of file +} diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index 8a4fdeb9e28..d9a72450b25 100644 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -732,28 +732,28 @@ dashboard.card.datamove.dataset.command.error.indexingProblem=Dataset could not #MailServiceBean.java notification.email.create.dataverse.subject={0}: Your dataverse has been created -notification.email.create.dataset.subject={0}: Your dataset has been created +notification.email.create.dataset.subject={0}: Dataset "{1}" has been created notification.email.dataset.created.subject={0}: Dataset "{1}" has been created notification.email.request.file.access.subject={0}: Access has been requested for a restricted file notification.email.grant.file.access.subject={0}: You have been granted access to a restricted file notification.email.rejected.file.access.subject={0}: Your request for access to a restricted file has been rejected -notification.email.submit.dataset.subject={0}: Your dataset has been submitted for review -notification.email.publish.dataset.subject={0}: Your dataset has been published -notification.email.publishFailure.dataset.subject={0}: Failed to publish your dataset -notification.email.returned.dataset.subject={0}: Your dataset has been returned -notification.email.workflow.success.subject={0}: Your dataset has been processed +notification.email.submit.dataset.subject={0}: Dataset "{1}" has been submitted for review +notification.email.publish.dataset.subject={0}: Dataset "{1}" has been published +notification.email.publishFailure.dataset.subject={0}: Failed to publish your dataset "{1}" +notification.email.returned.dataset.subject={0}: Dataset "{1}" has been returned +notification.email.workflow.success.subject={0}: Dataset "{1}" has been processed notification.email.workflow.success=A workflow running on {0} (view at {1} ) succeeded: {2} -notification.email.workflow.failure.subject={0}: Failed to process your dataset +notification.email.workflow.failure.subject={0}: Failed to process your dataset "{1}" notification.email.workflow.failure=A workflow running on {0} (view at {1} ) failed: {2} -notification.email.status.change.subject={0}: Dataset Status Change +notification.email.status.change.subject={0}: Dataset "{1}" Status Change notification.email.status.change=The Status of the dataset ({0}) has changed to {1} notification.email.workflow.nullMessage=No additional message sent from the workflow. 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}: Dataset status -notification.email.ingestCompletedWithErrors.subject={0}: Dataset status +notification.email.ingestCompleted.subject={0}: Dataset "{1}" status +notification.email.ingestCompletedWithErrors.subject={0}: Dataset "{1}" status notification.email.greeting=Hello, \n notification.email.greeting.html=Hello,
# Bundle file editors, please note that "notification.email.welcome" is used in a unit test diff --git a/src/test/java/edu/harvard/iq/dataverse/util/MailUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/util/MailUtilTest.java index 4363d1dd3c9..76e447b3faa 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/MailUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/MailUtilTest.java @@ -98,25 +98,25 @@ public void testSubjectRejectFileAccess() { @Test public void testSubjectCreateDataset() { userNotification.setType(UserNotification.Type.CREATEDS); - assertEquals("LibraScholar: Your dataset has been created", MailUtil.getSubjectTextBasedOnNotification(userNotification, null)); + assertEquals("LibraScholar: Dataset \"\" has been created", MailUtil.getSubjectTextBasedOnNotification(userNotification, null)); } @Test public void testSubjectSubmittedDS() { userNotification.setType(UserNotification.Type.SUBMITTEDDS); - assertEquals("LibraScholar: Your dataset has been submitted for review", MailUtil.getSubjectTextBasedOnNotification(userNotification, null)); + assertEquals("LibraScholar: Dataset \"\" has been submitted for review", MailUtil.getSubjectTextBasedOnNotification(userNotification, null)); } @Test public void testSubjectPublishedDS() { userNotification.setType(UserNotification.Type.PUBLISHEDDS); - assertEquals("LibraScholar: Your dataset has been published", MailUtil.getSubjectTextBasedOnNotification(userNotification, null)); + assertEquals("LibraScholar: Dataset \"\" has been published", MailUtil.getSubjectTextBasedOnNotification(userNotification, null)); } @Test public void testSubjectReturnedDS() { userNotification.setType(UserNotification.Type.RETURNEDDS); - assertEquals("LibraScholar: Your dataset has been returned", MailUtil.getSubjectTextBasedOnNotification(userNotification, null)); + assertEquals("LibraScholar: Dataset \"\" has been returned", MailUtil.getSubjectTextBasedOnNotification(userNotification, null)); } @Test