Package org.apache.james.imapserver.store

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


    {
        IdSet idSet = parser.set( request );
        String mailboxName = parser.mailbox( request );
        parser.endLine( request );

        ImapMailbox currentMailbox = session.getSelected();
        ImapMailbox toMailbox;
        try {
            toMailbox = getMailbox( mailboxName, session, true );
        }
        catch ( MailboxException e ) {
            e.setResponseCode( "TRYCREATE" );
View Full Code Here


        String mailboxName = parser.mailbox( request );
        parser.endLine( request );

        session.deselect();

        ImapMailbox mailbox = getMailbox( mailboxName, session, true );

        if ( !mailbox.isSelectable() ) {
            throw new MailboxException( "Nonselectable mailbox." );
        }

        boolean readOnly = ( this instanceof ExamineCommand );
        session.setSelected( mailbox, readOnly );

        response.flagsResponse( mailbox.getAllowedFlags() );
        response.existsResponse( mailbox.getMessageCount() );
        response.recentResponse( mailbox.getRecentCount() );
        response.okResponse( "UIDVALIDITY " + mailbox.getUidValidity(), null );

        int firstUnseen = mailbox.getFirstUnseen();
        if ( firstUnseen != 0 ) {
            int msnUnseen = mailbox.getMsn( firstUnseen );
            response.okResponse( "UNSEEN " + msnUnseen,
                                 "Message " + msnUnseen + " is the first unseen" );
        }
        else {
            response.okResponse( null, "No messages unseen" );
View Full Code Here

    {
        String mailboxName = parser.mailbox( request );
        StatusDataItems statusDataItems = parser.statusDataItems( request );
        parser.endLine( request );

        ImapMailbox mailbox = getMailbox( mailboxName, session, true );

        StringBuffer buffer = new StringBuffer( mailboxName );
        buffer.append( SP );
        buffer.append( "(" );

        if ( statusDataItems.messages ) {
            buffer.append( MESSAGES );
            buffer.append( SP );
            buffer.append( mailbox.getMessageCount() );
            buffer.append( SP );
        }

        if ( statusDataItems.recent ) {
            buffer.append( RECENT );
            buffer.append( SP );
            buffer.append( mailbox.getRecentCount() );
            buffer.append( SP );
        }

        if ( statusDataItems.uidNext ) {
            buffer.append( UIDNEXT );
            buffer.append( SP );
            buffer.append( mailbox.getUidNext() );
            buffer.append( SP );
        }

        if ( statusDataItems.uidValidity ) {
            buffer.append( UIDVALIDITY );
            buffer.append( SP );
            buffer.append( mailbox.getUidValidity() );
            buffer.append( SP );
        }

        if ( statusDataItems.unseen ) {
            buffer.append( UNSEEN );
            buffer.append( SP );
            buffer.append( mailbox.getUnseenCount() );
            buffer.append( SP );
        }
        if ( buffer.charAt( buffer.length() - 1 ) == ' ' ) {
            buffer.setLength( buffer.length() - 1 );
        }
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

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.