Examples of ImapMailbox


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

    /**
     * Asserts that a mailbox with the supplied name doesn't exist.
     */
    private void assertNoMailbox( String name ) throws Exception
    {
        ImapMailbox mailbox = imapHost.getMailbox( user, name );
        assertNull( "Mailbox <" + name + "> should not exist.",
                    mailbox );
    }
View Full Code Here

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

        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

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

    {
        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

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

            throws ProtocolException, MailboxException
    {
        parser.endLine( request );

        if ( ! session.selectedIsReadOnly() ) {
            ImapMailbox mailbox = session.getSelected();
            ImapHost host = session.getHost();
            host.expunge( mailbox );
        }
        session.deselect();
View Full Code Here

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

                referenceRoot = "";
                removeUserPrefix = true;
            }

            // Get the mailbox for the reference name.
            ImapMailbox referenceMailbox = getMailbox( referenceRoot, session, false );

            // If it doesn't exist, act as though "" was passed for reference name.
            if ( referenceMailbox == null )
            {
                referenceMailbox = getMailbox( "", session, true );
                removeUserPrefix = true;
            }

            mailboxes = new ArrayList( 1 );
            mailboxes.add( referenceMailbox );
        }
        else {
            String searchPattern;

            // If the mailboxPattern is fully qualified, ignore the
            // reference name.
            if ( mailboxPattern.charAt( 0 ) == NAMESPACE_PREFIX_CHAR ) {
                searchPattern = mailboxPattern;
            }
            else {
                searchPattern = combineSearchTerms( referenceName, mailboxPattern );
            }

            // If the search pattern is relative, need to remove user prefix from results.
            removeUserPrefix = ( searchPattern.charAt(0) != NAMESPACE_PREFIX_CHAR );

            mailboxes = doList( session, searchPattern );
        }

        String personalNamespace = USER_NAMESPACE + HIERARCHY_DELIMITER_CHAR +
                session.getUser().getUserName();
        int prefixLength = personalNamespace.length();

        Iterator iterator = mailboxes.iterator();
        while ( iterator.hasNext() ) {
            ImapMailbox mailbox = ( ImapMailbox ) iterator.next();
            StringBuffer message = new StringBuffer( "(" );
            if ( !mailbox.isSelectable() ) {
                message.append( "\\Noselect" );
            }
            message.append( ") \"" );
            message.append( HIERARCHY_DELIMITER_CHAR );
            message.append( "\" " );

            String mailboxName = mailbox.getFullName();
            if ( removeUserPrefix ) {
                if ( mailboxName.length() <= prefixLength ) {
                    mailboxName = "";
                }
                else {
View Full Code Here

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

    {
        // Parse the search term from the request
        SearchTerm searchTerm = parser.searchTerm( request );
        parser.endLine( request );

        ImapMailbox mailbox = session.getSelected();
        long[] uids = session.getHost().search( searchTerm, mailbox );
        StringBuffer idList = new StringBuffer();
        for ( int i = 0; i < uids.length; i++ ) {
            if ( i > 0 ) {
                idList.append( SP );
            }
            long uid = uids[i];
            if ( useUids ) {
                idList.append( uid );
            }
            else {
                int msn = mailbox.getMsn( uid );
                idList.append( msn );
            }
        }

        response.commandResponse( this, idList.toString() );
View Full Code Here

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

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

        if ( session.selectedIsReadOnly() ) {
            response.commandFailed( this, "Mailbox selected read only." );
        }

        ImapMailbox mailbox = session.getSelected();
        ImapHost host = session.getHost();
        int[] msns = host.expunge( mailbox );
        for ( int i = 0; i < msns.length; i++ ) {
            int msn = msns[i];
            response.expungeResponse( msn );
View Full Code Here

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

    {
        IdSet idSet = parser.set( request );
        FetchRequest fetch = parser.fetchRequest( request );
        parser.endLine( request );

        ImapMailbox mailbox = session.getSelected();
        long[] uids = mailbox.getMessageUids();
        for ( int i = 0; i < uids.length; i++ ) {
            long uid = uids[i];
            int msn = mailbox.getMsn( uid );

            if ( ( useUids && idSet.includes( uid ) ) ||
                 ( !useUids && idSet.includes( msn ) ) )
            {
                SimpleImapMessage imapMessage = mailbox.getMessage( uid );
                String msgData = outputMessage( fetch, imapMessage );
                response.fetchResponse( msn, msgData );
            }
        }
View Full Code Here

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

        IdSet idSet = parser.set( request );
        StoreDirective directive = parser.storeDirective( request );
        MessageFlags flags = parser.flagList( request );
        parser.endLine( request );

        ImapMailbox mailbox = session.getSelected();
        long[] uids = mailbox.getMessageUids();
        for ( int i = 0; i < uids.length; i++ ) {
            long uid = uids[i];
            int msn = mailbox.getMsn( uid );

            if ( ( useUids && idSet.includes( uid ) ) ||
                 ( !useUids && idSet.includes( msn ) ) )
            {
                SimpleImapMessage imapMessage = mailbox.getMessage( uid );
                storeFlags( imapMessage, directive, flags );
                mailbox.updateMessage( imapMessage );

                if ( ! directive.isSilent() ) {
                    StringBuffer out = new StringBuffer( "FLAGS " );
                    out.append( imapMessage.getFlags().format() );
                    response.fetchResponse( msn, out.toString() );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.