Skip to content

Commit

Permalink
refactor(mail): remove unused MailUtil.parseSystemAddress IQSS#7424
Browse files Browse the repository at this point in the history
As we replaced the lookups and parsing with a streamlined version of it all
in MailServiceBean, we don't need this helper function anymore.
  • Loading branch information
poikilotherm committed Oct 6, 2023
1 parent 59b09cb commit 7fc613f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
18 changes: 0 additions & 18 deletions src/main/java/edu/harvard/iq/dataverse/util/MailUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,14 @@
import edu.harvard.iq.dataverse.DatasetVersion;
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.logging.Logger;
import jakarta.mail.internet.AddressException;
import jakarta.mail.internet.InternetAddress;

public class MailUtil {

private static final Logger logger = Logger.getLogger(MailUtil.class.getCanonicalName());

public static InternetAddress parseSystemAddress(String systemEmail) {
if (systemEmail != null) {
try {
InternetAddress parsedSystemEmail = new InternetAddress(systemEmail);
logger.fine("parsed system email: " + parsedSystemEmail);
return parsedSystemEmail;
} catch (AddressException ex) {
logger.info("Email will not be sent due to invalid value in " + SystemEmail + " setting: " + ex);
return null;
}
}
logger.fine("Email will not be sent because the " + SystemEmail + " setting is null.");
return null;
}

public static String getSubjectTextBasedOnNotification(UserNotification userNotification, Object objectOfNotification) {
List<String> rootDvNameAsList = Arrays.asList(BrandingUtil.getInstallationBrandName());
String datasetDisplayName = "";
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/edu/harvard/iq/dataverse/util/MailUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public void setUp() {

}

/*
@Test
public void testParseSystemAddress() {
assertEquals("support@librascholar.edu", MailUtil.parseSystemAddress("support@librascholar.edu").getAddress());
Expand All @@ -46,6 +47,7 @@ public void testParseSystemAddress() {
assertEquals(null, MailUtil.parseSystemAddress("\"LibraScholar Support Team <support@librascholar.edu>"));
assertEquals(null, MailUtil.parseSystemAddress("support1@dataverse.org, support@librascholar.edu"));
}
*/

@Test
@Order(1)
Expand Down

0 comments on commit 7fc613f

Please sign in to comment.