Package org.apache.james.core

Examples of org.apache.james.core.MailImpl


        }

        while(true) {
            try {
                String key = spool.accept();
                MailImpl mail = spool.retrieve(key);
                // Retrieve can return null if the mail is no longer on the spool
                // (i.e. another thread has gotten to it first).
                // In this case we simply continue to the next key
                if (mail == null) {
                    continue;
                }
                if (getLogger().isDebugEnabled()) {
                    StringBuffer debugBuffer =
                        new StringBuffer(64)
                                .append("==== Begin processing mail ")
                                .append(mail.getName())
                                .append("====");
                    getLogger().debug(debugBuffer.toString());
                }
                process(mail);
                // Only remove an email from the spool is processing is
                // complete, or if it has no recipients
                if ((Mail.GHOST.equals(mail.getState())) ||
                    (mail.getRecipients() == null) ||
                    (mail.getRecipients().size() == 0)) {
                    spool.remove(key);
                    if (getLogger().isDebugEnabled()) {
                        StringBuffer debugBuffer =
                            new StringBuffer(64)
                                    .append("==== Removed from spool mail ")
                                    .append(mail.getName())
                                    .append("====");
                        getLogger().debug(debugBuffer.toString());
                    }
                }
                else {
View Full Code Here


                    //We have a lock on this object... let's grab the message
                    //  and see if it's a valid time.

                    // Retrieve can return null if the mail is no longer in the store.
                    // In this case we simply continue to the next key
                    MailImpl mail = retrieve(s);
                    if (mail == null) {
                        continue;
                    }
                    if (mail.getState().equals(Mail.ERROR)) {
                        //Test the time...
                        long timeToProcess = delay + mail.getLastUpdated().getTime();
                        if (System.currentTimeMillis() > timeToProcess) {
                            //We're ready to process this again
                            return s;
                        } else {
                            //We're not ready to process this.
View Full Code Here

     * Store a mail in a particular repository.
     *
     * @param mail the mail to process
     */
    public void service(Mail genericmail) {
        MailImpl mail = (MailImpl)genericmail;
        StringBuffer logBuffer =
            new StringBuffer(160)
                    .append("Storing mail ")
                    .append(mail.getName())
                    .append(" in ")
                    .append(repositoryPath);
        log(logBuffer.toString());
        repository.store(mail);
        if (!passThrough) {
            mail.setState(Mail.GHOST);
        }
    }
View Full Code Here

     * @throws MessagingException if an exception is caught while placing the mail
     *                            on the spool
     */
    public void sendMail(MailAddress sender, Collection recipients, MimeMessage message, String state)
            throws MessagingException {
        MailImpl mail = new MailImpl(getId(), sender, recipients, message);
        mail.setState(state);
        sendMail(mail);
    }
View Full Code Here

        // if headers do not contains minimum REQUIRED headers fields throw Exception
        if (!headers.isValid()) {
            throw new MessagingException("Some REQURED header field is missing. Invalid Message");
        }
        ByteArrayInputStream headersIn = new ByteArrayInputStream(headers.toByteArray());
        sendMail(new MailImpl(getId(), sender, recipients, new SequenceInputStream(headersIn, msg)));
    }
View Full Code Here

     *
     * @throws MessagingException if an exception is caught while placing the mail
     *                            on the spool
     */
    public void sendMail(Mail mail) throws MessagingException {
        MailImpl mailimpl = (MailImpl)mail;
        try {
            spool.store(mailimpl);
        } catch (Exception e) {
            try {
                spool.remove(mailimpl);
            } catch (Exception ignored) {
            }
            throw new MessagingException("Exception spooling message: " + e.getMessage(), e);
        }
        if (getLogger().isDebugEnabled()) {
            StringBuffer logBuffer =
                new StringBuffer(64)
                        .append("Mail ")
                        .append(mailimpl.getName())
                        .append(" pushed in spool");
            getLogger().debug(logBuffer.toString());
        }
    }
View Full Code Here

            }
        }

        Collection recipients = new HashSet();
        recipients.add(recipient);
        MailImpl mailImpl = new MailImpl(getId(), sender, recipients, message);
        MailRepository userInbox = getUserInbox(username);
        if (userInbox == null) {
            StringBuffer errorBuffer =
                new StringBuffer(128)
                    .append("The inbox for user ")
View Full Code Here

     *                            on the spool
     */
    public void sendMail( MailAddress sender, Collection recipients, MimeMessage message, String state )
            throws MessagingException
    {
        MailImpl mail = new MailImpl( getId(), sender, recipients, message );
        mail.setState( state );
        sendMail( mail );
    }
View Full Code Here

        // if headers do not contains minimum REQUIRED headers fields throw Exception
        if ( !headers.isValid() ) {
            throw new MessagingException( "Some REQURED header field is missing. Invalid Message" );
        }
        ByteArrayInputStream headersIn = new ByteArrayInputStream( headers.toByteArray() );
        sendMail( new MailImpl( getId(), sender, recipients, new SequenceInputStream( headersIn, msg ) ) );
    }
View Full Code Here

     * @throws MessagingException if an exception is caught while placing the mail
     *                            on the spool
     */
    public void sendMail( Mail mail ) throws MessagingException
    {
        MailImpl mailimpl = ( MailImpl ) mail;
        try {
            spool.store( mailimpl );
        }
        catch ( Exception e ) {
            try {
                spool.remove( mailimpl );
            }
            catch ( Exception ignored ) {
            }
            throw new MessagingException( "Exception spooling message: " + e.getMessage(), e );
        }
        if ( getLogger().isDebugEnabled() ) {
            StringBuffer logBuffer =
                    new StringBuffer( 64 )
                    .append( "Mail " )
                    .append( mailimpl.getName() )
                    .append( " pushed in spool" );
            getLogger().debug( logBuffer.toString() );
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.james.core.MailImpl

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.