james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r762688 - in /james/imap/trunk: api/src/main/java/org/apache/james/imap/api/ message/src/main/java/org/apache/james/imap/encode/ message/src/main/java/org/apache/james/imap/message/response/ message/src/test/java/org/apache/james/imap/encod...
Date Wed, 08 Apr 2009 04:10:04 GMT
Author: rdonkin
Date: Tue Apr  7 11:03:51 2009
New Revision: 762688

URL: http://svn.apache.org/viewvc?rev=762688&view=rev
Log:
Encode LIST responses with HasChildren HasNoChildren IMAP-73 https://issues.apache.org/jira/browse/IMAP-73

Modified:
    james/imap/trunk/api/src/main/java/org/apache/james/imap/api/ImapConstants.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListingEncodingUtils.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/AbstractListingResponse.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/LSubResponse.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ListResponse.java
    james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/LSubResponseEncoderTest.java
    james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/SearchResponseEncoderTest.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/ListProcessor.java
    james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/ListProcessorTest.java

Modified: james/imap/trunk/api/src/main/java/org/apache/james/imap/api/ImapConstants.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/api/src/main/java/org/apache/james/imap/api/ImapConstants.java?rev=762688&r1=762687&r2=762688&view=diff
==============================================================================
--- james/imap/trunk/api/src/main/java/org/apache/james/imap/api/ImapConstants.java (original)
+++ james/imap/trunk/api/src/main/java/org/apache/james/imap/api/ImapConstants.java Tue Apr
 7 11:03:51 2009
@@ -147,6 +147,10 @@
 
     public String RFC822_MESSAGE_ID = "Message-ID";
 
+    public String NAME_ATTRIBUTE_HAS_CHILDREN = "\\HasChildren";
+
+    public String NAME_ATTRIBUTE_HAS_NO_CHILDREN = "\\HasNoChildren";
+
     public static final String NAMESPACE_COMMAND_NAME = "NAMESPACE";
 
     public static final char BACK_SLASH = '\\';

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListingEncodingUtils.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListingEncodingUtils.java?rev=762688&r1=762687&r2=762688&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListingEncodingUtils.java
(original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListingEncodingUtils.java
Tue Apr  7 11:03:51 2009
@@ -26,6 +26,9 @@
 import org.apache.james.imap.api.ImapConstants;
 import org.apache.james.imap.message.response.AbstractListingResponse;
 
+/**
+ * Utilities for encoding LIST and LSUB responses.
+ */
 public class ListingEncodingUtils {
 
     public static void encodeListingResponse(final String responseTypeName,
@@ -40,10 +43,10 @@
                 name);
     }
 
-    private static List getNameAttributes(final AbstractListingResponse response) {
-        final List attributes;
+    private static List<String> getNameAttributes(final AbstractListingResponse response)
{
+        final List<String> attributes;
         if (response.isNameAttributed()) {
-            attributes = new ArrayList();
+            attributes = new ArrayList<String>();
             if (response.isNoInferiors()) {
                 attributes.add(ImapConstants.NAME_ATTRIBUTE_NOINFERIORS);
             }
@@ -56,6 +59,12 @@
             if (response.isUnmarked()) {
                 attributes.add(ImapConstants.NAME_ATTRIBUTE_UNMARKED);
             }
+            if (response.hasChildren()) {
+                attributes.add(ImapConstants.NAME_ATTRIBUTE_HAS_CHILDREN);
+            }
+            if (response.hasNoChildren()) {
+                attributes.add(ImapConstants.NAME_ATTRIBUTE_HAS_NO_CHILDREN);
+            }
         } else {
             attributes = null;
         }

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/AbstractListingResponse.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/AbstractListingResponse.java?rev=762688&r1=762687&r2=762688&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/AbstractListingResponse.java
(original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/AbstractListingResponse.java
Tue Apr  7 11:03:51 2009
@@ -24,6 +24,10 @@
  */
 public abstract class AbstractListingResponse {
 
+    private final boolean children;
+    
+    private final boolean noChildren;
+    
     private final boolean noInferiors;
 
     private final boolean noSelect;
@@ -38,13 +42,15 @@
 
     public AbstractListingResponse(final boolean noInferiors,
             final boolean noSelect, final boolean marked,
-            final boolean unmarked, final String hierarchyDelimiter,
-            final String name) {
+            final boolean unmarked, boolean hasChildren,
+            boolean hasNoChildren, final String hierarchyDelimiter, final String name) {
         super();
         this.noInferiors = noInferiors;
         this.noSelect = noSelect;
         this.marked = marked;
         this.unmarked = unmarked;
+        this.children = hasChildren;
+        this.noChildren = hasNoChildren;
         this.hierarchyDelimiter = hierarchyDelimiter;
         this.name = name;
     }
@@ -103,6 +109,23 @@
         return unmarked;
     }
 
+    
+    /**
+     * Is the <code>HasNoChildren</code> name attribute set?
+     * @return true if <code>HasNoChildren</code>, false otherwise
+     */
+    public boolean hasNoChildren() {
+        return noChildren;
+    }
+    
+    /**
+     * Is the <code>HasChildren</code> name attribute set?
+     * @return true if <code>HasChildren</code>, false otherwise
+     */
+    public boolean hasChildren() {
+        return children;
+    }
+    
     /**
      * Are any name attributes set?
      * 
@@ -110,30 +133,25 @@
      *         {@link #isMarked()} or {@link #isUnmarked(){
      */
     public final boolean isNameAttributed() {
-        return noInferiors || noSelect || marked || unmarked;
+        return noInferiors || noSelect || marked || unmarked || children || noChildren;
     }
 
-    /**
-     * @see java.lang.Object#hashCode()
-     */
+    @Override
     public int hashCode() {
         final int PRIME = 31;
         int result = 1;
-        result = PRIME
-                * result
-                + ((hierarchyDelimiter == null) ? 0 : hierarchyDelimiter
-                        .hashCode());
+        result = PRIME * result + (children ? 1231 : 1237);
+        result = PRIME * result + ((hierarchyDelimiter == null) ? 0 : hierarchyDelimiter.hashCode());
         result = PRIME * result + (marked ? 1231 : 1237);
         result = PRIME * result + ((name == null) ? 0 : name.hashCode());
+        result = PRIME * result + (noChildren ? 1231 : 1237);
         result = PRIME * result + (noInferiors ? 1231 : 1237);
         result = PRIME * result + (noSelect ? 1231 : 1237);
         result = PRIME * result + (unmarked ? 1231 : 1237);
         return result;
     }
 
-    /**
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
+    @Override
     public boolean equals(Object obj) {
         if (this == obj)
             return true;
@@ -142,6 +160,8 @@
         if (getClass() != obj.getClass())
             return false;
         final AbstractListingResponse other = (AbstractListingResponse) obj;
+        if (children != other.children)
+            return false;
         if (hierarchyDelimiter == null) {
             if (other.hierarchyDelimiter != null)
                 return false;
@@ -154,6 +174,8 @@
                 return false;
         } else if (!name.equals(other.name))
             return false;
+        if (noChildren != other.noChildren)
+            return false;
         if (noInferiors != other.noInferiors)
             return false;
         if (noSelect != other.noSelect)

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/LSubResponse.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/LSubResponse.java?rev=762688&r1=762687&r2=762688&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/LSubResponse.java
(original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/LSubResponse.java
Tue Apr  7 11:03:51 2009
@@ -27,6 +27,6 @@
         ImapResponseMessage {
     public LSubResponse(final String name, final String hierarchyDelimiter,
             final boolean noSelect) {
-        super(false, noSelect, false, false, hierarchyDelimiter, name);
+        super(false, noSelect, false, false, false, false, hierarchyDelimiter, name);
     }
 }

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ListResponse.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ListResponse.java?rev=762688&r1=762687&r2=762688&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ListResponse.java
(original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ListResponse.java
Tue Apr  7 11:03:51 2009
@@ -25,9 +25,10 @@
  */
 public final class ListResponse extends AbstractListingResponse implements
         ImapResponseMessage {
+    
     public ListResponse(final boolean noInferiors, final boolean noSelect,
             final boolean marked, final boolean unmarked,
-            final String hierarchyDelimiter, final String name) {
-        super(noInferiors, noSelect, marked, unmarked, hierarchyDelimiter, name);
+            boolean hasChildren, boolean hasNoChildren, final String hierarchyDelimiter,
final String name) {
+        super(noInferiors, noSelect, marked, unmarked, hasChildren, hasNoChildren, hierarchyDelimiter,
name);
     }
 }

Modified: james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/LSubResponseEncoderTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/LSubResponseEncoderTest.java?rev=762688&r1=762687&r2=762688&view=diff
==============================================================================
--- james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/LSubResponseEncoderTest.java
(original)
+++ james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/LSubResponseEncoderTest.java
Tue Apr  7 11:03:51 2009
@@ -53,7 +53,7 @@
 
     public void testIsAcceptable() {
         assertFalse(encoder.isAcceptable(new ListResponse(true, true, true,
-                true, ".", "name")));
+                true, false, false, ".", "name")));
         assertTrue(encoder.isAcceptable(new LSubResponse("name", ".", true)));
         assertFalse(encoder.isAcceptable(mock(ImapMessage.class)));
         assertFalse(encoder.isAcceptable(null));

Modified: james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/SearchResponseEncoderTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/SearchResponseEncoderTest.java?rev=762688&r1=762687&r2=762688&view=diff
==============================================================================
--- james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/SearchResponseEncoderTest.java
(original)
+++ james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/SearchResponseEncoderTest.java
Tue Apr  7 11:03:51 2009
@@ -53,7 +53,7 @@
 
     public void testIsAcceptable() {
         assertTrue(encoder.isAcceptable(new ListResponse(true, true, true,
-                true, ".", "name")));
+                true, false, false, ".", "name")));
         assertFalse(encoder.isAcceptable(new LSubResponse("name", ".", true)));
         assertFalse(encoder.isAcceptable(mock(ImapMessage.class)));
         assertFalse(encoder.isAcceptable(null));
@@ -67,7 +67,7 @@
                             with(same(".")), 
                             with(same("INBOX.name")));
         }});
-        encoder.encode(new ListResponse(false, false, false, false, ".", "INBOX.name"), composer,
new FakeImapSession());
+        encoder.encode(new ListResponse(false, false, false, false, false, false, ".", "INBOX.name"),
composer, new FakeImapSession());
     }
 
     public void testDelimiter() throws Exception {
@@ -78,7 +78,7 @@
                             with(same("@")), 
                             with(same("INBOX.name")));
         }});
-        encoder.encode(new ListResponse(false, false, false, false, "@", "INBOX.name"), composer,
new FakeImapSession());
+        encoder.encode(new ListResponse(false, false, false, false, false, false, "@", "INBOX.name"),
composer, new FakeImapSession());
     }
 
     public void testNoDelimiter() throws Exception {
@@ -89,7 +89,7 @@
                             with(aNull(String.class)), 
                             with(same("INBOX.name")));
         }});
-        encoder.encode(new ListResponse(false, false, false, false, null, "INBOX.name"),
composer, new FakeImapSession());
+        encoder.encode(new ListResponse(false, false, false, false, false, false, null, "INBOX.name"),
composer, new FakeImapSession());
     }
 
     public void testAllAttributes() throws Exception {
@@ -104,7 +104,7 @@
                             with(same(".")), 
                             with(same("INBOX.name")));
         }});
-        encoder.encode(new ListResponse(true, true, true, true, ".", "INBOX.name"), composer,
new FakeImapSession());
+        encoder.encode(new ListResponse(true, true, true, true, false, false, ".", "INBOX.name"),
composer, new FakeImapSession());
     }
 
     public void testNoInferiors() throws Exception {
@@ -116,7 +116,7 @@
                             with(same(".")), 
                             with(same("INBOX.name")));
         }});
-        encoder.encode(new ListResponse(true, false, false, false, ".", "INBOX.name"), composer,
new FakeImapSession());
+        encoder.encode(new ListResponse(true, false, false, false, false, false, ".", "INBOX.name"),
composer, new FakeImapSession());
     }
 
     public void testNoSelect() throws Exception {
@@ -128,7 +128,7 @@
                             with(same(".")), 
                             with(same("INBOX.name")));
         }});
-        encoder.encode(new ListResponse(false, true, false, false, ".", "INBOX.name"), composer,
new FakeImapSession());
+        encoder.encode(new ListResponse(false, true, false, false, false, false, ".", "INBOX.name"),
composer, new FakeImapSession());
     }
 
     public void testMarked() throws Exception {
@@ -140,7 +140,7 @@
                             with(same(".")), 
                             with(same("INBOX.name")));
         }});
-        encoder.encode(new ListResponse(false, false, true, false, ".", "INBOX.name"), composer,
new FakeImapSession());
+        encoder.encode(new ListResponse(false, false, true, false, false, false, ".", "INBOX.name"),
composer, new FakeImapSession());
     }
 
     public void testUnmarked() throws Exception {
@@ -152,6 +152,6 @@
                             with(same(".")), 
                             with(same("INBOX.name")));
         }});
-        encoder.encode(new ListResponse(false, false, false, true, ".", "INBOX.name"), composer,
new FakeImapSession());
+        encoder.encode(new ListResponse(false, false, false, true, false, false, ".", "INBOX.name"),
composer, new FakeImapSession());
     }
 }

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/ListProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/ListProcessor.java?rev=762688&r1=762687&r2=762688&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/ListProcessor.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/ListProcessor.java
Tue Apr  7 11:03:51 2009
@@ -65,7 +65,7 @@
             boolean noSelect, boolean marked, boolean unmarked,
             String hierarchyDelimiter, String mailboxName) {
         return new ListResponse(noInferior, noSelect, marked, unmarked,
-                hierarchyDelimiter, mailboxName);
+                false, false, hierarchyDelimiter, mailboxName);
     }
 
     protected final void doProcess(final String baseReferenceName,

Modified: james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/ListProcessorTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/ListProcessorTest.java?rev=762688&r1=762687&r2=762688&view=diff
==============================================================================
--- james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/ListProcessorTest.java
(original)
+++ james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/ListProcessorTest.java
Tue Apr  7 11:03:51 2009
@@ -72,7 +72,7 @@
             boolean marked, boolean unmarked, String hierarchyDelimiter,
             String mailboxName) {
         return new ListResponse(noinferior, noselect, marked, unmarked,
-                hierarchyDelimiter, mailboxName);
+                false, false, hierarchyDelimiter, mailboxName);
     }
 
     void setUpResult(final boolean isNoinferiors, final MailboxMetaData.Selectability selectability,



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message