org.apache.james.mime4j.parser.AbstractContentHandler Java Examples

The following examples show how to use org.apache.james.mime4j.parser.AbstractContentHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AutomaticallySentMailDetectorImpl.java    From james-project with Apache License 2.0 5 votes vote down vote up
private AbstractContentHandler createMdnContentHandler(final ResultCollector resultCollector) {
    return new AbstractContentHandler() {
        @Override
        public void body(BodyDescriptor bodyDescriptor, InputStream inputStream) throws MimeException, IOException {
            if (bodyDescriptor.getMimeType().equalsIgnoreCase("message/disposition-notification")) {
                resultCollector.setResult(MDNReportParser.parse(inputStream, bodyDescriptor.getCharset())
                    .map(report -> report.getDispositionField().getSendingMode() == DispositionSendingMode.Automatic)
                    .getOrElse(() -> false));
            }
        }
    };
}