Search in sources :

Example 1 with RecipientStringTerm

use of jakarta.mail.search.RecipientStringTerm in project exist by eXist-db.

the class MessageListFunctions method parseRecipientTerm.

private SearchTerm parseRecipientTerm(Node terms) throws XPathException {
    SearchTerm st = null;
    String pattern = ((Element) terms).getAttribute("pattern");
    String type = ((Element) terms).getAttribute("recipientType");
    if (StringUtils.isEmpty(type)) {
        throw (new XPathException(this, "recipientType not specified for term with type: " + ((Element) terms).getAttribute("type")));
    }
    if (pattern != null && !pattern.isEmpty()) {
        Message.RecipientType rtype = null;
        if (type.equalsIgnoreCase("to")) {
            rtype = Message.RecipientType.TO;
        } else if (type.equalsIgnoreCase("cc")) {
            rtype = Message.RecipientType.CC;
        } else if (type.equalsIgnoreCase("bcc")) {
            rtype = Message.RecipientType.BCC;
        } else {
            throw (new XPathException(this, "Invalid recipientType: " + type + ", for term with type: " + ((Element) terms).getAttribute("type")));
        }
        st = new RecipientStringTerm(rtype, pattern);
    } else {
        throw (new XPathException(this, "Pattern attribute must be specified for term with type: " + ((Element) terms).getAttribute("type")));
    }
    return (st);
}
Also used : Message(jakarta.mail.Message) RecipientStringTerm(jakarta.mail.search.RecipientStringTerm) XPathException(org.exist.xquery.XPathException) Element(org.w3c.dom.Element) SearchTerm(jakarta.mail.search.SearchTerm)

Aggregations

Message (jakarta.mail.Message)1 RecipientStringTerm (jakarta.mail.search.RecipientStringTerm)1 SearchTerm (jakarta.mail.search.SearchTerm)1 XPathException (org.exist.xquery.XPathException)1 Element (org.w3c.dom.Element)1