diff --git a/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/service/MailUtil.java b/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/service/MailUtil.java index dc5641f3..30df01fc 100644 --- a/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/service/MailUtil.java +++ b/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/service/MailUtil.java @@ -21,7 +21,6 @@ import jakarta.mail.MessagingException; import jakarta.mail.Multipart; import jakarta.mail.Part; -import org.apache.commons.lang3.StringUtils; /** * @author Russ Poetker (rpoetke1@jh.edu) @@ -32,7 +31,7 @@ private MailUtil() {} static String getHtmlText(Part part) throws MessagingException, IOException { if (part.isMimeType("text/html")) { - return cleanseContent(part.getContent().toString()); + return part.getContent().toString(); } if (part.isMimeType("multipart/alternative")) { @@ -41,7 +40,7 @@ static String getHtmlText(Part part) throws MessagingException, IOException { for (int i = 0; i < count; i++) { Part bodyPart = multipart.getBodyPart(i); if (bodyPart.isMimeType("text/html")) { - return cleanseContent(bodyPart.getContent().toString()); + return bodyPart.getContent().toString(); } else if (bodyPart.isMimeType("multipart/*")) { return getHtmlText(bodyPart); } @@ -53,15 +52,11 @@ static String getHtmlText(Part part) throws MessagingException, IOException { Part bodyPart = multipart.getBodyPart(i); String content = getHtmlText(bodyPart); if (Objects.nonNull(content)) { - return cleanseContent(content); + return content; } } } return null; } - - private static String cleanseContent(String content) { - return StringUtils.normalizeSpace(content); - } } diff --git a/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/service/NihmsReceiveMailService.java b/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/service/NihmsReceiveMailService.java index 32e9ac65..c0c644e1 100644 --- a/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/service/NihmsReceiveMailService.java +++ b/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/service/NihmsReceiveMailService.java @@ -93,20 +93,21 @@ public NihmsReceiveMailService(PassClient passClient, public void handleReceivedMail(MimeMessage receivedMessage) { try { - LOG.warn("Email received: " + receivedMessage.getSubject()); + LOG.warn("Email received: {}", receivedMessage.getSubject()); if (isEmailNotNihms(receivedMessage)) { return; } LOG.warn("Email is from Nihms"); String content = getHtmlText(receivedMessage); - LOG.warn("Nihms Email content: {}", content); if (Objects.isNull(content)) { - LOG.error("No HTML content found in nihms email: " + receivedMessage.getSubject()); + LOG.error("No HTML content found in nihms email: {}", receivedMessage.getSubject()); return; } + String loggingContent = content.replaceAll("[\n\r]", " "); + LOG.warn("Nihms Email content: {}", loggingContent); Elements messageElements = getMessageElements(content); if (messageElements.isEmpty()) { - LOG.error("No messages found in nihms email: {}", content); + LOG.error("No messages found in nihms email: {}", loggingContent); return; } processMessages(messageElements);