Package org.apache.james.util.stream

Examples of org.apache.james.util.stream.MessageStream


                Long uid = uidList.get(num - 1);
                if (deletedUidList.contains(uid) == false) {
                    FetchGroupImpl fetchGroup = new FetchGroupImpl(FetchGroup.BODY_CONTENT);
                    fetchGroup.or(FetchGroup.HEADERS);
                    Iterator<MessageResult> results = session.getUserMailbox().getMessages(MessageRange.one(uid), fetchGroup, mailboxSession);
                    MessageStream stream = new MessageStream();
                    OutputStream out = stream.getOutputStream();
                    OutputStream extraDotOut = new ExtraDotOutputStream(out);
                   
                    out.write((POP3Response.OK_RESPONSE + " Message follows\r\n").getBytes());
                    out.flush();
                    // response = new POP3Response(POP3Response.OK_RESPONSE,
                    // "Message follows");
                    try {
                        MessageResult result = results.next();

                        WritableByteChannel outChannel = Channels.newChannel(extraDotOut);

                        // write headers
                        Iterator<Header> headers = result.headers();
                        while (headers.hasNext()) {
                            headers.next().writeTo(outChannel);

                            // we need to write out the CRLF after each header
                            extraDotOut.write("\r\n".getBytes());

                        }
                        // headers and body are seperated by a CRLF
                        extraDotOut.write("\r\n".getBytes());

                        // write body
                        result.getBody().writeTo(Channels.newChannel(new CountingBodyOutputStream(extraDotOut, lines)));

                    } finally {
                        extraDotOut.flush();
                        // write a single dot to mark message as complete
                        out.write((".\r\n").getBytes());
                        out.flush();
                       
                        extraDotOut.close();
                        out.close();
                    }
                    session.writeStream(stream.getInputStream());

                    return null;

                } else {
                    StringBuilder responseBuffer = new StringBuilder(64).append("Message (").append(num).append(") already deleted.");
View Full Code Here


                MailboxSession mailboxSession = (MailboxSession) session.getState().get(POP3Session.MAILBOX_SESSION);
                Long uid = uidList.get(num - 1);
                if (deletedUidList.contains(uid) == false) {
                    Iterator<MessageResult> results = session.getUserMailbox().getMessages(MessageRange.one(uid), new FetchGroupImpl(FetchGroup.FULL_CONTENT), mailboxSession);
                    MessageStream stream = new MessageStream();
                    OutputStream out = stream.getOutputStream();
                    OutputStream extraDotOut = new ExtraDotOutputStream(out);
                   
                    out.write((POP3Response.OK_RESPONSE + " Message follows\r\n").getBytes());
                    out.flush();
                   
                    // response = new POP3Response(POP3Response.OK_RESPONSE,
                    // "Message follows");
                    try {
                        MessageResult result = results.next();
                        result.getFullContent().writeTo(Channels.newChannel(extraDotOut));

                    } finally {
                        extraDotOut.flush();
                       
                        // write a single dot to mark message as complete
                        out.write((".\r\n").getBytes());
                        out.flush();
                       
                        extraDotOut.close();
                        out.close();
                    }

                    session.writeStream(stream.getInputStream());

                    return null;
                } else {

                    StringBuilder responseBuffer = new StringBuilder(64).append("Message (").append(num).append(") already deleted.");
View Full Code Here

TOP

Related Classes of org.apache.james.util.stream.MessageStream

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.