Search in sources :

Example 16 with MailStoreException

use of org.xwiki.mail.MailStoreException in project xwiki-platform by xwiki.

the class FileSystemMailContentStore method load.

@Override
public ExtendedMimeMessage load(Session session, String batchId, String uniqueMessageId) throws MailStoreException {
    File messageFile = null;
    try {
        messageFile = getMessageFile(batchId, uniqueMessageId);
        InputStream is = new FileInputStream(messageFile);
        return new ExtendedMimeMessage(session, is);
    } catch (Exception e) {
        throw new MailStoreException(String.format("Failed to load message (id [%s], batch id [%s]) from file [%s]", uniqueMessageId, batchId, messageFile), e);
    }
}
Also used : ExtendedMimeMessage(org.xwiki.mail.ExtendedMimeMessage) MailStoreException(org.xwiki.mail.MailStoreException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) File(java.io.File) FileInputStream(java.io.FileInputStream) MailStoreException(org.xwiki.mail.MailStoreException) InitializationException(org.xwiki.component.phase.InitializationException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

MailStoreException (org.xwiki.mail.MailStoreException)16 MailStatus (org.xwiki.mail.MailStatus)8 Test (org.junit.Test)7 MailContentStore (org.xwiki.mail.MailContentStore)6 XWikiContext (com.xpn.xwiki.XWikiContext)5 XWikiException (com.xpn.xwiki.XWikiException)4 XWikiHibernateBaseStore (com.xpn.xwiki.store.XWikiHibernateBaseStore)4 HibernateException (org.hibernate.HibernateException)4 Session (org.hibernate.Session)4 ExtendedMimeMessage (org.xwiki.mail.ExtendedMimeMessage)4 MailListener (org.xwiki.mail.MailListener)4 MailStatusStore (org.xwiki.mail.MailStatusStore)4 File (java.io.File)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 InitializationException (org.xwiki.component.phase.InitializationException)3 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 Session (javax.mail.Session)2 MimeMessage (javax.mail.internet.MimeMessage)2 Query (org.hibernate.Query)2