Author: rdonkin
Date: Wed May 13 08:52:48 2009
New Revision: 774254
URL: http://svn.apache.org/viewvc?rev=774254&view=rev
Log:
Improved TRY CREATE diagnosis. IMAP-83
https://issues.apache.org/jira/browse/IMAP-83
Modified:
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/AppendExpunge.test
Modified:
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java?rev=774254&r1=774253&r2=774254&view=diff
==============================================================================
---
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
(original)
+++
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
Wed May 13 08:52:48 2009
@@ -37,6 +37,7 @@
import org.apache.james.imap.mailbox.MailboxException;
import org.apache.james.imap.mailbox.MailboxManager;
import org.apache.james.imap.mailbox.MailboxManagerProvider;
+import org.apache.james.imap.mailbox.MailboxNotFoundException;
import org.apache.james.imap.mailbox.MailboxSession;
import org.apache.james.imap.message.request.AppendRequest;
import org.apache.james.imap.processor.base.ImapSessionUtils;
@@ -70,27 +71,40 @@
final Mailbox mailbox = mailboxManager.getMailbox(fullMailboxName,
ImapSessionUtils.getMailboxSession(session));
appendToMailbox(messageBytes, datetime, flags, session, tag,
command, mailbox, responder, fullMailboxName);
-
- } catch (MailboxException mme) {
- // Mailbox API does not provide facilities for diagnosing the
- // problem
- // assume that
- // TODO: improved API should communicate when this operation
- // TODO: fails whether the mailbox exists
- Log logger = session.getLog();
- if (logger.isInfoEnabled()) {
- logger.info(mme.getMessage());
- }
- if (logger.isDebugEnabled()) {
- logger.debug("Cannot open mailbox: ", mme);
- }
- no(command, tag, responder,
- HumanReadableTextKey.FAILURE_NO_SUCH_MAILBOX,
- StatusResponse.ResponseCode.tryCreate());
+ } catch (MailboxNotFoundException e) {
+// Indicates that the mailbox does not exist
+// So TRY CREATE
+ tryCreate(session, tag, command, responder, e);
+ } catch (MailboxException e) {
+// Some other issue
+ no(command, tag, responder, e, session);
}
}
+ /**
+ * Issues a TRY CREATE response.
+ * @param session not null
+ * @param tag not null
+ * @param command not null
+ * @param responder not null
+ * @param e not null
+ */
+ private void tryCreate(ImapSession session, String tag, ImapCommand
command,
+ Responder responder, MailboxNotFoundException e) {
+
+ final Log logger = session.getLog();
+ if (logger.isInfoEnabled()) {
+ logger.info(e.getMessage());
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("Cannot open mailbox: ", e);
+ }
+ no(command, tag, responder,
+ HumanReadableTextKey.FAILURE_NO_SUCH_MAILBOX,
+ StatusResponse.ResponseCode.tryCreate());
+ }
+
private void appendToMailbox(final byte[] message, final Date datetime,
final Flags flagsToBeSet, final ImapSession session, final String
tag,
final ImapCommand command, final Mailbox mailbox, Responder
responder, final String fullMailboxName) {
@@ -107,8 +121,12 @@
}
unsolicitedResponses(session, responder, false);
okComplete(command, tag, responder);
+ } catch (MailboxNotFoundException e) {
+// Indicates that the mailbox does not exist
+// So TRY CREATE
+ tryCreate(session, tag, command, responder, e);
} catch (MailboxException e) {
- // TODO why not TRYCREATE?
+// Some other issue
no(command, tag, responder, e, session);
}
}
Modified:
james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/AppendExpunge.test
URL:
http://svn.apache.org/viewvc/james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/AppendExpunge.test?rev=774254&r1=774253&r2=774254&view=diff
==============================================================================
---
james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/AppendExpunge.test
(original)
+++
james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/AppendExpunge.test
Wed May 13 08:52:48 2009
@@ -49,7 +49,7 @@
C:
S: A003 OK APPEND completed.
-C: A004 APPEND appendexpunge (\Deleted) {310+}
+C: A004 APPEND appendexpunge {310+}
C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
C: From: Fred Foobar <[email protected]>
C: Subject: afternoon meeting 2
@@ -76,7 +76,7 @@
S: \* OK \[UIDNEXT 4\]
S: A006 OK \[READ-WRITE\] SELECT completed.
-C: A109 STORE 1:2 FLAGS.SILENT (\Deleted)
+C: A109 STORE 2 FLAGS.SILENT (\Deleted)
S: A109 OK STORE completed.
C: A007 EXPUNGE
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]