Author: norman
Date: Fri Nov 18 10:54:16 2011
New Revision: 1203583

URL: http://svn.apache.org/viewvc?rev=1203583&view=rev
Log:
Add some more methods to mailbox to full-fill all needs for pop3. See 
PROTOCOLS-2

Added:
    
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/mailbox/AbstractMailbox.java
Modified:
    
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/RetrCmdHandler.java
    
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/TopCmdHandler.java
    
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/mailbox/Mailbox.java

Modified: 
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/RetrCmdHandler.java
URL: 
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/RetrCmdHandler.java?rev=1203583&r1=1203582&r2=1203583&view=diff
==============================================================================
--- 
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/RetrCmdHandler.java
 (original)
+++ 
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/RetrCmdHandler.java
 Fri Nov 18 10:54:16 2011
@@ -63,7 +63,7 @@ public class RetrCmdHandler implements C
                 Long uid = uidList.get(num - 1).getUid();
                 if (deletedUidList.contains(uid) == false) {
                        
-                    InputStream content = 
session.getUserMailbox().getMessageContent(uid);
+                    InputStream content = 
session.getUserMailbox().getMessage(uid);
 
                     if (content != null) {
 

Modified: 
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/TopCmdHandler.java
URL: 
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/TopCmdHandler.java?rev=1203583&r1=1203582&r2=1203583&view=diff
==============================================================================
--- 
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/TopCmdHandler.java
 (original)
+++ 
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/TopCmdHandler.java
 Fri Nov 18 10:54:16 2011
@@ -21,6 +21,7 @@ package org.apache.james.protocols.pop3.
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.SequenceInputStream;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -82,13 +83,10 @@ public class TopCmdHandler extends RetrC
                 Long uid = uidList.get(num - 1).getUid();
                 if (deletedUidList.contains(uid) == false) {
 
-                    InputStream content = 
session.getUserMailbox().getMessageContent(uid);
-
-                    if (content != null) {
-                        InputStream in = new CountingBodyInputStream(new 
ExtraDotInputStream(new CRLFTerminatedInputStream(content)), lines);
-
-
-                        response = new 
POP3StreamResponse(POP3Response.OK_RESPONSE, "Message follows", in);
+                    InputStream body = new CountingBodyInputStream(new 
ExtraDotInputStream(new 
CRLFTerminatedInputStream(session.getUserMailbox().getMessageBody(uid))), 
lines);
+                    InputStream headers = 
session.getUserMailbox().getMessageHeaders(uid);
+                    if (body != null && headers != null) {
+                        response = new 
POP3StreamResponse(POP3Response.OK_RESPONSE, "Message follows", new 
SequenceInputStream(headers, body));
                         return response;
 
                     } else {

Added: 
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/mailbox/AbstractMailbox.java
URL: 
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/mailbox/AbstractMailbox.java?rev=1203583&view=auto
==============================================================================
--- 
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/mailbox/AbstractMailbox.java
 (added)
+++ 
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/mailbox/AbstractMailbox.java
 Fri Nov 18 10:54:16 2011
@@ -0,0 +1,33 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.protocols.pop3.mailbox;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.SequenceInputStream;
+
+public abstract class AbstractMailbox implements Mailbox{
+
+       @Override
+       public InputStream getMessage(long uid) throws IOException {
+               return new SequenceInputStream(getMessageHeaders(uid), 
getMessageBody(uid));
+       }
+
+}

Modified: 
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/mailbox/Mailbox.java
URL: 
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/mailbox/Mailbox.java?rev=1203583&r1=1203582&r2=1203583&view=diff
==============================================================================
--- 
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/mailbox/Mailbox.java
 (original)
+++ 
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/mailbox/Mailbox.java
 Fri Nov 18 10:54:16 2011
@@ -31,13 +31,31 @@ import java.util.List;
 public interface Mailbox {
        
        /**
-        * Returns the message content as {@link InputStream} or 
<code>null</code> if no message can be found for the given <code>uid</code>
+        * Returns the message body as {@link InputStream} or <code>null</code> 
if no message can be found for the given <code>uid</code>
         * 
         * @param uid
-        * @return content
+        * @return body
         * @throws IOException
         */
-       InputStream getMessageContent(long uid) throws IOException;
+       InputStream getMessageBody(long uid) throws IOException;
+       
+       /**
+        * Returns the message headers as {@link InputStream} or 
<code>null</code> if no message can be found for the given <code>uid</code>
+        * 
+        * @param uid
+        * @return headers
+        * @throws IOException
+        */
+       InputStream getMessageHeaders(long uid) throws IOException;
+       
+       /**
+        * Return the full message (headers + body) as {@link InputStream} or 
<code>null</code> if no message can be found for the given <code>uid</code>
+        * @param uid
+        * @return message
+        * @throws IOException
+        */
+       InputStream getMessage(long uid) throws IOException;
+
        
        /**
         * Return a immutable {@link List} which holds the {@link 
MessageMetaData} for all messages in the {@link Mailbox}



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to