You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by rd...@apache.org on 2008/03/30 12:04:50 UTC

svn commit: r642700 - in /james/server/trunk: experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ imap-api/src/main/java/org/apache/james/api/imap/display/ imap-api/src/main/java/org/apache/james/api/imap/m...

Author: rdonkin
Date: Sun Mar 30 03:04:40 2008
New Revision: 642700

URL: http://svn.apache.org/viewvc?rev=642700&view=rev
Log:
SELECT and EXAMINE processors now return stream of response. Removed deprecated response and encoder. No longer send additional unnecessary message when no messages are seen.

Added:
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/imap4rev1/AbstractMailboxSelectionRequest.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/response/imap4rev1/FlagsResponse.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/imap4rev1/FlagsResponseEncoder.java
Removed:
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/response/imap4rev1/legacy/ExamineAndSelectResponse.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/ExamineAndSelectResponseEncoder.java
Modified:
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendExamineInbox.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendExpunge.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendSelectInbox.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendToSelected.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BodyPartialFetch.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ComplexMail.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/Copy.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ExamineEmpty.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchHeaderFields.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchHeaderFieldsNot.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchMultipartAlternative.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchMultipartMixed.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchMultipartMixedComplex.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SearchAtoms.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SearchCombinations.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectAppend.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectEmpty.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectInbox.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectUnseen.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectedStateSetup.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/UidSearchAtoms.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/UidSearchCombinations.test
    james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java
    james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/MessageFlags.java
    james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponse.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/imap4rev1/ExamineRequest.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/imap4rev1/SelectRequest.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/DecoderUtils.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposer.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/base/ImapResponseComposerImpl.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/imap4rev1/StatusResponseEncoder.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/main/DefaultImapEncoderFactory.java
    james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/ImapResponseTest.java
    james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/AbstractMailboxSelectionProcessor.java
    james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/ExamineProcessor.java
    james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/SelectProcessor.java
    james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/commands/CommandParser.java

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendExamineInbox.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendExamineInbox.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendExamineInbox.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendExamineInbox.test Sun Mar 30 03:04:40 2008
@@ -48,7 +48,7 @@
 S: \* 2 EXISTS
 S: \* 2 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: (\* OK \[UNSEEN 1\] Message 1 is the first unseen)|(\* OK No messages unseen)
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: abcd OK \[READ-ONLY\] EXAMINE completed.
 
@@ -58,7 +58,7 @@
 S: \* 2 EXISTS
 S: \* 2 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: (\* OK \[UNSEEN 1\] Message 1 is the first unseen)|(\* OK No messages unseen)
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: abcd OK \[READ-ONLY\] EXAMINE completed.
 

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendExpunge.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendExpunge.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendExpunge.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendExpunge.test Sun Mar 30 03:04:40 2008
@@ -71,7 +71,7 @@
 S: \* 3 EXISTS
 S: \* \d+ RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: A006 OK \[READ-WRITE\] SELECT completed.
 

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendSelectInbox.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendSelectInbox.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendSelectInbox.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendSelectInbox.test Sun Mar 30 03:04:40 2008
@@ -48,7 +48,7 @@
 S: \* 2 EXISTS
 S: \* 2 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: (\* OK \[UNSEEN 1\] Message 1 is the first unseen)|(\* OK No messages unseen)
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: abcd OK \[READ-WRITE\] SELECT completed.
 
@@ -58,7 +58,7 @@
 S: \* 2 EXISTS
 S: \* 2 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: (\* OK \[UNSEEN 1\] Message 1 is the first unseen)|(\* OK No messages unseen)
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: abcd OK \[READ-WRITE\] SELECT completed.
 

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendToSelected.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendToSelected.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendToSelected.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/AppendToSelected.test Sun Mar 30 03:04:40 2008
@@ -39,7 +39,7 @@
 S: \* 1 EXISTS
 S: \* 1 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: a7 OK \[READ-WRITE\] SELECT completed.
 

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BodyPartialFetch.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BodyPartialFetch.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BodyPartialFetch.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BodyPartialFetch.test Sun Mar 30 03:04:40 2008
@@ -23,7 +23,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY (.)*\]
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: A3 OK \[READ-WRITE\] SELECT completed\.
 C: A4 APPEND testmailbox {765+}

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ComplexMail.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ComplexMail.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ComplexMail.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ComplexMail.test Sun Mar 30 03:04:40 2008
@@ -27,7 +27,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A3 OK \[READ-WRITE\] SELECT completed\.
 C: A20 APPEND testmailbox {14862+}

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/Copy.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/Copy.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/Copy.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/Copy.test Sun Mar 30 03:04:40 2008
@@ -47,7 +47,7 @@
 S: \* 3 EXISTS
 S: \* \d+ RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: (\* OK \[UNSEEN \d+\] Message \d+ is the first unseen)|(\* OK No messages unseen)
+S: \* OK \[UNSEEN \d+\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: a1 OK \[READ-WRITE\] SELECT completed.
 

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ExamineEmpty.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ExamineEmpty.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ExamineEmpty.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/ExamineEmpty.test Sun Mar 30 03:04:40 2008
@@ -31,7 +31,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: abcd OK \[READ-ONLY\] EXAMINE completed.
 
@@ -40,7 +39,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: abcd OK \[READ-ONLY\] EXAMINE completed.
 
@@ -49,7 +47,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: abcd OK \[READ-ONLY\] EXAMINE completed.
 

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchHeaderFields.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchHeaderFields.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchHeaderFields.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchHeaderFields.test Sun Mar 30 03:04:40 2008
@@ -24,7 +24,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A3 OK \[READ-WRITE\] SELECT completed\.
 C: A4 APPEND testmailbox {185+}
@@ -277,7 +276,7 @@
 S: \* 9 EXISTS
 S: \* 9 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A13 OK \[READ-WRITE\] SELECT completed\.
 C: A14 FETCH 1:* (BODY.PEEK[])
@@ -581,7 +580,7 @@
 S: \* 9 EXISTS
 S: \* 9 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK \[UNSEEN 1\] (.)*
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A16 OK \[READ-WRITE\] SELECT completed\.
 C: A17 DELETE testmailbox

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchHeaderFieldsNot.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchHeaderFieldsNot.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchHeaderFieldsNot.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchHeaderFieldsNot.test Sun Mar 30 03:04:40 2008
@@ -24,7 +24,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A3 OK \[READ-WRITE\] SELECT completed\.
 C: A4 APPEND testmailbox {185+}
@@ -277,7 +276,7 @@
 S: \* 9 EXISTS
 S: \* 9 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK \[UNSEEN 1\] (.)*
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A13 OK \[READ-WRITE\] SELECT completed\.
 C: A14 FETCH 1:* (BODY.PEEK[])
@@ -558,7 +557,7 @@
 S: \* 9 EXISTS
 S: \* 9 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK \[UNSEEN 1\] (.)*
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A16 OK \[READ-WRITE\] SELECT completed\.
 C: A17 DELETE testmailbox

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchMultipartAlternative.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchMultipartAlternative.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchMultipartAlternative.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchMultipartAlternative.test Sun Mar 30 03:04:40 2008
@@ -24,7 +24,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A3 OK \[READ-WRITE\] SELECT completed\.
 C: A4 APPEND testmailbox {666+}
@@ -152,7 +151,6 @@
 S: \* 1 EXISTS
 S: \* 1 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A12 OK \[READ-WRITE\] SELECT completed\.
 C: A13 DELETE testmailbox

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchMultipartMixed.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchMultipartMixed.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchMultipartMixed.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchMultipartMixed.test Sun Mar 30 03:04:40 2008
@@ -24,7 +24,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A3 OK \[READ-WRITE\] SELECT completed\.
 C: A4 APPEND testmailbox {765+}
@@ -70,7 +69,7 @@
 S: \* 1 EXISTS
 S: \* 1 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A5 OK \[READ-WRITE\] SELECT completed\.
 C: A6 FETCH 1 (BODY[])
@@ -179,7 +178,6 @@
 S: \* 1 EXISTS
 S: \* 1 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A13 OK \[READ-WRITE\] SELECT completed\.
 C: A14 DELETE testmailbox

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchMultipartMixedComplex.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchMultipartMixedComplex.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchMultipartMixedComplex.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/FetchMultipartMixedComplex.test Sun Mar 30 03:04:40 2008
@@ -24,7 +24,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A3 OK \[READ-WRITE\] SELECT completed\.
 C: A4 APPEND testmailbox {1767+}
@@ -127,7 +126,7 @@
 S: \* 1 EXISTS
 S: \* 1 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A5 OK \[READ-WRITE\] SELECT completed\.
 C: A6 FETCH 1 (BODY[])
@@ -564,7 +563,6 @@
 S: \* 1 EXISTS
 S: \* 1 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A26 OK \[READ-WRITE\] SELECT completed\.
 C: A27 DELETE testmailbox

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SearchAtoms.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SearchAtoms.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SearchAtoms.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SearchAtoms.test Sun Mar 30 03:04:40 2008
@@ -23,7 +23,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A3 OK \[READ-WRITE\] SELECT completed\.
 C: A4 APPEND testmailbox {185+}

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SearchCombinations.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SearchCombinations.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SearchCombinations.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SearchCombinations.test Sun Mar 30 03:04:40 2008
@@ -23,7 +23,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A3 OK \[READ-WRITE\] SELECT completed\.
 C: A4 APPEND testmailbox {185+}

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectAppend.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectAppend.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectAppend.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectAppend.test Sun Mar 30 03:04:40 2008
@@ -24,7 +24,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: 10 OK \[READ-WRITE\] SELECT completed.
 

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectEmpty.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectEmpty.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectEmpty.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectEmpty.test Sun Mar 30 03:04:40 2008
@@ -31,7 +31,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: abcd OK \[READ-WRITE\] SELECT completed.
 
@@ -41,7 +40,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK No messages unseen
 }
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: abcd OK \[READ-WRITE\] SELECT completed.
@@ -51,7 +49,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: abcd OK \[READ-WRITE\] SELECT completed.
 

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectInbox.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectInbox.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectInbox.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectInbox.test Sun Mar 30 03:04:40 2008
@@ -21,6 +21,5 @@
 S: \* \d+ EXISTS
 S: \* \d+ RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: (\* OK \[UNSEEN 1\] Message 1 is the first unseen)|(\* OK No messages unseen)
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: abcd OK \[READ-WRITE\] SELECT completed.

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectUnseen.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectUnseen.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectUnseen.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectUnseen.test Sun Mar 30 03:04:40 2008
@@ -27,7 +27,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: 10 OK \[READ-WRITE\] SELECT completed.
 
@@ -70,7 +69,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: 20 OK \[READ-WRITE\] SELECT completed.
 
@@ -79,7 +77,7 @@
 S: \* 2 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: 21 OK \[READ-WRITE\] SELECT completed.
 
@@ -102,7 +100,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: 30 OK \[READ-WRITE\] SELECT completed.
 
@@ -111,7 +108,7 @@
 S: \* 2 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK \[UNSEEN 2\] Message 2 is the first unseen
+S: \* OK \[UNSEEN 2\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: 40 OK \[READ-WRITE\] SELECT completed.
 

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectedStateSetup.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectedStateSetup.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectedStateSetup.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/SelectedStateSetup.test Sun Mar 30 03:04:40 2008
@@ -76,7 +76,7 @@
 S: \* 4 EXISTS
 S: \* 4 RECENT
 S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
+S: \* OK \[UNSEEN 1\]
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
 S: a1 OK \[READ-WRITE\] SELECT completed.
 

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/UidSearchAtoms.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/UidSearchAtoms.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/UidSearchAtoms.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/UidSearchAtoms.test Sun Mar 30 03:04:40 2008
@@ -23,7 +23,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A3 OK \[READ-WRITE\] SELECT completed\.
 C: A4 APPEND testmailbox {185+}

Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/UidSearchCombinations.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/UidSearchCombinations.test?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/UidSearchCombinations.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/UidSearchCombinations.test Sun Mar 30 03:04:40 2008
@@ -23,7 +23,6 @@
 S: \* 0 EXISTS
 S: \* 0 RECENT
 S: \* OK \[UIDVALIDITY (.)*
-S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\](.)*
 S: A3 OK \[READ-WRITE\] SELECT completed\.
 C: A4 APPEND testmailbox {185+}

Modified: james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java (original)
+++ james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java Sun Mar 30 03:04:40 2008
@@ -25,7 +25,23 @@
  * Keys human response text that may be displayed to the user. 
  */
 public class HumanReadableTextKey {
+    
+    public static final HumanReadableTextKey SELECT
+    = new HumanReadableTextKey("org.apache.james.imap.SELECT", 
+        "completed.");
+    
+    public static final HumanReadableTextKey UNSEEN
+    = new HumanReadableTextKey("org.apache.james.imap.UNSEEN", 
+        "");
+    
+    public static final HumanReadableTextKey UID_VALIDITY 
+    = new HumanReadableTextKey("org.apache.james.imap.UID_VALIDITY", 
+    "");
 
+    public static final HumanReadableTextKey PERMANENT_FLAGS 
+    = new HumanReadableTextKey("org.apache.james.imap.PERMANENT_FLAGS", 
+    ""); 
+    
     public static final HumanReadableTextKey GENERIC_LSUB_FAILURE 
     = new HumanReadableTextKey("org.apache.james.imap.GENERIC_SUBSCRIPTION_FAILURE", 
     "Cannot list subscriptions."); 

Modified: james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/MessageFlags.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/MessageFlags.java?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/MessageFlags.java (original)
+++ james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/MessageFlags.java Sun Mar 30 03:04:40 2008
@@ -19,6 +19,9 @@
 
 package org.apache.james.api.imap.message;
 
+import java.util.ArrayList;
+import java.util.Collection;
+
 import javax.mail.Flags;
 
 
@@ -30,6 +33,13 @@
  */
 public class MessageFlags
 {
+    public static final String SEEN_OUTPUT_CAPITALISED = "\\Seen";
+    public static final String RECENT_OUTPUT_CAPITALISED = "\\Recent";
+    public static final String FLAGGED_OUTPUT_CAPITALISED = "\\Flagged";
+    public static final String DRAFT_OUTPUT_CAPITALISED = "\\Draft";
+    public static final String DELETED_OUTPUT_CAPITALISED = "\\Deleted";
+    public static final String ANSWERED_OUTPUT_CAPITALISED = "\\Answered";
+    
     public static final Flags ALL_FLAGS = new Flags();
     static {
         ALL_FLAGS.add(Flags.Flag.ANSWERED);
@@ -40,13 +50,41 @@
         ALL_FLAGS.add(Flags.Flag.SEEN);
     }
     
-    public static final String ANSWERED = "\\ANSWERED";
-    public static final String DELETED = "\\DELETED";
-    public static final String DRAFT = "\\DRAFT";
-    public static final String FLAGGED = "\\FLAGGED";
-    public static final String SEEN = "\\SEEN";
-    public static final String RECENT = "\\RECENT";
+    public static final String ANSWERED_ALL_CAPS = "\\ANSWERED";
+    public static final String DELETED_ALL_CAPS = "\\DELETED";
+    public static final String DRAFT_ALL_CAPS = "\\DRAFT";
+    public static final String FLAGGED_ALL_CAPS = "\\FLAGGED";
+    public static final String SEEN_ALL_CAPS = "\\SEEN";
+    public static final String RECENT_ALL_CAPS = "\\RECENT";
 
+    /**
+     * Returns IMAP formatted String naming flags.
+     * @return <code>Collection</code> of <code>String</code>'s
+     * naming the flags.
+     */
+    public static Collection names(Flags flags) {
+        final Collection results = new ArrayList();
+        if ( flags.contains(Flags.Flag.ANSWERED) ) {
+            results.add( ANSWERED_OUTPUT_CAPITALISED );
+        }
+        if ( flags.contains(Flags.Flag.DELETED) ) {
+            results.add( DELETED_OUTPUT_CAPITALISED );
+        }
+        if ( flags.contains(Flags.Flag.DRAFT) ) {
+            results.add( DRAFT_OUTPUT_CAPITALISED );
+        }
+        if ( flags.contains(Flags.Flag.FLAGGED) ) {
+            results.add( FLAGGED_OUTPUT_CAPITALISED );
+        }
+        if ( flags.contains(Flags.Flag.RECENT) ) {
+            results.add( RECENT_OUTPUT_CAPITALISED );
+        }
+        if ( flags.contains(Flags.Flag.SEEN) ) {
+            results.add( SEEN_OUTPUT_CAPITALISED );
+        }
+        return results;
+    }
+    
     /**
      * Returns IMAP formatted String of MessageFlags for named user
      */

Modified: james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponse.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponse.java?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponse.java (original)
+++ james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponse.java Sun Mar 30 03:04:40 2008
@@ -22,8 +22,11 @@
 import java.util.Collection;
 import java.util.Collections;
 
+import javax.mail.Flags;
+
 import org.apache.james.api.imap.ImapCommand;
 import org.apache.james.api.imap.display.HumanReadableTextKey;
+import org.apache.james.api.imap.message.MessageFlags;
 import org.apache.james.api.imap.message.response.ImapResponseMessage;
 
 /**
@@ -170,8 +173,8 @@
          * @param flagNames <code>Collection<String></code> containing flag names
          * @return <code>ResponseCode</code>, not null
          */
-        public static final ResponseCode permanentFlags(Collection flagNames) {
-            return new ResponseCode("PERMANENTFLAGS", flagNames);
+        public static final ResponseCode permanentFlags(Flags flags) {
+            return new ResponseCode("PERMANENTFLAGS", MessageFlags.names(flags));
         }
         
         /**
@@ -203,7 +206,7 @@
          * @param uid positive non-zero integer
          * @return <code>ResponseCode</code>, not null
          */
-        public static final ResponseCode uidValidity(int uid) {
+        public static final ResponseCode uidValidity(long uid) {
             return new ResponseCode("UIDVALIDITY", uid);
         }
         
@@ -243,13 +246,13 @@
         
         private final String code;
         private final Collection parameters;
-        private final int number;
+        private final long number;
 
         private ResponseCode(final String code) {
             this(code, Collections.EMPTY_LIST, 0);
         }
         
-        private ResponseCode(final String code, final int number) {
+        private ResponseCode(final String code, final long number) {
             this(code, Collections.EMPTY_LIST, number);
         }
         
@@ -257,7 +260,7 @@
             this(code, parameters, 0);
         }
         
-        private ResponseCode(final String code, final Collection parameters, final int number) {
+        private ResponseCode(final String code, final Collection parameters, final long number) {
             super();
             this.code = code;
             this.parameters = parameters;
@@ -273,7 +276,7 @@
          * @return the number, 
          * or zero if no number has been set
          */
-        public final int getNumber() {
+        public final long getNumber() {
             return number;
         }
 
@@ -290,7 +293,7 @@
             final int PRIME = 31;
             int result = 1;
             result = PRIME * result + ((code == null) ? 0 : code.hashCode());
-            result = PRIME * result + number;
+            result = PRIME * result + (int) (number ^ (number >>> 32));
             result = PRIME * result + ((parameters == null) ? 0 : parameters.hashCode());
             return result;
         }

Added: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/imap4rev1/AbstractMailboxSelectionRequest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/imap4rev1/AbstractMailboxSelectionRequest.java?rev=642700&view=auto
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/imap4rev1/AbstractMailboxSelectionRequest.java (added)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/imap4rev1/AbstractMailboxSelectionRequest.java Sun Mar 30 03:04:40 2008
@@ -0,0 +1,39 @@
+/****************************************************************
+ * 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.imap.message.request.imap4rev1;
+
+import org.apache.james.api.imap.ImapCommand;
+import org.apache.james.imap.message.request.base.AbstractImapRequest;
+
+public abstract class AbstractMailboxSelectionRequest extends
+        AbstractImapRequest {
+    private final String mailboxName;
+
+    public AbstractMailboxSelectionRequest(final ImapCommand command, final String mailboxName,
+            final String tag) {
+        super(tag, command);
+        this.mailboxName = mailboxName;
+    }
+
+    public final String getMailboxName() {
+        return mailboxName;
+    }
+
+}

Modified: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/imap4rev1/ExamineRequest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/imap4rev1/ExamineRequest.java?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/imap4rev1/ExamineRequest.java (original)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/imap4rev1/ExamineRequest.java Sun Mar 30 03:04:40 2008
@@ -19,20 +19,11 @@
 package org.apache.james.imap.message.request.imap4rev1;
 
 import org.apache.james.api.imap.ImapCommand;
-import org.apache.james.imap.message.request.base.AbstractImapRequest;
-
-public class ExamineRequest extends AbstractImapRequest {
-
-    private final String mailboxName;
 
+public class ExamineRequest extends AbstractMailboxSelectionRequest {
     public ExamineRequest(final ImapCommand command, final String mailboxName,
             final String tag) {
-        super(tag, command);
-        this.mailboxName = mailboxName;
-    }
-
-    public final String getMailboxName() {
-        return mailboxName;
+        super(command, mailboxName, tag);
     }
 
 }

Modified: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/imap4rev1/SelectRequest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/imap4rev1/SelectRequest.java?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/imap4rev1/SelectRequest.java (original)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/imap4rev1/SelectRequest.java Sun Mar 30 03:04:40 2008
@@ -19,19 +19,11 @@
 package org.apache.james.imap.message.request.imap4rev1;
 
 import org.apache.james.api.imap.ImapCommand;
-import org.apache.james.imap.message.request.base.AbstractImapRequest;
 
-public class SelectRequest extends AbstractImapRequest {
-    private final String mailboxName;
+public class SelectRequest extends AbstractMailboxSelectionRequest {
 
     public SelectRequest(final ImapCommand command, final String mailboxName,
             final String tag) {
-        super(tag, command);
-        this.mailboxName = mailboxName;
+        super(command, mailboxName, tag);
     }
-
-    public final String getMailboxName() {
-        return mailboxName;
-    }
-
 }

Added: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/response/imap4rev1/FlagsResponse.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/response/imap4rev1/FlagsResponse.java?rev=642700&view=auto
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/response/imap4rev1/FlagsResponse.java (added)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/response/imap4rev1/FlagsResponse.java Sun Mar 30 03:04:40 2008
@@ -0,0 +1,69 @@
+/****************************************************************
+ * 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.imap.message.response.imap4rev1;
+
+import javax.mail.Flags;
+
+import org.apache.james.api.imap.message.response.ImapResponseMessage;
+
+/**
+ * Carries a RFC3501 <code>Flags</code> response.
+ */
+public class FlagsResponse implements ImapResponseMessage {
+    private final Flags flags;
+
+    public FlagsResponse(final Flags flags) {
+        super();
+        this.flags = flags;
+    }
+
+    public String toString() {
+        return "Flags: " + flags;
+    }
+    
+    public Flags getFlags() {
+        return flags;
+    }
+    
+    public int hashCode() {
+        final int PRIME = 31;
+        int result = 1;
+        result = PRIME * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        final FlagsResponse other = (FlagsResponse) obj;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+    
+    
+}

Modified: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/DecoderUtils.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/DecoderUtils.java?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/DecoderUtils.java (original)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/DecoderUtils.java Sun Mar 30 03:04:40 2008
@@ -53,22 +53,22 @@
                                         | JUL_BIT | AUG_BIT | SEP_BIT | OCT_BIT | NOV_BIT | DEC_BIT;
     
     public static void setFlag( final String flagString, final Flags flags )  {
-        if ( flagString.equalsIgnoreCase( MessageFlags.ANSWERED ) ) {
+        if ( flagString.equalsIgnoreCase( MessageFlags.ANSWERED_ALL_CAPS ) ) {
             flags.add(Flags.Flag.ANSWERED);
         }
-        else if ( flagString.equalsIgnoreCase( MessageFlags.DELETED ) ) {
+        else if ( flagString.equalsIgnoreCase( MessageFlags.DELETED_ALL_CAPS ) ) {
             flags.add(Flags.Flag.DELETED);
         }
-        else if ( flagString.equalsIgnoreCase( MessageFlags.DRAFT ) ) {
+        else if ( flagString.equalsIgnoreCase( MessageFlags.DRAFT_ALL_CAPS ) ) {
             flags.add(Flags.Flag.DRAFT);
         }
-        else if ( flagString.equalsIgnoreCase( MessageFlags.FLAGGED ) ) {
+        else if ( flagString.equalsIgnoreCase( MessageFlags.FLAGGED_ALL_CAPS ) ) {
             flags.add(Flags.Flag.FLAGGED);
         }
-        else if ( flagString.equalsIgnoreCase( MessageFlags.SEEN ) ) {
+        else if ( flagString.equalsIgnoreCase( MessageFlags.SEEN_ALL_CAPS ) ) {
             flags.add(Flags.Flag.SEEN);
         } else {
-            if ( flagString.equalsIgnoreCase( MessageFlags.RECENT) ) {
+            if ( flagString.equalsIgnoreCase( MessageFlags.RECENT_ALL_CAPS) ) {
                 // RFC3501 specifically excludes /Recent 
                 // The /Recent flag should be set automatically by the server
             } else {

Modified: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposer.java?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposer.java (original)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposer.java Sun Mar 30 03:04:40 2008
@@ -262,11 +262,7 @@
 
     public abstract void message(final long number) throws IOException;
 
-    public abstract void responseCode(final String responseCode) throws IOException;
-
     public abstract void end() throws IOException;
-
-    public abstract void permanentFlagsResponse(Flags flags) throws IOException;
 
     public abstract void tag(String tag) throws IOException;
 

Modified: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/base/ImapResponseComposerImpl.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/base/ImapResponseComposerImpl.java?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/base/ImapResponseComposerImpl.java (original)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/base/ImapResponseComposerImpl.java Sun Mar 30 03:04:40 2008
@@ -30,7 +30,6 @@
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.james.api.imap.ImapCommand;
 import org.apache.james.api.imap.ImapConstants;
-import org.apache.james.api.imap.message.MessageFlags;
 import org.apache.james.imap.message.response.imap4rev1.Literal;
 import org.apache.james.imapserver.codec.encode.ImapResponseComposer;
 import org.apache.james.imapserver.codec.encode.ImapResponseWriter;
@@ -310,7 +309,7 @@
      * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#responseCode(java.lang.String)
      */
     public void responseCode(final String responseCode) throws IOException {
-        if (responseCode != null) {
+        if (responseCode != null && !"".equals(responseCode)) {
             writer.responseCode(responseCode);
         }
     }
@@ -325,17 +324,6 @@
 
     /**
      * @throws IOException 
-     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#permanentFlagsResponse(javax.mail.Flags)
-     */
-    public void permanentFlagsResponse(Flags flags) throws IOException {
-        untagged();
-        message(OK);
-        responseCode("PERMANENTFLAGS " + MessageFlags.format(flags));
-        end();
-    }
-
-    /**
-     * @throws IOException 
      * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#tag(java.lang.String)
      */
     public void tag(String tag) throws IOException {
@@ -373,7 +361,7 @@
         if (command != null) {
             commandName(command);
         }
-        if (text != null) {
+        if (text != null && !"".equals(text)) {
             message(text);
         }
         end();

Added: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/imap4rev1/FlagsResponseEncoder.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/imap4rev1/FlagsResponseEncoder.java?rev=642700&view=auto
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/imap4rev1/FlagsResponseEncoder.java (added)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/imap4rev1/FlagsResponseEncoder.java Sun Mar 30 03:04:40 2008
@@ -0,0 +1,47 @@
+/****************************************************************
+ * 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.imapserver.codec.encode.imap4rev1;
+
+import java.io.IOException;
+
+import javax.mail.Flags;
+
+import org.apache.james.api.imap.ImapMessage;
+import org.apache.james.imap.message.response.imap4rev1.FlagsResponse;
+import org.apache.james.imapserver.codec.encode.ImapEncoder;
+import org.apache.james.imapserver.codec.encode.ImapResponseComposer;
+import org.apache.james.imapserver.codec.encode.base.AbstractChainedImapEncoder;
+
+public class FlagsResponseEncoder extends AbstractChainedImapEncoder {
+
+    public FlagsResponseEncoder(ImapEncoder next) {
+        super(next);
+    }
+
+    public boolean isAcceptable(ImapMessage message) {
+        return message instanceof FlagsResponse;
+    }
+
+    protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer) throws IOException {
+        final FlagsResponse flagsResponse = (FlagsResponse) acceptableMessage;
+        final Flags flags = flagsResponse.getFlags();
+        composer.flagsResponse(flags);
+    }
+}

Modified: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/imap4rev1/StatusResponseEncoder.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/imap4rev1/StatusResponseEncoder.java?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/imap4rev1/StatusResponseEncoder.java (original)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/imap4rev1/StatusResponseEncoder.java Sun Mar 30 03:04:40 2008
@@ -50,7 +50,7 @@
         final HumanReadableTextKey textKey = response.getTextKey();
         final String text = asString(textKey);
         final Collection parameters;
-        final int number;
+        final long number;
         if (responseCode == null) {
             parameters = null;
             number = 0;

Modified: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/main/DefaultImapEncoderFactory.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/main/DefaultImapEncoderFactory.java?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/main/DefaultImapEncoderFactory.java (original)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/main/DefaultImapEncoderFactory.java Sun Mar 30 03:04:40 2008
@@ -25,16 +25,16 @@
 import org.apache.james.imapserver.codec.encode.imap4rev1.ExistsResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.ExpungeResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.FetchResponseEncoder;
+import org.apache.james.imapserver.codec.encode.imap4rev1.FlagsResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.RecentResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.StatusResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.legacy.BadResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.legacy.CapabilityResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.legacy.CommandFailedResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.legacy.ErrorResponseEncoder;
-import org.apache.james.imapserver.codec.encode.imap4rev1.legacy.ExamineAndSelectResponseEncoder;
-import org.apache.james.imapserver.codec.encode.imap4rev1.server.STATUSResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.server.LSubResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.server.ListResponseEncoder;
+import org.apache.james.imapserver.codec.encode.imap4rev1.server.STATUSResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.server.SearchResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.status.UntaggedNoResponseEncoder;
 
@@ -55,8 +55,8 @@
         final SearchResponseEncoder searchResponseEncoder = new SearchResponseEncoder(statusCommandResponseEncoder);
         final LSubResponseEncoder lsubResponseEncoder = new LSubResponseEncoder(searchResponseEncoder);
         final ListResponseEncoder listResponseEncoder = new ListResponseEncoder(lsubResponseEncoder);
-        final ExamineAndSelectResponseEncoder examineAndSelectResponseEncoder = new ExamineAndSelectResponseEncoder(listResponseEncoder);
-        final ErrorResponseEncoder errorResponseEncoder = new ErrorResponseEncoder(examineAndSelectResponseEncoder);
+        final FlagsResponseEncoder flagsResponseEncoder = new FlagsResponseEncoder(listResponseEncoder);
+        final ErrorResponseEncoder errorResponseEncoder = new ErrorResponseEncoder(flagsResponseEncoder);
         final CommandFailedResponseEncoder commandFailedResponseEncoder = new CommandFailedResponseEncoder(errorResponseEncoder);
         final CapabilityResponseEncoder capabilityResponseEncoder = new CapabilityResponseEncoder(commandFailedResponseEncoder);
         final BadResponseEncoder result = new BadResponseEncoder(capabilityResponseEncoder);

Modified: james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/ImapResponseTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/ImapResponseTest.java?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/ImapResponseTest.java (original)
+++ james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/ImapResponseTest.java Sun Mar 30 03:04:40 2008
@@ -22,7 +22,6 @@
 import javax.mail.Flags;
 
 import org.apache.james.api.imap.ImapConstants;
-import org.apache.james.api.imap.message.MessageFlags;
 import org.apache.james.imapserver.codec.encode.base.ImapResponseComposerImpl;
 import org.apache.james.imapserver.codec.encode.imap4rev1.legacy.MockImapResponseWriter;
 import org.jmock.MockObjectTestCase;
@@ -173,18 +172,4 @@
         assertEquals(new MockImapResponseWriter.EndOperation(), 
                 writer.operations.get(2));
     }
-
-    public void testPermanentFlagsResponse() throws Exception {
-        Flags flags = new Flags();
-        response.permanentFlagsResponse(flags);
-        assertEquals(4, writer.operations.size());
-        assertEquals(new MockImapResponseWriter.UntaggedOperation(), writer.operations.get(0));
-        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposerImpl.OK),
-                writer.operations.get(1));
-        assertEquals(new MockImapResponseWriter.ResponseCodeOperation("PERMANENTFLAGS " + MessageFlags.format(flags)),
-                writer.operations.get(2));
-        assertEquals(new MockImapResponseWriter.EndOperation(), 
-                writer.operations.get(3));
-    }
-
 }

Modified: james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/AbstractMailboxSelectionProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/AbstractMailboxSelectionProcessor.java?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/AbstractMailboxSelectionProcessor.java (original)
+++ james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/AbstractMailboxSelectionProcessor.java Sun Mar 30 03:04:40 2008
@@ -28,12 +28,17 @@
 import org.apache.james.api.imap.ImapCommand;
 import org.apache.james.api.imap.ProtocolException;
 import org.apache.james.api.imap.display.HumanReadableTextKey;
-import org.apache.james.api.imap.message.response.ImapResponseMessage;
+import org.apache.james.api.imap.message.request.ImapRequest;
+import org.apache.james.api.imap.message.response.imap4rev1.StatusResponse;
 import org.apache.james.api.imap.message.response.imap4rev1.StatusResponseFactory;
+import org.apache.james.api.imap.message.response.imap4rev1.StatusResponse.ResponseCode;
 import org.apache.james.api.imap.process.ImapProcessor;
 import org.apache.james.api.imap.process.ImapSession;
 import org.apache.james.api.imap.process.SelectedImapMailbox;
-import org.apache.james.imap.message.response.imap4rev1.legacy.ExamineAndSelectResponse;
+import org.apache.james.imap.message.request.imap4rev1.AbstractMailboxSelectionRequest;
+import org.apache.james.imap.message.response.imap4rev1.ExistsResponse;
+import org.apache.james.imap.message.response.imap4rev1.FlagsResponse;
+import org.apache.james.imap.message.response.imap4rev1.RecentResponse;
 import org.apache.james.imapserver.processor.base.AbstractMailboxAwareProcessor;
 import org.apache.james.imapserver.processor.base.AuthorizationException;
 import org.apache.james.imapserver.processor.base.ImapSessionUtils;
@@ -43,7 +48,6 @@
 import org.apache.james.mailboxmanager.MailboxNotFoundException;
 import org.apache.james.mailboxmanager.MailboxSession;
 import org.apache.james.mailboxmanager.MessageResult;
-import org.apache.james.mailboxmanager.MessageResult.FetchGroup;
 import org.apache.james.mailboxmanager.impl.FetchGroupImpl;
 import org.apache.james.mailboxmanager.impl.GeneralMessageSetImpl;
 import org.apache.james.mailboxmanager.mailbox.ImapMailbox;
@@ -52,60 +56,118 @@
 
 abstract public class AbstractMailboxSelectionProcessor extends
         AbstractMailboxAwareProcessor {
-
+    
+    private final FlagsResponse standardFlags;
     final StatusResponseFactory statusResponseFactory;
+    private final boolean openReadOnly;
     
     public AbstractMailboxSelectionProcessor(final ImapProcessor next,
             final MailboxManagerProvider mailboxManagerProvider, 
-            final StatusResponseFactory statusResponseFactory) {
+            final StatusResponseFactory statusResponseFactory, final boolean openReadOnly) {
         super(next, mailboxManagerProvider, statusResponseFactory);
         this.statusResponseFactory = statusResponseFactory;
+        this.openReadOnly = openReadOnly;
+        final Flags flags = new Flags();
+        flags.add(Flags.Flag.ANSWERED);
+        flags.add(Flags.Flag.DELETED);
+        flags.add(Flags.Flag.DRAFT);
+        flags.add(Flags.Flag.FLAGGED);
+        flags.add(Flags.Flag.SEEN);
+        standardFlags = new FlagsResponse(flags);
+    }
+    
+    protected void doProcess(ImapRequest message,
+            ImapSession session, String tag, ImapCommand command, Responder responder)
+            throws MailboxException, AuthorizationException, ProtocolException {
+        final AbstractMailboxSelectionRequest request = (AbstractMailboxSelectionRequest) message;
+        final String mailboxName = request.getMailboxName();
+        doProcess(mailboxName, session, tag, command, responder);
     }
 
-    protected final ImapResponseMessage doProcess(String mailboxName,
-            boolean isExamine, ImapSession session, String tag,
-            ImapCommand command) throws MailboxException,
+    protected final void doProcess(String mailboxName, ImapSession session, String tag,
+            ImapCommand command, Responder responder) throws MailboxException,
             AuthorizationException, ProtocolException {
-        ImapResponseMessage result;
         try {
-            String fullMailboxName = buildFullName(session, mailboxName);
-            selectMailbox(fullMailboxName, session, isExamine);
-            result = process(isExamine, tag, command, session);
+            final String fullMailboxName = buildFullName(session, mailboxName);
+            selectMailbox(fullMailboxName, session);
+            respond(tag, command, session, responder);
         } catch (MailboxNotFoundException e) {
-            result = statusResponseFactory.taggedNo(tag, command, 
-                    HumanReadableTextKey.FAILURE_NO_SUCH_MAILBOX);
+            responder.respond(statusResponseFactory.taggedNo(tag, command, 
+                    HumanReadableTextKey.FAILURE_NO_SUCH_MAILBOX));
         } catch (MailboxManagerException e) {
             throw new MailboxException(e);
         }
-        return result;
     }
 
-    private ImapResponseMessage process(boolean isExamine, String tag, ImapCommand command, ImapSession session) 
-                throws MailboxException, MailboxManagerException {
-        ImapResponseMessage result;
+    private void respond(String tag, ImapCommand command, ImapSession session,
+            Responder responder) throws MailboxException, MailboxManagerException {
+        
         ImapMailbox mailbox = ImapSessionUtils.getMailbox(session);
         final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
+        final SelectedImapMailbox selected = session.getSelected();
+        
         // TODO: compact this into a single API call for meta-data about the repository
+        flags(responder);
+        exists(responder, mailbox, mailboxSession);
+        recent(responder, selected);
+        uidValidity(responder, mailbox, mailboxSession);
+        unseen(responder, mailbox, mailboxSession, selected);
+        permanentFlags(responder, mailbox);
+        taggedOk(responder, tag, command, mailbox);
+    }
+
+    private void taggedOk(final Responder responder, final String tag, final ImapCommand command, final ImapMailbox mailbox) {
+        final boolean writeable = mailbox.isWriteable() && !openReadOnly;
+        final ResponseCode code;
+        if (writeable) {
+            code = ResponseCode.readWrite();
+        } else {
+            code = ResponseCode.readOnly();
+        }
+        final StatusResponse taggedOk = statusResponseFactory.taggedOk(tag, command, HumanReadableTextKey.SELECT, code);
+        responder.respond(taggedOk);
+    }
+
+    private void flags(Responder responder) {
+        responder.respond(standardFlags);
+    }
+
+    private void permanentFlags(Responder responder, ImapMailbox mailbox) {
         final Flags permanentFlags = mailbox.getPermanentFlags();
-        final boolean writeable = mailbox.isWriteable() && !isExamine;
-        final SelectedImapMailbox selected = session.getSelected();
-        final int recentCount = selected.recentCount();
-        final long uidValidity = mailbox.getUidValidity(mailboxSession);
+        final StatusResponse untaggedOk = statusResponseFactory.untaggedOk(HumanReadableTextKey.PERMANENT_FLAGS, ResponseCode.permanentFlags(permanentFlags));
+        responder.respond(untaggedOk);
+    }
+
+    private void unseen(Responder responder, ImapMailbox mailbox, final MailboxSession mailboxSession, final SelectedImapMailbox selected) throws MailboxManagerException {
         final MessageResult firstUnseen = mailbox.getFirstUnseen(FetchGroupImpl.MINIMAL, mailboxSession);
-        final int messageCount = mailbox.getMessageCount(mailboxSession);
-        final int msn;
-        if (firstUnseen == null) {
-            msn = -1;
-        } else {
-            msn = selected.msn(firstUnseen.getUid());
+        if (firstUnseen != null) {
+            final long unseenUid = firstUnseen.getUid();
+            int msn = selected.msn(unseenUid);
+            final StatusResponse untaggedOk = statusResponseFactory.untaggedOk(HumanReadableTextKey.UNSEEN, ResponseCode.unseen(msn));
+            responder.respond(untaggedOk);
         }
-        result = new ExamineAndSelectResponse(command, permanentFlags,
-                writeable, recentCount, uidValidity, msn, messageCount, tag);
-        return result;
+        
+    }
+
+    private void uidValidity(Responder responder, ImapMailbox mailbox, final MailboxSession mailboxSession) throws MailboxManagerException {
+        final long uidValidity = mailbox.getUidValidity(mailboxSession);
+        final StatusResponse untaggedOk = statusResponseFactory.untaggedOk(HumanReadableTextKey.UID_VALIDITY, ResponseCode.uidValidity(uidValidity));
+        responder.respond(untaggedOk);
+    }
+
+    private void recent(Responder responder, final SelectedImapMailbox selected) {
+        final int recentCount = selected.recentCount();
+        final RecentResponse recentResponse = new RecentResponse(recentCount);
+        responder.respond(recentResponse);
+    }
+
+    private void exists(Responder responder, ImapMailbox mailbox, final MailboxSession mailboxSession) throws MailboxManagerException {
+        final int messageCount = mailbox.getMessageCount(mailboxSession);
+        final ExistsResponse existsResponse = new ExistsResponse(messageCount);
+        responder.respond(existsResponse);
     }
 
-    private boolean selectMailbox(String mailboxName, ImapSession session,
-            boolean readOnly) throws MailboxException, MailboxManagerException {
+    private void selectMailbox(String mailboxName, ImapSession session) throws MailboxException, MailboxManagerException {
         final MailboxManager mailboxManager = getMailboxManager(session);
         final ImapMailbox mailbox = mailboxManager.getImapMailbox(mailboxName, false);
         final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
@@ -117,8 +179,7 @@
         } else {
             sessionMailbox = currentMailbox;
         }
-        addRecent(readOnly, mailbox, mailboxSession, sessionMailbox);
-        return readOnly;
+        addRecent(mailbox, mailboxSession, sessionMailbox);
     }
 
     private SelectedImapMailbox createNewSelectedMailbox(final ImapMailbox mailbox, final MailboxSession mailboxSession,
@@ -139,8 +200,8 @@
         return sessionMailbox;
     }
 
-    private void addRecent(boolean readOnly, final ImapMailbox mailbox, final MailboxSession mailboxSession, SelectedImapMailbox sessionMailbox) throws MailboxManagerException {
-        final long[] recentUids = mailbox.recent(!readOnly, mailboxSession);
+    private void addRecent(final ImapMailbox mailbox, final MailboxSession mailboxSession, SelectedImapMailbox sessionMailbox) throws MailboxManagerException {
+        final long[] recentUids = mailbox.recent(!openReadOnly, mailboxSession);
         for (int i = 0; i < recentUids.length; i++) {
             long uid = recentUids[i];
             sessionMailbox.addRecent(uid);    

Modified: james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/ExamineProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/ExamineProcessor.java?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/ExamineProcessor.java (original)
+++ james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/ExamineProcessor.java Sun Mar 30 03:04:40 2008
@@ -19,18 +19,10 @@
 
 package org.apache.james.imapserver.processor.imap4rev1;
 
-import org.apache.james.api.imap.ImapCommand;
 import org.apache.james.api.imap.ImapMessage;
-import org.apache.james.api.imap.ProtocolException;
-import org.apache.james.api.imap.message.request.ImapRequest;
-import org.apache.james.api.imap.message.response.ImapResponseMessage;
 import org.apache.james.api.imap.message.response.imap4rev1.StatusResponseFactory;
 import org.apache.james.api.imap.process.ImapProcessor;
-import org.apache.james.api.imap.process.ImapSession;
-import org.apache.james.api.imap.process.ImapProcessor.Responder;
 import org.apache.james.imap.message.request.imap4rev1.ExamineRequest;
-import org.apache.james.imapserver.processor.base.AuthorizationException;
-import org.apache.james.imapserver.store.MailboxException;
 import org.apache.james.mailboxmanager.manager.MailboxManagerProvider;
 
 public class ExamineProcessor extends AbstractMailboxSelectionProcessor {
@@ -38,28 +30,10 @@
     public ExamineProcessor(final ImapProcessor next,
             final MailboxManagerProvider mailboxManagerProvider,
             final StatusResponseFactory statusResponseFactory) {
-        super(next, mailboxManagerProvider, statusResponseFactory);
+        super(next, mailboxManagerProvider, statusResponseFactory, true);
     }
 
     protected boolean isAcceptable(ImapMessage message) {
         return (message instanceof ExamineRequest);
-    }
-
-    protected void doProcess(ImapRequest message,
-            ImapSession session, String tag, ImapCommand command, Responder responder)
-            throws MailboxException, AuthorizationException, ProtocolException {
-        final ExamineRequest request = (ExamineRequest) message;
-        final ImapResponseMessage result = doProcess(request, session, tag,
-                command);
-        responder.respond(result);
-    }
-
-    private ImapResponseMessage doProcess(ExamineRequest request,
-            ImapSession session, String tag, ImapCommand command)
-            throws MailboxException, AuthorizationException, ProtocolException {
-        final String mailboxName = request.getMailboxName();
-        final ImapResponseMessage result = doProcess(mailboxName, true,
-                session, tag, command);
-        return result;
     }
 }

Modified: james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/SelectProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/SelectProcessor.java?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/SelectProcessor.java (original)
+++ james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/SelectProcessor.java Sun Mar 30 03:04:40 2008
@@ -19,18 +19,10 @@
 
 package org.apache.james.imapserver.processor.imap4rev1;
 
-import org.apache.james.api.imap.ImapCommand;
 import org.apache.james.api.imap.ImapMessage;
-import org.apache.james.api.imap.ProtocolException;
-import org.apache.james.api.imap.message.request.ImapRequest;
-import org.apache.james.api.imap.message.response.ImapResponseMessage;
 import org.apache.james.api.imap.message.response.imap4rev1.StatusResponseFactory;
 import org.apache.james.api.imap.process.ImapProcessor;
-import org.apache.james.api.imap.process.ImapSession;
-import org.apache.james.api.imap.process.ImapProcessor.Responder;
 import org.apache.james.imap.message.request.imap4rev1.SelectRequest;
-import org.apache.james.imapserver.processor.base.AuthorizationException;
-import org.apache.james.imapserver.store.MailboxException;
 import org.apache.james.mailboxmanager.manager.MailboxManagerProvider;
 
 public class SelectProcessor extends AbstractMailboxSelectionProcessor {
@@ -38,28 +30,11 @@
     public SelectProcessor(final ImapProcessor next,
             final MailboxManagerProvider mailboxManagerProvider,
             final StatusResponseFactory statusResponseFactory) {
-        super(next, mailboxManagerProvider, statusResponseFactory);
+        super(next, mailboxManagerProvider, statusResponseFactory, false);
     }
 
     protected boolean isAcceptable(ImapMessage message) {
         return (message instanceof SelectRequest);
     }
 
-    protected void doProcess(ImapRequest message,
-            ImapSession session, String tag, ImapCommand command, Responder responder)
-            throws MailboxException, AuthorizationException, ProtocolException {
-        final SelectRequest request = (SelectRequest) message;
-        final ImapResponseMessage result = doProcess(request, session, tag,
-                command);
-        responder.respond(result);
-    }
-
-    private ImapResponseMessage doProcess(SelectRequest request,
-            ImapSession session, String tag, ImapCommand command)
-            throws MailboxException, AuthorizationException, ProtocolException {
-        final String mailboxName = request.getMailboxName();
-        final ImapResponseMessage result = doProcess(mailboxName, false,
-                session, tag, command);
-        return result;
-    }
 }

Modified: james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/commands/CommandParser.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/commands/CommandParser.java?rev=642700&r1=642699&r2=642700&view=diff
==============================================================================
--- james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/commands/CommandParser.java (original)
+++ james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/commands/CommandParser.java Sun Mar 30 03:04:40 2008
@@ -331,22 +331,22 @@
 
     public void setFlag( String flagString, Flags flags ) throws ProtocolException
     {
-        if ( flagString.equalsIgnoreCase( MessageFlags.ANSWERED ) ) {
+        if ( flagString.equalsIgnoreCase( MessageFlags.ANSWERED_ALL_CAPS ) ) {
             flags.add(Flags.Flag.ANSWERED);
         }
-        else if ( flagString.equalsIgnoreCase( MessageFlags.DELETED ) ) {
+        else if ( flagString.equalsIgnoreCase( MessageFlags.DELETED_ALL_CAPS ) ) {
             flags.add(Flags.Flag.DELETED);
         }
-        else if ( flagString.equalsIgnoreCase( MessageFlags.DRAFT ) ) {
+        else if ( flagString.equalsIgnoreCase( MessageFlags.DRAFT_ALL_CAPS ) ) {
             flags.add(Flags.Flag.DRAFT);
         }
-        else if ( flagString.equalsIgnoreCase( MessageFlags.FLAGGED ) ) {
+        else if ( flagString.equalsIgnoreCase( MessageFlags.FLAGGED_ALL_CAPS ) ) {
             flags.add(Flags.Flag.FLAGGED);
         }
-        else if ( flagString.equalsIgnoreCase( MessageFlags.SEEN ) ) {
+        else if ( flagString.equalsIgnoreCase( MessageFlags.SEEN_ALL_CAPS ) ) {
             flags.add(Flags.Flag.SEEN);
         }
-        else if ( flagString.equalsIgnoreCase( MessageFlags.RECENT) ) {
+        else if ( flagString.equalsIgnoreCase( MessageFlags.RECENT_ALL_CAPS) ) {
             flags.add(Flags.Flag.RECENT);
         } 
         else {



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