use of org.apache.jsieve.mail.SieveMailException in project zm-mailbox by Zimbra.
the class ZimbraMailAdapter method getMatchingHeaderFromAllParts.
/**
* Scans all MIME parts and returns the values of any headers that
* match the given name.
*/
public Set<String> getMatchingHeaderFromAllParts(String name) throws SieveMailException {
MimeMessage msg;
Set<String> values = new HashSet<String>();
try {
msg = handler.getMimeMessage();
for (MPartInfo partInfo : Mime.getParts(msg)) {
MimePart part = partInfo.getMimePart();
values.addAll(Arrays.asList(Mime.getHeaders(part, name)));
}
} catch (Exception e) {
throw new SieveMailException("Unable to match attachment headers.", e);
}
return values;
}
use of org.apache.jsieve.mail.SieveMailException in project zm-mailbox by Zimbra.
the class ZimbraMailAdapter method getHeaderNames.
@Override
public List<String> getHeaderNames() throws SieveMailException {
Set<String> headerNames = new HashSet<String>();
MimeMessage msg;
try {
msg = handler.getMimeMessage();
} catch (ServiceException e) {
ZimbraLog.filter.warn("Unable to get MimeMessage.", e);
return Collections.emptyList();
}
try {
@SuppressWarnings("unchecked") Enumeration<Header> allHeaders = msg.getAllHeaders();
while (allHeaders.hasMoreElements()) {
headerNames.add(allHeaders.nextElement().getName());
}
return new ArrayList<String>(headerNames);
} catch (MessagingException ex) {
throw new SieveMailException(ex);
}
}
Aggregations