Package org.apache.james.mailbox

Examples of org.apache.james.mailbox.MessageManager


        List<MailboxPath> mailboxPathList = mailboxManager.list(mailboxSession);
       
        Assert.assertEquals(MockMailboxManager.EXPECTED_MAILBOXES_COUNT, mailboxPathList.size());
       
        for (MailboxPath mailboxPath: mailboxPathList) {
            MessageManager messageManager = mailboxManager.getMailbox(mailboxPath, mailboxSession);
            Assert.assertEquals(MockMailboxManager.MESSAGE_PER_MAILBOX_COUNT * multiplicationFactor, messageManager.getMessageCount(mailboxSession));
        }
       
        mailboxManager.endProcessingRequest(mailboxSession);
        mailboxManager.logout(mailboxSession, true);
       
View Full Code Here


     * @throws UnsupportedEncodingException
     */
    private void createMailbox(MailboxSession mailboxSession, MailboxPath mailboxPath) throws MailboxException, UnsupportedEncodingException {
        getMockMailboxManager().startProcessingRequest(mailboxSession);
        getMockMailboxManager().createMailbox(mailboxPath, mailboxSession);
        MessageManager messageManager = getMockMailboxManager().getMailbox(mailboxPath, mailboxSession);
        for (int j=0; j < MESSAGE_PER_MAILBOX_COUNT; j++) {
            messageManager.appendMessage(new ByteArrayInputStream(MockMail.MAIL_TEXT_PLAIN.getBytes("UTF-8")),
                    Calendar.getInstance().getTime(),
                    mailboxSession,
                    true,
                    new Flags(Flags.Flag.RECENT));
        }
View Full Code Here

                    try {
                        MailboxSession session = getMailboxManager().createSystemSession("test", LoggerFactory.getLogger("Test"));

                        getMailboxManager().startProcessingRequest(session);
                        MessageManager m = getMailboxManager().getMailbox(path, session);
                        Long uid =  m.appendMessage(new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), session, false, new Flags());
                        System.out.println("Append message with uid=" + uid);
                        if (uids.put(uid, new Object()) != null) {
                            fail.set(true);
                        }
                        getMailboxManager().endProcessingRequest(session);
View Full Code Here

                        final MailboxPath path = new MailboxPath(MailboxConstants.USER_NAMESPACE, user, destination);
                        try {
                            if ("INBOX".equalsIgnoreCase(destination) && !(mailboxManager.mailboxExists(path, session))) {
                                mailboxManager.createMailbox(path, session);
                            }
                            final MessageManager mailbox = mailboxManager.getMailbox(path, session);

                            if (mailbox == null) {
                                final String error = "Mailbox for user " + user + " was not found on this server.";
                                throw new MessagingException(error);
                            }

                            mailbox.appendMessage(new MimeMessageInputStream(mail), new Date(), session, true, null);
                        } catch (IOException e) {
                            throw new MessagingException("Failed to write mail message", e);
                        } finally {
                            session.close();
                            mailboxManager.logout(session, true);
View Full Code Here

        log(arg0.toString(), arg1);
      }
         
        });
        manager.startProcessingRequest(session);
        MessageManager mailbox = manager.getMailbox(new MailboxPath(MailboxConstants.USER_NAMESPACE,
                                            session.getUser().getUserName(), "INBOX"),
                                            session);
        Iterator<MessageResult> results = mailbox.getMessages(MessageRange.all(), new FetchGroupImpl(FetchGroup.MINIMAL), session);
       
        while (results.hasNext()) {
          size += results.next().getSize();
        }
        manager.endProcessingRequest(session);
View Full Code Here

                    final MailboxPath path = new MailboxPath(MailboxConstants.USER_NAMESPACE, user, destination);
                    try {
                        if ("INBOX".equalsIgnoreCase(destination) && !(mailboxManager.mailboxExists(path, session))) {
                            mailboxManager.createMailbox(path, session);
                        }
                        final MessageManager mailbox = mailboxManager.getMailbox(path, session);
                        if (mailbox == null) {
                            final String error = "Mailbox for user " + user + " was not found on this server.";
                            throw new MessagingException(error);
                        }

                        mailbox.appendMessage(new MimeMessageInputStream(mail), new Date(), session, true, null);
                    } finally {
                        session.close();
                        mailboxManager.logout(session, true);

                        // stop processing request
View Full Code Here

    protected void doProcess(FetchRequest request, final ImapSession session, String tag, ImapCommand command, final Responder responder) {
        final boolean useUids = request.isUseUids();
        final IdRange[] idSet = request.getIdSet();
        final FetchData fetch = request.getFetch();
        try {
            final MessageManager mailbox = getSelectedMailbox(session);

            if (mailbox == null) {
                throw new MailboxException("Session not in SELECTED state");
            }
View Full Code Here

        }
        MailboxSession mailboxSession = (MailboxSession) session.getState().get(POP3Session.MAILBOX_SESSION);

        List<Long> toBeRemoved = (List<Long>) session.getState().get(POP3Session.DELETED_UID_LIST);
        try {
            MessageManager mailbox = session.getUserMailbox();

            for (int i = 0; i < toBeRemoved.size(); i++) {
                MessageRange range = MessageRange.one(toBeRemoved.get(i));
                mailbox.setFlags(new Flags(Flags.Flag.DELETED), true, false, range, mailboxSession);
                mailbox.expunge(range, mailboxSession);
            }
            response = new POP3Response(POP3Response.OK_RESPONSE, "Apache James POP3 Server signing off.");
        } catch (Exception ex) {
            response = new POP3Response(POP3Response.ERR_RESPONSE, "Some deleted messages were not removed");
            session.getLogger().error("Some deleted messages were not removed", ex);
View Full Code Here

               
                // check if mailbox exists.. if not just create it
                if (mailboxManager.mailboxExists(mailboxPath, mSession) == false) {
                    mailboxManager.createMailbox(mailboxPath, mSession);
                }
                MessageManager mailbox = mailboxManager.getMailbox(mailboxPath, mSession);

                session.getState().put(POP3Session.MAILBOX_SESSION, mSession);
                session.setUserMailbox(mailbox);
                stat(session);
View Full Code Here

                    try {
                        MailboxSession session = getMailboxManager().createSystemSession("test", LoggerFactory.getLogger("Test"));

                        getMailboxManager().startProcessingRequest(session);
                        MessageManager m = getMailboxManager().getMailbox(path, session);
                       
                        System.out.println("Append message with uid=" + m.appendMessage(new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), session, false, new Flags()));
                        getMailboxManager().endProcessingRequest(session);
                        getMailboxManager().logout(session,false);
                    } catch (MailboxException e) {
                        e.printStackTrace();
                        fail.set(true);
View Full Code Here

TOP

Related Classes of org.apache.james.mailbox.MessageManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.