Package org.apache.james.core

Examples of org.apache.james.core.MailImpl


            if (argument == null) {
                responseString = OK_RESPONSE + " unique-id listing follows";
                writeLoggedFlushedResponse(responseString);
                int count = 0;
                for (Enumeration e = userMailbox.elements(); e.hasMoreElements(); count++) {
                    MailImpl mc = (MailImpl) e.nextElement();
                    if (mc != DELETED) {
                        StringBuffer responseBuffer =
                            new StringBuffer(64)
                                    .append(count)
                                    .append(" ")
                                    .append(mc.getName());
                        out.println(responseBuffer.toString());
                    }
                }
                out.println(".");
                out.flush();
            } else {
                int num = 0;
                try {
                    num = Integer.parseInt(argument);
                    MailImpl mc = (MailImpl) userMailbox.elementAt(num);
                    if (mc != DELETED) {
                        StringBuffer responseBuffer =
                            new StringBuffer(64)
                                    .append(OK_RESPONSE)
                                    .append(" ")
                                    .append(num)
                                    .append(" ")
                                    .append(mc.getName());
                        responseString = responseBuffer.toString();
                        writeLoggedFlushedResponse(responseString);
                    } else {
                        StringBuffer responseBuffer =
                            new StringBuffer(64)
View Full Code Here


                responseString = ERR_RESPONSE + " Usage: DELE [mail number]";
                writeLoggedFlushedResponse(responseString);
                return;
            }
            try {
                MailImpl mc = (MailImpl) userMailbox.elementAt(num);
                if (mc == DELETED) {
                    StringBuffer responseBuffer =
                        new StringBuffer(64)
                                .append(ERR_RESPONSE)
                                .append(" Message (")
View Full Code Here

                responseString = ERR_RESPONSE + " Usage: RETR [mail number]";
                writeLoggedFlushedResponse(responseString);
                return;
            }
            try {
                MailImpl mc = (MailImpl) userMailbox.elementAt(num);
                if (mc != DELETED) {
                    responseString = OK_RESPONSE + " Message follows";
                    writeLoggedFlushedResponse(responseString);
                    OutputStream nouts =
                            new ExtraDotOutputStream(outs);
                    nouts = new BytesWrittenResetOutputStream(nouts,
                                                              theWatchdog,
                                                              theConfigData.getResetLength());
                    mc.writeMessageTo(nouts);
                    nouts.flush();
                    // TODO: Is this an extra CRLF?
                    out.println();
                    out.println(".");
                    out.flush();
View Full Code Here

                responseString = ERR_RESPONSE + " Usage: TOP [mail number] [Line number]";
                writeLoggedFlushedResponse(responseString);
                return;
            }
            try {
                MailImpl mc = (MailImpl) userMailbox.elementAt(num);
                if (mc != DELETED) {
                    responseString = OK_RESPONSE + " Message follows";
                    writeLoggedFlushedResponse(responseString);
                    for (Enumeration e = mc.getMessage().getAllHeaderLines(); e.hasMoreElements(); ) {
                        out.println(e.nextElement());
                    }
                    out.println();
                    OutputStream nouts =
                            new ExtraDotOutputStream(outs);
                    nouts = new BytesWrittenResetOutputStream(nouts,
                                                              theWatchdog,
                                                              theConfigData.getResetLength());
                    mc.writeContentTo(nouts, lines);
                    nouts.flush();
                    out.println(".");
                    out.flush();
                } else {
                    StringBuffer responseBuffer =
View Full Code Here

            return;
        }
        List toBeRemoved =  ListUtils.subtract(backupUserMailbox, userMailbox);
        try {
            for (Iterator it = toBeRemoved.iterator(); it.hasNext(); ) {
                MailImpl mc = (MailImpl) it.next();
                userInbox.remove(mc.getName());
            }
            responseString = OK_RESPONSE + " Apache James POP3 Server signing off.";
            writeLoggedFlushedResponse(responseString);
        } catch (Exception ex) {
            responseString = ERR_RESPONSE + " Some deleted messages were not removed";
View Full Code Here

    public MailImpl retrieve(String key) {
        if ((DEEP_DEBUG) && (getLogger().isDebugEnabled())) {
            getLogger().debug("Retrieving mail: " + key);
        }
        try {
            MailImpl mc = null;
            try {
                mc = (MailImpl) or.get(key);
            } catch (RuntimeException re) {
                StringBuffer exceptionBuffer =
                    new StringBuffer(128)
                            .append("Exception retrieving mail: ")
                            .append(re.toString())
                            .append(", so we're deleting it... good riddance!");
                getLogger().error(exceptionBuffer.toString());
                remove(key);
                return null;
            }
            MimeMessageAvalonSource source = new MimeMessageAvalonSource(sr, destination, key);
            mc.setMessage(new MimeMessageWrapper(source));

            return mc;
        } catch (Exception me) {
            getLogger().error("Exception retrieving mail: " + me);
            throw new RuntimeException("Exception while retrieving mail: " + me.getMessage());
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

                throw new RuntimeException("Exception storing mail: " + e);
            }
        } else {
            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

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.