diff --git a/doc/sphinx-guides/source/installation/config.rst b/doc/sphinx-guides/source/installation/config.rst index b4a9c146127..d250a717080 100644 --- a/doc/sphinx-guides/source/installation/config.rst +++ b/doc/sphinx-guides/source/installation/config.rst @@ -433,9 +433,11 @@ The key required to create users via API as documented at :doc:`/api/native-api` :SystemEmail ++++++++++++ -This is the email address that "system" emails are sent from such as password reset links. +This is the email address that "system" emails are sent from such as password reset links. Your Dataverse installation will not send mail without this setting in place. -``curl -X PUT -d "Support " http://localhost:8080/api/admin/settings/:SystemEmail`` +``curl -X PUT -d 'LibraScholar SWAT Team ' http://localhost:8080/api/admin/settings/:SystemEmail`` + +Note that only the email address is required, which you can supply without the ``<`` and ``>`` signs, but if you include the text, it's the way to customize the name of your support team, which appears in the "from" address in emails as well as in help text in the UI. :FooterCopyright ++++++++++++++++ diff --git a/doc/sphinx-guides/source/style/patterns.rst b/doc/sphinx-guides/source/style/patterns.rst index e0ce5eb8581..80792bbdf68 100644 --- a/doc/sphinx-guides/source/style/patterns.rst +++ b/doc/sphinx-guides/source/style/patterns.rst @@ -519,7 +519,7 @@ For our help/information, success, warning, and error message blocks we use a cu  Success! – The metadata for this dataset has been updated.
-  Error – The username, email address, or password you entered is invalid. Need assistance accessing your account? If you believe this is an error, please contact Dataverse Support for assistance. +  Error – The username, email address, or password you entered is invalid. Need assistance accessing your account? If you believe this is an error, please contact Root Support for assistance.
diff --git a/doc/sphinx-guides/source/user/account.rst b/doc/sphinx-guides/source/user/account.rst index 9e5c9565d1f..5c704b90157 100755 --- a/doc/sphinx-guides/source/user/account.rst +++ b/doc/sphinx-guides/source/user/account.rst @@ -99,7 +99,7 @@ If you already have a Dataverse account associated with the Username/Email log i Convert your Dataverse account away from your Institutional Log In ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -If you are leaving your institution and need to convert your Dataverse account to the Dataverse Username/Email log in option, you will need to contact support for the Dataverse installation you are using. On your account page, there is a link for "Dataverse Support" that will open the popup form to contact support for assistance. +If you are leaving your institution and need to convert your Dataverse account to the Dataverse Username/Email log in option, you will need to contact support for the Dataverse installation you are using. On your account page, there is a link that will open a popup form to contact support for assistance. ORCID Log In ~~~~~~~~~~~~~ @@ -132,7 +132,7 @@ If you already have a Dataverse account associated with the Username/Email log i Convert your Dataverse account away from ORCID for log in ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -If you don't want to log in to Dataverse using ORCID any more, you will want to convert your Dataverse account to the Dataverse Username/Email log in option. To do this, you will need to contact support for the Dataverse installation you are using. On your account page, there is a link for "Dataverse Support" that will open the popup form to contact support for assistance. +If you don't want to log in to Dataverse using ORCID any more, you will want to convert your Dataverse account to the Dataverse Username/Email log in option. To do this, you will need to contact support for the Dataverse installation you are using. On your account page, there is a link that will open a popup form to contact support for assistance. GitHub and Google Log In ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/scripts/api/setup-optional-harvard.sh b/scripts/api/setup-optional-harvard.sh index 4bcae4c8685..c1815998e6e 100755 --- a/scripts/api/setup-optional-harvard.sh +++ b/scripts/api/setup-optional-harvard.sh @@ -21,7 +21,7 @@ echo "- Enabling Geoconnect" curl -s -X PUT -d true "$SERVER/admin/settings/:GeoconnectCreateEditMaps" curl -s -X PUT -d true "$SERVER/admin/settings/:GeoconnectViewMaps" echo "- Setting system email" -curl -X PUT -d "Dataverse Support " http://localhost:8080/api/admin/settings/:SystemEmail +curl -X PUT -d "Harvard Dataverse Support " http://localhost:8080/api/admin/settings/:SystemEmail curl -X PUT -d ", The President & Fellows of Harvard College" http://localhost:8080/api/admin/settings/:FooterCopyright echo "- Setting up the Harvard Shibboleth institutional group" curl -s -X POST -H 'Content-type:application/json' --upload-file data/shibGroupHarvard.json "$SERVER/admin/groups/shib?key=$adminKey" diff --git a/scripts/database/upgrades/upgrade_v4.6.2_to_v4.7.sql b/scripts/database/upgrades/upgrade_v4.6.2_to_v4.7.sql new file mode 100644 index 00000000000..901b013a104 --- /dev/null +++ b/scripts/database/upgrades/upgrade_v4.6.2_to_v4.7.sql @@ -0,0 +1,2 @@ +--Uncomment to preserve "Dataverse" at end of each dataverse name. +--UPDATE dataverse SET name = name || ' Dataverse'; diff --git a/src/main/java/Bundle.properties b/src/main/java/Bundle.properties index dc38b23462d..a778ca538cb 100755 --- a/src/main/java/Bundle.properties +++ b/src/main/java/Bundle.properties @@ -112,11 +112,11 @@ messages.validation.msg=Required fields were missed or there was a validation er # contactFormFragment.xhtml -contact.header=Contact Dataverse Support +contact.header=Contact {0} contact.dataverse.header=Email Dataverse Contact contact.dataset.header=Email Dataset Contact contact.to=To -contact.support=Dataverse Support +contact.support=Support contact.from=From contact.from.required=User email is required. contact.from.invalid=Email is invalid. @@ -154,7 +154,7 @@ wasReturnedByReviewer=, was returned by the curator of toReview=Don't forget to publish it or send it back to the contributor! worldMap.added=dataset had a WorldMap layer data added to it. # Bundle file editors, please note that "notification.welcome" is used in a unit test. -notification.welcome=Welcome to {0} Dataverse! Get started by adding or finding data. Have questions? Check out the {1}. Want to test out Dataverse features? Use our {2}. Also, check for your welcome email to verify your address. +notification.welcome=Welcome to {0}! Get started by adding or finding data. Have questions? Check out the {1}. Want to test out Dataverse features? Use our {2}. Also, check for your welcome email to verify your address. notification.demoSite=Demo Site notification.requestFileAccess=File access requested for dataset: {0}. notification.grantFileAccess=Access granted for files in dataset: {0}. @@ -498,38 +498,38 @@ harvestserver.viewEditDialog.btn.save=Save Changes #MailServiceBean.java -notification.email.create.dataverse.subject=Dataverse: Your dataverse has been created -notification.email.create.dataset.subject=Dataverse: Your dataset has been created -notification.email.request.file.access.subject=Dataverse: Access has been requested for a restricted file -notification.email.grant.file.access.subject=Dataverse: You have been granted access to restricted file -notification.email.rejected.file.access.subject=Dataverse: Your request for access to restricted file has been rejected -notification.email.update.maplayer=Dataverse: WorldMap layer added to dataset -notification.email.maplayer.deletefailed.subject=Failed to delete WorldMap layer +notification.email.create.dataverse.subject={0}: Your dataverse has been created +notification.email.create.dataset.subject={0}: Your dataset 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.update.maplayer={0}: WorldMap layer added to dataset +notification.email.maplayer.deletefailed.subject={0}: Failed to delete WorldMap layer notification.email.maplayer.deletefailed.text=We failed to delete the WorldMap layer associated with the restricted file {0}, and any related data that may still be publicly available on the WorldMap site. Please try again, or contact WorldMap and/or Dataverse support. (Dataset: {1}) -notification.email.submit.dataset.subject=Dataverse: Your dataset has been submitted for review -notification.email.publish.dataset.subject=Dataverse: Your dataset has been published -notification.email.returned.dataset.subject=Dataverse: Your dataset has been returned -notification.email.create.account.subject=Dataverse: Your account has been created -notification.email.assign.role.subject=Dataverse: You have been assigned a role -notification.email.revoke.role.subject=Dataverse: Your role has been revoked -notification.email.verifyEmail.subject=Dataverse: Verify your email address +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.returned.dataset.subject={0}: Your dataset has been returned +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.greeting=Hello, \n # Bundle file editors, please note that "notification.email.welcome" is used in a unit test -notification.email.welcome=Welcome to Dataverse! Get started by adding or finding data. Have questions? Check out the User Guide at {0}/{1}/user/ or contact Dataverse Support for assistance. Want to test out Dataverse features? Use our Demo Site at https://demo.dataverse.org +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. notification.email.welcomeConfirmEmailAddOn=\n\nPlease verify your email address at {0}. Note, the verify link will expire after {1}. Send another verification email by visiting your account page. notification.email.requestFileAccess=File access requested for dataset: {0}. Manage permissions at {1}. notification.email.grantFileAccess=Access granted for files in dataset: {0} (view at {1}). notification.email.rejectFileAccess=Access rejected for requested files in dataset: {0} (view at {1}). # Bundle file editors, please note that "notification.email.createDataverse" is used in a unit test -notification.email.createDataverse=Your new dataverse named {0} (view at {1} ) was created in {2} (view at {3} ). To learn more about what you can do with your dataverse, check out the Dataverse Management - Dataverse User Guide at {4}/{5}/user/dataverse-management.html . +notification.email.createDataverse=Your new dataverse named {0} (view at {1} ) was created in {2} (view at {3} ). To learn more about what you can do with your dataverse, check out the Dataverse Management - User Guide at {4}/{5}/user/dataverse-management.html . # Bundle file editors, please note that "notification.email.createDataset" is used in a unit test -notification.email.createDataset=Your new dataset named {0} (view at {1} ) was created in {2} (view at {3} ). To learn more about what you can do with a dataset, check out the Dataset Management - Dataset User Guide at {4}/{5}/user/dataset-management.html . -notification.email.wasSubmittedForReview={0} (view at {1}) was submitted for review to be published in {2} (view at {3}). Don't forget to publish it or send it back to the contributor\! +notification.email.createDataset=Your new dataset named {0} (view at {1} ) was created in {2} (view at {3} ). To learn more about what you can do with a dataset, check out the Dataset Management - User Guide at {4}/{5}/user/dataset-management.html . +notification.email.wasSubmittedForReview={0} (view at {1}) was submitted for review to be published in {2} (view at {3}). Don't forget to publish it or send it back to the contributor\! notification.email.wasReturnedByReviewer={0} (view at {1}) was returned by the curator of {2} (view at {3}). notification.email.wasPublished={0} (view at {1}) was published in {2} (view at {3}). notification.email.worldMap.added={0} (view at {1}) had WorldMap layer data added to it. -notification.email.closing=\n\nThank you,\nThe Dataverse Project +notification.email.closing=\n\nThank you,\n{0} notification.email.assignRole=You are now {0} for the {1} "{2}" (view at {3}). notification.email.revokeRole=One of your roles for the {0} "{1}" has been revoked (view at {2}). notification.email.changeEmail=Hello, {0}.{1}\n\nPlease contact us if you did not intend this change or if you need assistance. @@ -537,9 +537,9 @@ hours=hours hour=hour minutes=minutes minute=minute -notification.email.checksumfail.subject=Dataverse: Your upload failed checksum validation. -notification.email.import.filesystem.subject=Dataverse: Your file import job has completed -notification.email.import.checksum.subject=Dataverse: Your file checksum job has completed +notification.email.checksumfail.subject={0}: Your upload failed checksum validation +notification.email.import.filesystem.subject={0}: Your file import job has completed +notification.email.import.checksum.subject={0}: Your file checksum job has completed # passwordreset.xhtml @@ -951,7 +951,7 @@ dataset.manageTemplates.tab.action.btn.delete.dialog.header=Delete Template dataset.manageTemplates.tab.action.btn.view.dialog.header=Dataset Template Preview dataset.manageTemplates.tab.action.btn.view.dialog.datasetTemplate=Dataset Template dataset.manageTemplates.tab.action.btn.view.dialog.datasetTemplate.title=The dataset template which prepopulates info into the form automatically. -dataset.manageTemplates.tab.action.noedit.createdin=Template created at {0} Dataverse +dataset.manageTemplates.tab.action.noedit.createdin=Template created at {0} dataset.manageTemplates.delete.usedAsDefault=This template is the default template for the following dataverse(s). It will be removed as default as well. dataset.manageTemplates.info.message.notEmptyTable=Create, clone, edit, view, or delete dataset templates. Create a dataset template to prefill metadata fields with standard values, such as author affiliation, to help users create datasets in this dataverse. You can also add help text directly into the metadata fields to give users more information on what to add to these metadata fields. @@ -1034,7 +1034,7 @@ dataset.manageGuestbooks.tab.action.btn.view.dialog.datasetGuestbook=Guestbook N dataset.manageGuestbooks.tab.action.btn.viewCollectedData.dialog.header=Dataset Guestbook Collected Data dataset.manageGuestbooks.tab.action.btn.view.dialog.userCollectedData.title=User data collected by the guestbook. dataset.manageGuestbooks.tab.action.btn.view.dialog.userCollectedData=Collected Data -dataset.manageGuestbooks.tab.action.noedit.createdin=Guestbook created at {0} Dataverse +dataset.manageGuestbooks.tab.action.noedit.createdin=Guestbook created at {0} dataset.manageGuestbooks.message.deleteSuccess=The guestbook has been deleted. dataset.manageGuestbooks.message.deleteFailure=The guestbook cannot be deleted. dataset.manageGuestbooks.message.editSuccess=The guestbook has been updated. @@ -1383,11 +1383,11 @@ file.dataFilesTab.terms.list.termsOfAccess.addInfo.studyCompletion.title=Relatio file.dataFilesTab.terms.list.guestbook=Guestbook file.dataFilesTab.terms.list.guestbook.title=User information (i.e., name, email, institution, and position) will be collected when files are downloaded. file.dataFilesTab.terms.list.guestbook.noSelected.tip=No guestbook is assigned to this dataset, you will not be prompted to provide any information on file download. -file.dataFilesTab.terms.list.guestbook.noSelected.admin.tip=There are no guestbooks available in {0} Dataverse to assign to this dataset. +file.dataFilesTab.terms.list.guestbook.noSelected.admin.tip=There are no guestbooks available in {0} to assign to this dataset. file.dataFilesTab.terms.list.guestbook.inUse.tip=The following guestbook will prompt a user to provide additional information when downloading a file. file.dataFilesTab.terms.list.guestbook.viewBtn=Preview Guestbook file.dataFilesTab.terms.list.guestbook.select.tip=Select a guestbook to have a user provide additional information when downloading a file. -file.dataFilesTab.terms.list.guestbook.noAvailable.tip=There are no guestbooks enabled in {0} Dataverse. To create a guestbook, return to {0} Dataverse, click the "Edit" button and select the "Dataset Guestbooks" option. +file.dataFilesTab.terms.list.guestbook.noAvailable.tip=There are no guestbooks enabled in {0}. To create a guestbook, return to {0}, click the "Edit" button and select the "Dataset Guestbooks" option. file.dataFilesTab.terms.list.guestbook.clearBtn=Clear Selection file.dataFilesTab.versions=Versions diff --git a/src/main/java/edu/harvard/iq/dataverse/AbstractIdServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/AbstractIdServiceBean.java index 9142893f7cb..1ee5fabbbcc 100644 --- a/src/main/java/edu/harvard/iq/dataverse/AbstractIdServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/AbstractIdServiceBean.java @@ -53,7 +53,7 @@ protected HashMap addBasicMetadata(Dataset datasetIn, HashMap>>. Body: " + body); try { Message msg = new MimeMessage(session); @@ -185,7 +187,8 @@ public Boolean sendNotificationEmail(UserNotification notification){ Object objectOfNotification = getObjectOfNotification(notification); if (objectOfNotification != null){ String messageText = getMessageTextBasedOnNotification(notification, objectOfNotification); - String subjectText = getSubjectTextBasedOnNotification(notification); + String rootDataverseName = dataverseService.findRootDataverse().getName(); + String subjectText = MailUtil.getSubjectTextBasedOnNotification(notification, rootDataverseName); if (!(messageText.isEmpty() || subjectText.isEmpty())){ retval = sendSystemEmail(emailAddress, subjectText, messageText); } else { @@ -199,45 +202,7 @@ public Boolean sendNotificationEmail(UserNotification notification){ } return retval; } - - private String getSubjectTextBasedOnNotification(UserNotification userNotification) { - switch (userNotification.getType()) { - case ASSIGNROLE: - return ResourceBundle.getBundle("Bundle").getString("notification.email.assign.role.subject"); - case REVOKEROLE: - return ResourceBundle.getBundle("Bundle").getString("notification.email.revoke.role.subject"); - case CREATEDV: - return ResourceBundle.getBundle("Bundle").getString("notification.email.create.dataverse.subject"); - case REQUESTFILEACCESS: - return ResourceBundle.getBundle("Bundle").getString("notification.email.request.file.access.subject"); - case GRANTFILEACCESS: - return ResourceBundle.getBundle("Bundle").getString("notification.email.grant.file.access.subject"); - case REJECTFILEACCESS: - return ResourceBundle.getBundle("Bundle").getString("notification.email.rejected.file.access.subject"); - case MAPLAYERUPDATED: - return ResourceBundle.getBundle("Bundle").getString("notification.email.update.maplayer"); - case MAPLAYERDELETEFAILED: - return ResourceBundle.getBundle("Bundle").getString("notification.email.maplayer.deletefailed.subject"); - case CREATEDS: - return ResourceBundle.getBundle("Bundle").getString("notification.email.create.dataset.subject"); - case SUBMITTEDDS: - return ResourceBundle.getBundle("Bundle").getString("notification.email.submit.dataset.subject"); - case PUBLISHEDDS: - return ResourceBundle.getBundle("Bundle").getString("notification.email.publish.dataset.subject"); - case RETURNEDDS: - return ResourceBundle.getBundle("Bundle").getString("notification.email.returned.dataset.subject"); - case CREATEACC: - return ResourceBundle.getBundle("Bundle").getString("notification.email.create.account.subject"); - case CHECKSUMFAIL: - return ResourceBundle.getBundle("Bundle").getString("notification.email.checksumfail.subject"); - case FILESYSTEMIMPORT: - return ResourceBundle.getBundle("Bundle").getString("notification.email.import.filesystem.subject"); - case CHECKSUMIMPORT: - return ResourceBundle.getBundle("Bundle").getString("notification.email.import.checksum.subject"); - } - return ""; - } - + private String getDatasetManageFileAccessLink(DataFile datafile){ return systemConfig.getDataverseSiteUrl() + "/permissions-manage-files.xhtml?id=" + datafile.getOwner().getId(); } @@ -442,9 +407,14 @@ private String getMessageTextBasedOnNotification(UserNotification userNotificati messageText += MessageFormat.format(pattern, paramArrayReturnedDataset); return messageText; case CREATEACC: + String rootDataverseName = dataverseService.findRootDataverse().getName(); + InternetAddress systemAddress = getSystemAddress(); String accountCreatedMessage = BundleUtil.getStringFromBundle("notification.email.welcome", Arrays.asList( + BrandingUtil.getInstallationBrandName(rootDataverseName), systemConfig.getGuidesBaseUrl(), - systemConfig.getGuidesVersion() + systemConfig.getGuidesVersion(), + BrandingUtil.getSupportTeamName(systemAddress, rootDataverseName), + BrandingUtil.getSupportTeamEmailAddress(systemAddress) )); String optionalConfirmEmailAddon = confirmEmailService.optionalConfirmEmailAddonMsg(userNotification.getUser()); accountCreatedMessage += optionalConfirmEmailAddon; diff --git a/src/main/java/edu/harvard/iq/dataverse/SendFeedbackDialog.java b/src/main/java/edu/harvard/iq/dataverse/SendFeedbackDialog.java index 99e155fcf8e..d68a610bd1a 100644 --- a/src/main/java/edu/harvard/iq/dataverse/SendFeedbackDialog.java +++ b/src/main/java/edu/harvard/iq/dataverse/SendFeedbackDialog.java @@ -1,5 +1,6 @@ package edu.harvard.iq.dataverse; +import edu.harvard.iq.dataverse.branding.BrandingUtil; import edu.harvard.iq.dataverse.settings.SettingsServiceBean; import static edu.harvard.iq.dataverse.util.JsfHelper.JH; import edu.harvard.iq.dataverse.util.MailUtil; @@ -36,6 +37,7 @@ public class SendFeedbackDialog implements java.io.Serializable { // If there is no recipient, this is a general feeback message private DvObject recipient; private Logger logger = Logger.getLogger(SendFeedbackDialog.class.getCanonicalName()); + private InternetAddress systemAddress; @EJB MailServiceBean mailService; @@ -55,7 +57,6 @@ public String getUserEmail() { } public void initUserInput(ActionEvent ae) { - System.out.println("initUserInput()"); userEmail=""; userMessage=""; messageTo=""; @@ -64,7 +65,8 @@ public void initUserInput(ActionEvent ae) { op1 = new Long(random.nextInt(10)); op2 = new Long(random.nextInt(10)); userSum=null; - + String systemEmail = settingsService.getValueForKey(SettingsServiceBean.Key.SystemEmail); + systemAddress = MailUtil.parseSystemAddress(systemEmail); } public Long getOp1() { @@ -94,16 +96,17 @@ public void setUserSum(Long userSum) { public String getMessageTo() { if (recipient == null) { - return JH.localize("contact.support"); + return BrandingUtil.getSupportTeamName(systemAddress, dataverseService.findRootDataverse().getName()); } else if (recipient.isInstanceofDataverse()) { - return ((Dataverse)recipient).getDisplayName() +" "+ JH.localize("contact.contact"); - } else + return ((Dataverse) recipient).getDisplayName() + " " + JH.localize("contact.contact"); + } else { return JH.localize("dataset") + " " + JH.localize("contact.contact"); + } } public String getFormHeader() { if (recipient == null) { - return JH.localize("contact.header"); + return BrandingUtil.getContactHeader(systemAddress, dataverseService.findRootDataverse().getName()); } else if (recipient.isInstanceofDataverse()) { return JH.localize("contact.dataverse.header"); } else diff --git a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java index 82a928b4bb0..9bb68534a19 100644 --- a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java +++ b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java @@ -5,18 +5,17 @@ */ package edu.harvard.iq.dataverse; +import edu.harvard.iq.dataverse.branding.BrandingUtil; import edu.harvard.iq.dataverse.settings.Setting; import edu.harvard.iq.dataverse.settings.SettingsServiceBean; import edu.harvard.iq.dataverse.settings.SettingsServiceBean.Key; -import java.util.Arrays; -import java.util.Collections; +import edu.harvard.iq.dataverse.util.MailUtil; import java.util.HashMap; import java.util.Map; -import java.util.Set; -import java.util.TreeSet; import javax.ejb.EJB; import javax.faces.view.ViewScoped; import javax.inject.Named; +import javax.mail.internet.InternetAddress; /** * @@ -29,6 +28,9 @@ public class SettingsWrapper implements java.io.Serializable { @EJB SettingsServiceBean settingService; + @EJB + DataverseServiceBean dataverseService; + private Map settingsMap; // Related to a specific setting for guide urls @@ -131,5 +133,11 @@ public String getGuidesBaseUrl() { return guidesBaseUrl; } + public String getSupportTeamName() { + String systemEmail = getValueForKey(SettingsServiceBean.Key.SystemEmail); + InternetAddress systemAddress = MailUtil.parseSystemAddress(systemEmail); + return BrandingUtil.getSupportTeamName(systemAddress, dataverseService.findRootDataverse().getName()); + } + } diff --git a/src/main/java/edu/harvard/iq/dataverse/branding/BrandingUtil.java b/src/main/java/edu/harvard/iq/dataverse/branding/BrandingUtil.java new file mode 100644 index 00000000000..ea83fc15ebc --- /dev/null +++ b/src/main/java/edu/harvard/iq/dataverse/branding/BrandingUtil.java @@ -0,0 +1,38 @@ +package edu.harvard.iq.dataverse.branding; + +import edu.harvard.iq.dataverse.util.BundleUtil; +import java.util.Arrays; +import javax.mail.internet.InternetAddress; + +public class BrandingUtil { + + public static String getInstallationBrandName(String rootDataverseName) { + return rootDataverseName; + } + + public static String getSupportTeamName(InternetAddress systemAddress, String rootDataverseName) { + if (systemAddress != null) { + String personalName = systemAddress.getPersonal(); + if (personalName != null) { + return personalName; + } + } + if (rootDataverseName != null && !rootDataverseName.isEmpty()) { + return rootDataverseName + " " + BundleUtil.getStringFromBundle("contact.support"); + } + String saneDefault = BundleUtil.getStringFromBundle("dataverse"); + return BundleUtil.getStringFromBundle("contact.support", Arrays.asList(saneDefault)); + } + + public static String getSupportTeamEmailAddress(InternetAddress systemAddress) { + if (systemAddress == null) { + return null; + } + return systemAddress.getAddress(); + } + + public static String getContactHeader(InternetAddress systemAddress, String rootDataverseName) { + return BundleUtil.getStringFromBundle("contact.header", Arrays.asList(getSupportTeamName(systemAddress, rootDataverseName))); + } + +} diff --git a/src/main/java/edu/harvard/iq/dataverse/dataverse/DataverseUtil.java b/src/main/java/edu/harvard/iq/dataverse/dataverse/DataverseUtil.java new file mode 100644 index 00000000000..6fed8b2430b --- /dev/null +++ b/src/main/java/edu/harvard/iq/dataverse/dataverse/DataverseUtil.java @@ -0,0 +1,16 @@ +package edu.harvard.iq.dataverse.dataverse; + +import edu.harvard.iq.dataverse.authorization.users.User; +import edu.harvard.iq.dataverse.util.BundleUtil; + +public class DataverseUtil { + + public static String getSuggestedDataverseNameOnCreate(User user) { + if (user == null) { + return null; + } + // getDisplayInfo() is never null. + return user.getDisplayInfo().getTitle() + " " + BundleUtil.getStringFromBundle("dataverse"); + } + +} diff --git a/src/main/java/edu/harvard/iq/dataverse/search/IndexServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/search/IndexServiceBean.java index 648bebaa4c7..39b21befd6f 100644 --- a/src/main/java/edu/harvard/iq/dataverse/search/IndexServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/search/IndexServiceBean.java @@ -113,7 +113,7 @@ public class IndexServiceBean { @PostConstruct public void init(){ solrServer = new HttpSolrServer("http://" + systemConfig.getSolrHostColonPort() + "/solr"); - rootDataverseName = findRootDataverseCached().getName() + " " + BundleUtil.getStringFromBundle("dataverse"); + rootDataverseName = findRootDataverseCached().getName(); } @PreDestroy @@ -171,7 +171,7 @@ public Future indexDataverse(Dataverse dataverse) { solrInputDocument.addField(SearchFields.SOURCE, HARVESTED); } else { (this means that all dataverses are "local" - should this be removed? */ solrInputDocument.addField(SearchFields.IS_HARVESTED, false); - solrInputDocument.addField(SearchFields.METADATA_SOURCE, findRootDataverseCached().getName() + " " + BundleUtil.getStringFromBundle("dataverse")); //rootDataverseName); + solrInputDocument.addField(SearchFields.METADATA_SOURCE, findRootDataverseCached().getName()); //rootDataverseName); /*}*/ addDataverseReleaseDateToSolrDoc(solrInputDocument, dataverse); @@ -679,7 +679,7 @@ private String addOrUpdateDataset(IndexableDataset indexableDataset) { solrInputDocument.addField(SearchFields.METADATA_SOURCE, HARVESTED); } else { solrInputDocument.addField(SearchFields.IS_HARVESTED, false); - solrInputDocument.addField(SearchFields.METADATA_SOURCE, findRootDataverseCached().getName() + " " + BundleUtil.getStringFromBundle("dataverse")); //rootDataverseName); + solrInputDocument.addField(SearchFields.METADATA_SOURCE, findRootDataverseCached().getName()); //rootDataverseName); } DatasetVersion datasetVersion = indexableDataset.getDatasetVersion(); @@ -907,7 +907,7 @@ private String addOrUpdateDataset(IndexableDataset indexableDataset) { datafileSolrInputDocument.addField(SearchFields.METADATA_SOURCE, HARVESTED); } else { datafileSolrInputDocument.addField(SearchFields.IS_HARVESTED, false); - datafileSolrInputDocument.addField(SearchFields.METADATA_SOURCE, findRootDataverseCached().getName() + " " + BundleUtil.getStringFromBundle("dataverse")); + datafileSolrInputDocument.addField(SearchFields.METADATA_SOURCE, findRootDataverseCached().getName()); } } if (fileSortByDate == null) { 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 4b318cd7fe4..4b9d9f65d73 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/MailUtil.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/MailUtil.java @@ -1,6 +1,11 @@ package edu.harvard.iq.dataverse.util; +import edu.harvard.iq.dataverse.UserNotification; +import edu.harvard.iq.dataverse.branding.BrandingUtil; import static edu.harvard.iq.dataverse.settings.SettingsServiceBean.Key.SystemEmail; +import java.util.Arrays; +import java.util.List; +import java.util.ResourceBundle; import java.util.logging.Logger; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; @@ -23,4 +28,44 @@ public static InternetAddress parseSystemAddress(String systemEmail) { logger.fine("Email will not be sent because the " + SystemEmail + " setting is null."); return null; } + + public static String getSubjectTextBasedOnNotification(UserNotification userNotification, String rootDataverseName) { + List rootDvNameAsList = Arrays.asList(BrandingUtil.getInstallationBrandName(rootDataverseName)); + switch (userNotification.getType()) { + case ASSIGNROLE: + return BundleUtil.getStringFromBundle("notification.email.assign.role.subject", rootDvNameAsList); + case REVOKEROLE: + return BundleUtil.getStringFromBundle("notification.email.revoke.role.subject", rootDvNameAsList); + case CREATEDV: + return BundleUtil.getStringFromBundle("notification.email.create.dataverse.subject", rootDvNameAsList); + case REQUESTFILEACCESS: + return BundleUtil.getStringFromBundle("notification.email.request.file.access.subject", rootDvNameAsList); + case GRANTFILEACCESS: + return BundleUtil.getStringFromBundle("notification.email.grant.file.access.subject", rootDvNameAsList); + case REJECTFILEACCESS: + return BundleUtil.getStringFromBundle("notification.email.rejected.file.access.subject", rootDvNameAsList); + case MAPLAYERUPDATED: + return BundleUtil.getStringFromBundle("notification.email.update.maplayer", rootDvNameAsList); + case MAPLAYERDELETEFAILED: + return BundleUtil.getStringFromBundle("notification.email.maplayer.deletefailed.subject", rootDvNameAsList); + case CREATEDS: + return BundleUtil.getStringFromBundle("notification.email.create.dataset.subject", rootDvNameAsList); + case SUBMITTEDDS: + return BundleUtil.getStringFromBundle("notification.email.submit.dataset.subject", rootDvNameAsList); + case PUBLISHEDDS: + return BundleUtil.getStringFromBundle("notification.email.publish.dataset.subject", rootDvNameAsList); + case RETURNEDDS: + return BundleUtil.getStringFromBundle("notification.email.returned.dataset.subject", rootDvNameAsList); + case CREATEACC: + return BundleUtil.getStringFromBundle("notification.email.create.account.subject", rootDvNameAsList); + case CHECKSUMFAIL: + return BundleUtil.getStringFromBundle("notification.email.checksumfail.subject", rootDvNameAsList); + case FILESYSTEMIMPORT: + return BundleUtil.getStringFromBundle("notification.email.import.filesystem.subject", rootDvNameAsList); + case CHECKSUMIMPORT: + return BundleUtil.getStringFromBundle("notification.email.import.checksum.subject", rootDvNameAsList); + } + return ""; + } + } diff --git a/src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java b/src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java index 6258311b8d0..871f5b43cdf 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java @@ -607,7 +607,7 @@ public String getDefaultAuthProvider() { } public String getNameOfInstallation() { - return dataverseService.findRootDataverse().getName() + " Dataverse"; + return dataverseService.findRootDataverse().getName(); } public AbstractOAuth2AuthenticationProvider.DevOAuthAccountType getDevOAuthAccountType() { diff --git a/src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java b/src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java index 94272a64f2a..d557aac924d 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java @@ -350,7 +350,7 @@ private static String getRootDataverseNameforCitation(Dataset dataset) { } String rootDataverseName = root.getName(); if (!StringUtil.isEmpty(rootDataverseName)) { - return rootDataverseName + " Dataverse"; + return rootDataverseName; } else { return ""; } diff --git a/src/main/webapp/403.xhtml b/src/main/webapp/403.xhtml index 7fd725cc46b..bb6d6314752 100644 --- a/src/main/webapp/403.xhtml +++ b/src/main/webapp/403.xhtml @@ -11,7 +11,7 @@ - + @@ -21,7 +21,7 @@ - + diff --git a/src/main/webapp/404.xhtml b/src/main/webapp/404.xhtml index 43c80a1d5f5..488eb5cd322 100644 --- a/src/main/webapp/404.xhtml +++ b/src/main/webapp/404.xhtml @@ -12,7 +12,7 @@ - + @@ -22,7 +22,7 @@ - + diff --git a/src/main/webapp/500.xhtml b/src/main/webapp/500.xhtml index 8e07c3c85da..f617691d65e 100644 --- a/src/main/webapp/500.xhtml +++ b/src/main/webapp/500.xhtml @@ -10,7 +10,7 @@ - + diff --git a/src/main/webapp/ThemeAndWidgets.xhtml b/src/main/webapp/ThemeAndWidgets.xhtml index da229c2b436..dca392d8344 100644 --- a/src/main/webapp/ThemeAndWidgets.xhtml +++ b/src/main/webapp/ThemeAndWidgets.xhtml @@ -12,7 +12,7 @@ - + diff --git a/src/main/webapp/confirmemail.xhtml b/src/main/webapp/confirmemail.xhtml index 3b7a283382f..06f23ed7c1f 100644 --- a/src/main/webapp/confirmemail.xhtml +++ b/src/main/webapp/confirmemail.xhtml @@ -11,7 +11,7 @@ - + diff --git a/src/main/webapp/contactFormFragment.xhtml b/src/main/webapp/contactFormFragment.xhtml index ce546a8dcb7..33565e21e8f 100644 --- a/src/main/webapp/contactFormFragment.xhtml +++ b/src/main/webapp/contactFormFragment.xhtml @@ -8,7 +8,7 @@ - +
diff --git a/src/main/webapp/dashboard.xhtml b/src/main/webapp/dashboard.xhtml index ac170efe593..69af5b4a53b 100644 --- a/src/main/webapp/dashboard.xhtml +++ b/src/main/webapp/dashboard.xhtml @@ -11,7 +11,7 @@ - + diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index 04b82f0d8ad..6113ab87a49 100755 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -14,7 +14,7 @@ - + @@ -361,7 +361,7 @@
- + diff --git a/src/main/webapp/dataverse.xhtml b/src/main/webapp/dataverse.xhtml index 82f7f4c8de2..48f96328a10 100644 --- a/src/main/webapp/dataverse.xhtml +++ b/src/main/webapp/dataverse.xhtml @@ -12,7 +12,7 @@ - + @@ -57,11 +57,7 @@
-
- -
#{bundle.dataverse}
-
- +
@@ -399,7 +395,7 @@
-
+
#{DataversePage.dataverse.alias}
@@ -533,22 +529,22 @@ diff --git a/src/main/webapp/dataverse_header.xhtml b/src/main/webapp/dataverse_header.xhtml index 5d845c005fa..2d6e48522b6 100644 --- a/src/main/webapp/dataverse_header.xhtml +++ b/src/main/webapp/dataverse_header.xhtml @@ -156,14 +156,14 @@
@@ -221,10 +221,10 @@