use of org.apache.james.mime4j.MimeException in project k-9 by k9mail.
the class Address method parse.
/**
* Parse a comma separated list of addresses in RFC-822 format and return an
* array of Address objects.
*
* @param addressList
* @return An array of 0 or more Addresses.
*/
public static Address[] parse(String addressList) {
if (TextUtils.isEmpty(addressList)) {
return EMPTY_ADDRESS_ARRAY;
}
List<Address> addresses = new ArrayList<Address>();
try {
MailboxList parsedList = AddressBuilder.DEFAULT.parseAddressList(addressList).flatten();
for (int i = 0, count = parsedList.size(); i < count; i++) {
org.apache.james.mime4j.dom.address.Address address = parsedList.get(i);
if (address instanceof Mailbox) {
Mailbox mailbox = (Mailbox) address;
addresses.add(new Address(mailbox.getLocalPart() + "@" + mailbox.getDomain(), mailbox.getName(), false));
} else {
Log.e(LOG_TAG, "Unknown address type from Mime4J: " + address.getClass().toString());
}
}
} catch (MimeException pe) {
Log.e(LOG_TAG, "MimeException in Address.parse()", pe);
//but we do an silent failover : we just use the given string as name with empty address
addresses.add(new Address(null, addressList, false));
}
return addresses.toArray(EMPTY_ADDRESS_ARRAY);
}
use of org.apache.james.mime4j.MimeException in project k-9 by k9mail.
the class MessageHeaderParser method parse.
public static void parse(final Part part, InputStream headerInputStream) throws MessagingException {
MimeStreamParser parser = getMimeStreamParser();
parser.setContentHandler(new MessageHeaderParserContentHandler(part));
try {
parser.parse(headerInputStream);
} catch (MimeException me) {
throw new MessagingException("Error parsing headers", me);
} catch (IOException e) {
throw new MessagingException("I/O error parsing headers", e);
}
}
use of org.apache.james.mime4j.MimeException in project k-9 by k9mail.
the class MimeMessage method parse.
private void parse(InputStream in, boolean recurse) throws IOException, MessagingException {
mHeader.clear();
mFrom = null;
mTo = null;
mCc = null;
mBcc = null;
mReplyTo = null;
mMessageId = null;
mReferences = null;
mInReplyTo = null;
mSentDate = null;
mBody = null;
MimeConfig parserConfig = new MimeConfig();
// The default is a mere 10k
parserConfig.setMaxHeaderLen(-1);
// The default is 1000 characters. Some MUAs generate
parserConfig.setMaxLineLen(-1);
// REALLY long References: headers
// Disable the check for header count.
parserConfig.setMaxHeaderCount(-1);
MimeStreamParser parser = new MimeStreamParser(parserConfig);
parser.setContentHandler(new MimeMessageBuilder());
if (recurse) {
parser.setRecurse();
}
try {
parser.parse(new EOLConvertingInputStream(in));
} catch (MimeException me) {
throw new MessagingException(me.getMessage(), me);
}
}
use of org.apache.james.mime4j.MimeException in project tika by apache.
the class MailContentHandler method endBodyPart.
public void endBodyPart() throws MimeException {
try {
handler.endElement("p");
handler.endElement("div");
} catch (SAXException e) {
throw new MimeException(e);
}
}
Aggregations