Package org.apache.james.mailbox

Examples of org.apache.james.mailbox.MailboxManager


    }

    @Override
    protected void doProcess(GetACLRequest message, ImapSession session, String tag, ImapCommand command, Responder responder) {

        final MailboxManager mailboxManager = getMailboxManager();
        final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
        final String mailboxName = message.getMailboxName();
        try {

            MessageManager messageManager = mailboxManager.getMailbox(buildFullPath(session, mailboxName), mailboxSession);

            /*
             * RFC 4314 section 6.
             * An implementation MUST make sure the ACL commands themselves do
             * not give information about mailboxes with appropriately
View Full Code Here


        }
    }
   
    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

        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) {
            if (session.getLog().isDebugEnabled()) {
                session.getLog().debug("Delete failed for mailbox " + mailboxPath + " as it not exist", e);
View Full Code Here

    }

    @Override
    protected void doProcess(DeleteACLRequest message, ImapSession session, String tag, ImapCommand command, Responder responder) {

        final MailboxManager mailboxManager = getMailboxManager();
        final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
        final String mailboxName = message.getMailboxName();
        final String identifier = message.getIdentifier();
        try {
           
            MessageManager messageManager = mailboxManager.getMailbox(buildFullPath(session, mailboxName), mailboxSession);

            /*
             * RFC 4314 section 6.
             * An implementation MUST make sure the ACL commands themselves do
             * not give information about mailboxes with appropriately
View Full Code Here

    }

    @Override
    protected void doProcess(ListRightsRequest message, ImapSession session, String tag, ImapCommand command, Responder responder) {

        final MailboxManager mailboxManager = getMailboxManager();
        final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
        final String mailboxName = message.getMailboxName();
        final String identifier = message.getIdentifier();
        try {

            MessageManager messageManager = mailboxManager.getMailbox(buildFullPath(session, mailboxName), mailboxSession);

            /*
             * RFC 4314 section 6.
             * An implementation MUST make sure the ACL commands themselves do
             * not give information about mailboxes with appropriately
View Full Code Here

    }

    @Override
    protected void doProcess(SetACLRequest message, ImapSession session, String tag, ImapCommand command, Responder responder) {

        final MailboxManager mailboxManager = getMailboxManager();
        final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
        final String mailboxName = message.getMailboxName();
        final String identifier = message.getIdentifier();
        try {
           
            /* parsing the rights is the the cheapest thing to begin with */
            EditMode editMode = MailboxACL.EditMode.REPLACE;
            String rights = message.getRights();
            if (rights != null && rights.length() > 0) {
                switch (rights.charAt(0)) {
                case MailboxACL.ADD_RIGHTS_MARKER:
                    editMode = MailboxACL.EditMode.ADD;
                    rights = rights.substring(1);
                    break;
                case MailboxACL.REMOVE_RIGHTS_MARKER:
                    editMode = MailboxACL.EditMode.REMOVE;
                    rights = rights.substring(1);
                    break;
                }
            }
            MailboxACLRights mailboxAclRights = new Rfc4314Rights(rights);

            MessageManager messageManager = mailboxManager.getMailbox(buildFullPath(session, mailboxName), mailboxSession);

            /*
             * RFC 4314 section 6.
             * An implementation MUST make sure the ACL commands themselves do
             * not give information about mailboxes with appropriately
View Full Code Here

    protected void doProcess(final IdleRequest message, final ImapSession session, final String tag, final ImapCommand command, final Responder responder) {

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

            final AtomicBoolean idleActive = new AtomicBoolean(true);
           
            session.pushLineHandler(new ImapLineHandler() {

                /**
                 * @see
                 * org.apache.james.imap.api.process.ImapLineHandler
                 * #onLine(org.apache.james.imap.api.process.ImapSession, byte[])
                 */
                public void onLine(ImapSession session, byte[] data) {
                    String line;
                    if (data.length > 2) {
                        line = new String(data, 0, data.length - 2);
                    } else {
                        line = "";
                    }

                    if (idleListener != null) {
                        try {
                            mailboxManager.removeListener(sm.getPath(), idleListener, mailboxSession);
                        } catch (MailboxException e) {
                            if (session.getLog().isInfoEnabled()) {
                                session.getLog().info("Unable to remove idle listener from mailbox", e);
                            }
                        }
View Full Code Here

        final Date datetime = request.getDatetime();
        final Flags flags = request.getFlags();
        try {

            final MailboxPath mailboxPath = buildFullPath(session, mailboxName);
            final MailboxManager mailboxManager = getMailboxManager();
            final MessageManager mailbox = mailboxManager.getMailbox(mailboxPath, ImapSessionUtils.getMailboxSession(session));
            appendToMailbox(messageIn, datetime, flags, session, tag, command, mailbox, responder, mailboxPath);
        } catch (MailboxNotFoundException e) {
            // consume message on exception
            consume(messageIn);
View Full Code Here

    private void appendToMailbox(final InputStream message, final Date datetime, final Flags flagsToBeSet, final ImapSession session, final String tag, final ImapCommand command, final MessageManager mailbox, Responder responder, final MailboxPath mailboxPath) {
        try {
            final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
            final SelectedMailbox selectedMailbox = session.getSelected();
            final MailboxManager mailboxManager = getMailboxManager();
            final boolean isSelectedMailbox = selectedMailbox != null && selectedMailbox.getPath().equals(mailboxPath);
            final long uid = mailbox.appendMessage(message, datetime, mailboxSession, !isSelectedMailbox, flagsToBeSet);
            if (isSelectedMailbox) {
                selectedMailbox.addRecent(uid);
            }

            // get folder UIDVALIDITY
            Long uidValidity = mailboxManager.getMailbox(mailboxPath, mailboxSession).getMetaData(false, mailboxSession, FetchGroup.NO_UNSEEN).getUidValidity();

            unsolicitedResponses(session, responder, false);

            // in case of MULTIAPPEND support we will push more then one UID
            // here
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.