Package org.apache.james.mailbox

Examples of org.apache.james.mailbox.MailboxSession


            Iterator<String> mailRepositoryIterator = mailRepository.list();

            String userName30 = convert23UserTo30(userName23);


            MailboxSession mailboxSession = mailboxManager.createSystemSession(userName30, log);
            MailboxPath mailboxPath = MailboxPath.inbox(mailboxSession);

            mailboxManager.startProcessingRequest(mailboxSession);
            try {
                mailboxManager.createMailbox(mailboxPath, mailboxSession);
View Full Code Here


                username = recipient.toString();
            } else {
                username = recipient.getLocalPart();
            }

            MailboxSession mailboxSession = mailboxManager.createSystemSession(username, new Slf4jLoggerAdapter(session.getLogger()));
            MailboxPath inbox = MailboxPath.inbox(mailboxSession);

            mailboxManager.startProcessingRequest(mailboxSession);

            // create inbox if not exist
View Full Code Here

    public static final String MAILBOX_USER_ATTRIBUTE_SESSION_KEY = "org.apache.james.api.imap.MAILBOX_USER_ATTRIBUTE_SESSION_KEY";

    public static final String MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY = "org.apache.james.api.imap.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY";

    public static MailboxSession getMailboxSession(final ImapSession session) {
        final MailboxSession result = (MailboxSession) session.getAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY);
        return result;
    }
View Full Code Here

        return result;
    }

    public static String getUserName(final ImapSession imapSession) {
        final String result;
        final MailboxSession mailboxSession = getMailboxSession(imapSession);
        if (imapSession == null) {
            result = null;
        } else {
            result = mailboxSession.getUser().getUserName();
        }
        return result;
    }
View Full Code Here

        no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX, StatusResponse.ResponseCode.tryCreate());
    }

    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) {
View Full Code Here

    }

    protected void doProcess(ExpungeRequest request, ImapSession session, String tag, ImapCommand command, Responder responder) {
        try {
            final MessageManager mailbox = getSelectedMailbox(session);
            final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);

            if (!mailbox.isWriteable(mailboxSession)) {
                no(command, tag, responder, HumanReadableText.MAILBOX_IS_READ_ONLY);
            } else {
                IdRange[] ranges = request.getUidSet();
View Full Code Here

                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.");
View Full Code Here

            final MessageManager mailbox = getSelectedMailbox(session);
            for (int i = 0; i < idSet.length; i++) {
                final SelectedMailbox selected = session.getSelected();
                MessageRange messageSet = messageRange(selected, idSet[i], useUids);
                if (messageSet != null) {
                    final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
                    final Map<Long, Flags> flagsByUid = mailbox.setFlags(flags, value, replace, messageSet, mailboxSession);
                    // As the STORE command is allowed to create a new "flag/keyword", we need to send a FLAGS and PERMANENTFLAGS response before the FETCH response
                    // if some new flag/keyword was used
                    // See IMAP-303
                    if (selected.hasNewApplicableFlags()) {
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);
            }
View Full Code Here

    private void addFlagsResponses(final ImapSession session, final SelectedMailbox selected, final ImapProcessor.Responder responder, boolean useUid) {
      
       
        try {
            final MessageManager mailbox = getMailbox(session, selected);
            final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);

            // Check ifwe need to send a FLAGS and PERMANENTFLAGS response before the FETCH response
            // This is the case if some new flag/keyword was used
            // See IMAP-303
            if (selected.hasNewApplicableFlags()) {
View Full Code Here

TOP

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

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.