Skip to content

Commit

Permalink
Cleanse nihms email content
Browse files Browse the repository at this point in the history
  • Loading branch information
rpoet-jh committed Dec 18, 2024
1 parent 1abcbb0 commit 1fa9ebd
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import jakarta.mail.internet.AddressException;
import jakarta.mail.internet.InternetAddress;
import jakarta.mail.internet.MimeMessage;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.pass.deposit.provider.nihms.NihmsAssembler;
import org.eclipse.pass.support.client.PassClient;
import org.eclipse.pass.support.client.PassClientSelector;
Expand Down Expand Up @@ -99,14 +100,15 @@ public void handleReceivedMail(MimeMessage receivedMessage) {
}
LOG.warn("Email is from Nihms");
String content = getHtmlText(receivedMessage);
LOG.warn("Nihms Email content:" + content);
String cleansedContent = StringUtils.normalizeSpace(content);
LOG.warn("Nihms Email content:" + cleansedContent);
if (Objects.isNull(content)) {
LOG.error("No HTML content found in nihms email: " + receivedMessage.getSubject());
return;
}
Elements messageElements = getMessageElements(content);
Elements messageElements = getMessageElements(cleansedContent);
if (messageElements.isEmpty()) {
LOG.error("No messages found in nihms email: " + content);
LOG.error("No messages found in nihms email: " + cleansedContent);
return;
}
processMessages(messageElements);
Expand Down

0 comments on commit 1fa9ebd

Please sign in to comment.