Package org.apache.james.imapserver.store

Examples of org.apache.james.imapserver.store.ImapMailbox


            datetime = new Date();
        }
        MimeMessage message = parser.mimeMessage( request );
        parser.endLine( request );

        ImapMailbox mailbox = null;
        try {
            mailbox = getMailbox( mailboxName, session, true );
        }
        catch ( MailboxException e ) {
            e.setResponseCode( "TRYCREATE" );
            throw e;
        }

        mailbox.createMessage( message, flags, datetime );

        session.unsolicitedResponses( response );
        response.commandComplete( this );
    }
View Full Code Here


    /** @see ImapHost#getMailbox */
    public ImapMailbox getMailbox( User user, String mailboxName )
    {
        String name = getQualifiedMailboxName( user, mailboxName );
        ImapMailbox mailbox = store.getMailbox( name );
        return ( checkViewable( mailbox ) );
    }
View Full Code Here

    }

    public ImapMailbox getMailbox( User user, String mailboxName, boolean mustExist )
            throws MailboxException
    {
        ImapMailbox mailbox = getMailbox( user, mailboxName );
        if ( mustExist && mailbox == null )
        {
            throw new MailboxException( "No such mailbox." );
        }
        return mailbox;
View Full Code Here

    }

    /** @see ImapHost#createPrivateMailAccount */
    public void createPrivateMailAccount( User user ) throws MailboxException
    {
        ImapMailbox root = store.getMailbox( USER_NAMESPACE );
        ImapMailbox userRoot = store.createMailbox( root, user.getUserName(), false );
        store.createMailbox( userRoot, INBOX_NAME, true );
    }
View Full Code Here

        if ( tokens.countTokens() < 2 ) {
            throw new MailboxException( "Cannot create mailbox at namespace level." );
        }

        String namespaceRoot = tokens.nextToken();
        ImapMailbox mailbox = store.getMailbox( namespaceRoot );
        if ( mailbox == null ) {
            throw new MailboxException( "Invalid namespace." );
        }

        while ( tokens.hasMoreTokens() ) {
            // Get the next name from the list, and find the child
            String childName = tokens.nextToken();
            ImapMailbox child = store.getMailbox( mailbox, childName );
            // Create if neccessary
            if ( child == null ) {
                // TODO check permissions.
                boolean makeSelectable = ( !tokens.hasMoreTokens() );
                child = store.createMailbox( mailbox, childName, makeSelectable );
View Full Code Here

    /** @see ImapHost#deleteMailbox */
    public void deleteMailbox( User user, String mailboxName )
            throws MailboxException, AuthorizationException
    {
        ImapMailbox toDelete = getMailbox( user, mailboxName, true );

        if ( store.getChildren( toDelete ).isEmpty() ) {
            long[] uids = toDelete.getMessageUids();
            for ( int i = 0; i < uids.length; i++ ) {
                long uid = uids[i];
                SimpleImapMessage imapMessage = toDelete.getMessage( uid );
                toDelete.deleteMessage( imapMessage.getUid() );
            }
            store.deleteMailbox( toDelete );
        }
        else {
            if ( toDelete.isSelectable() ) {
                // TODO delete all messages.
                store.setSelectable( toDelete, false );
            }
            else {
                throw new MailboxException( "Can't delete a non-selectable mailbox with children." );
View Full Code Here

                               String oldMailboxName,
                               String newMailboxName )
            throws MailboxException, AuthorizationException
    {

        ImapMailbox existingMailbox = getMailbox( user, oldMailboxName, true );

        // TODO: check permissions.

        // Handle case where existing is INBOX
        //          - just create new folder, move all messages,
        //            and leave INBOX (with children) intact.
        String userInboxName = getQualifiedMailboxName( user, INBOX_NAME );
        if ( userInboxName.equals( existingMailbox.getFullName() ) ) {
            ImapMailbox newBox = createMailbox( user, newMailboxName );
            // TODO copy all messages from INBOX.
            return;
        }

        store.renameMailbox( existingMailbox, newMailboxName );
View Full Code Here

        ArrayList mailboxes = new ArrayList();
        String qualifiedPattern = getQualifiedMailboxName( user, mailboxPattern );

        Iterator iter = store.listMailboxes( qualifiedPattern ).iterator();
        while ( iter.hasNext() ) {
            ImapMailbox mailbox = ( ImapMailbox ) iter.next();

            // TODO check subscriptions.
            if ( subscribedOnly ) {
                if ( ! subscriptions.isSubscribed( user, mailbox ) ) {
                    // if not subscribed
View Full Code Here

    /** @see ImapHost#subscribe */
    public void subscribe( User user, String mailboxName )
            throws MailboxException
    {
        ImapMailbox mailbox = getMailbox( user, mailboxName, true );
        subscriptions.subscribe( user, mailbox );
    }
View Full Code Here

    /** @see ImapHost#unsubscribe */
    public void unsubscribe( User user, String mailboxName )
            throws MailboxException
    {
        ImapMailbox mailbox = getMailbox( user, mailboxName, true );
        subscriptions.unsubscribe( user, mailbox );
    }
View Full Code Here

TOP

Related Classes of org.apache.james.imapserver.store.ImapMailbox

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.