Package org.apache.james.mailbox

Examples of org.apache.james.mailbox.MailboxManager


            boolean authFailure = false;
            if (userid == null) {
                authFailure = true;
            }
            if (authFailure == false) {
                final MailboxManager mailboxManager = getMailboxManager();
                try {
                    final MailboxSession mailboxSession = mailboxManager.login(userid, passwd, session.getLog());
                    session.authenticated();
                    session.setAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY, mailboxSession);
                    final MailboxPath inboxPath = buildFullPath(session, MailboxConstants.INBOX);
                    if (mailboxManager.mailboxExists(inboxPath, mailboxSession)) {
                        session.getLog().debug("INBOX exists. No need to create it.");
                    } else {
                        try {
                            session.getLog().debug("INBOX does not exist. Creating it.");
                            mailboxManager.createMailbox(inboxPath, mailboxSession);
                        } catch (MailboxExistsException e) {
                            session.getLog().debug("Mailbox created by concurrent call. Safe to ignore this exception.");
                        }
                    }
                    okComplete(command, tag, responder);
View Full Code Here


     */
    protected void doProcess(RenameRequest request, ImapSession session, String tag, ImapCommand command, Responder responder) {
        final MailboxPath existingPath = buildFullPath(session, request.getExistingName());
        final MailboxPath newPath = buildFullPath(session, request.getNewName());
        try {
            final MailboxManager mailboxManager = getMailboxManager();
            MailboxSession mailboxsession = ImapSessionUtils.getMailboxSession(session);
            mailboxManager.renameMailbox(existingPath, newPath, mailboxsession);

            if (existingPath.getName().equalsIgnoreCase(ImapConstants.INBOX_NAME) && mailboxManager.mailboxExists(existingPath, mailboxsession) == false) {
                mailboxManager.createMailbox(existingPath, mailboxsession);
            }
            okComplete(command, tag, responder);
            unsolicitedResponses(session, responder, false);
        } catch (MailboxExistsException e) {
            session.getLog().debug("Rename failed", e);
View Full Code Here

            responder.respond(response);
        }
    }

    private MessageManager getMailbox(final ImapSession session, final SelectedMailbox selected) throws MailboxException {
        final MailboxManager mailboxManager = getMailboxManager();
        final MessageManager mailbox = mailboxManager.getMailbox(selected.getPath(), ImapSessionUtils.getMailboxSession(session));
        return mailbox;
    }
View Full Code Here

        MessageManager result;
        final SelectedMailbox selectedMailbox = session.getSelected();
        if (selectedMailbox == null) {
            result = null;
        } else {
            final MailboxManager mailboxManager = getMailboxManager();
            result = mailboxManager.getMailbox(selectedMailbox.getPath(), ImapSessionUtils.getMailboxSession(session));
        }
        return result;
    }
View Full Code Here

     * org.apache.james.imap.api.process.ImapProcessor.Responder)
     */
    protected void doProcess(CreateRequest request, ImapSession session, String tag, ImapCommand command, Responder responder) {
        final MailboxPath mailboxPath = buildFullPath(session, request.getMailboxName());
        try {
            final MailboxManager mailboxManager = getMailboxManager();
            mailboxManager.createMailbox(mailboxPath, ImapSessionUtils.getMailboxSession(session));
            unsolicitedResponses(session, responder, false);
            okComplete(command, tag, responder);
        } catch (MailboxExistsException e) {
            session.getLog().debug("Create failed", e);
            no(command, tag, responder, HumanReadableText.MAILBOX_EXISTS);
View Full Code Here

        try {
            final SelectedMailbox selected = session.getSelected();
            if (selected != null && selected.getPath().equals(mailboxPath)) {
                session.deselect();
            }
            final MailboxManager mailboxManager = getMailboxManager();
            mailboxManager.deleteMailbox(mailboxPath, ImapSessionUtils.getMailboxSession(session));
            unsolicitedResponses(session, responder, false);
            okComplete(command, tag, responder);
        } catch (MailboxNotFoundException e) {
            session.getLog().debug("Delete failed", e);
            no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX);
View Full Code Here

        try {
            responder.respond(new ContinuationResponse(HumanReadableText.IDLING));
            unsolicitedResponses(session, responder, false);

            final MailboxManager mailboxManager = getMailboxManager();
            final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
            SelectedMailbox sm = session.getSelected();
            if (sm != null) {
                mailboxManager.addListener(sm.getPath(), new IdleMailboxListener(closed, session, responder), mailboxSession);
            }

            session.pushLineHandler(new ImapLineHandler() {

                /*
 
View Full Code Here

        final IdRange[] idSet = request.getIdSet();
        final boolean useUids = request.isUseUids();
        final SelectedMailbox currentMailbox = session.getSelected();
        try {
            final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
            final MailboxManager mailboxManager = getMailboxManager();
            final boolean mailboxExists = mailboxManager.mailboxExists(targetMailbox, mailboxSession);

            if (!mailboxExists) {
                no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX, ResponseCode.tryCreate());
            } else {

                final MessageManager mailbox = mailboxManager.getMailbox(targetMailbox, mailboxSession);

                List<IdRange> resultRanges = new ArrayList<IdRange>();
                for (int i = 0; i < idSet.length; i++) {
                    MessageRange messageSet = messageRange(currentMailbox, idSet[i], useUids);
                    if (messageSet != null) {
                        List<MessageRange> copiedUids = mailboxManager.copyMessages(messageSet, currentMailbox.getPath(), targetMailbox, mailboxSession);
                        for (MessageRange mr : copiedUids) {
                            // Set recent flag on copied message as this SHOULD be
                            // done.
                            // See RFC 3501 6.4.7. COPY Command
                            // See IMAP-287
View Full Code Here

        try {
            if (logger != null && logger.isDebugEnabled()) {
                logger.debug("Status called on mailbox named " + mailboxPath + " (" + mailboxPath + ")");
            }

            final MailboxManager mailboxManager = getMailboxManager();
            final MessageManager mailbox = mailboxManager.getMailbox(mailboxPath, ImapSessionUtils.getMailboxSession(session));
            final MessageManager.MetaData.FetchGroup fetchGroup;
            if (statusDataItems.isUnseen()) {
                fetchGroup = MessageManager.MetaData.FetchGroup.UNSEEN_COUNT;
            } else {
                fetchGroup = MessageManager.MetaData.FetchGroup.NO_UNSEEN;
View Full Code Here

        final ExistsResponse existsResponse = new ExistsResponse(messageCount);
        responder.respond(existsResponse);
    }

    private MessageManager.MetaData selectMailbox(MailboxPath mailboxPath, ImapSession session) throws MailboxException {
        final MailboxManager mailboxManager = getMailboxManager();
        final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
        final MessageManager mailbox = mailboxManager.getMailbox(mailboxPath, mailboxSession);

        final SelectedMailbox sessionMailbox;
        final SelectedMailbox currentMailbox = session.getSelected();
        if (currentMailbox == null || !currentMailbox.getPath().equals(mailboxPath)) {
            sessionMailbox = createNewSelectedMailbox(mailbox, mailboxSession, session, mailboxPath);
View Full Code Here

TOP

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

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.