james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r564881 - in /james/server/trunk: core-library/src/main/java/org/apache/james/mailboxmanager/ core-library/src/main/java/org/apache/james/mailboxmanager/manager/ experimental-seda-imap-function/src/test/java/org/apache/james/test/functional...
Date Sat, 11 Aug 2007 09:18:13 GMT
Author: rdonkin
Date: Sat Aug 11 02:18:11 2007
New Revision: 564881

URL: http://svn.apache.org/viewvc?view=rev&rev=564881
Log:
EXAMINE must report the mailbox status as read-only. Improved message when mailbox does not
exist.

Added:
    james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/MailboxNotFoundException.java
Modified:
    james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/manager/MailboxManager.java
    james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/scripts/ExamineEmpty.test
    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/Imap4Rev1ProcessorFactory.java
    james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/SelectProcessor.java
    james/server/trunk/phoenix-deployment/src/test/org/apache/james/experimental/imapserver/ExperimentalAuthenticatedStateTest.java
    james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java

Added: james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/MailboxNotFoundException.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/MailboxNotFoundException.java?view=auto&rev=564881
==============================================================================
--- james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/MailboxNotFoundException.java
(added)
+++ james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/MailboxNotFoundException.java
Sat Aug 11 02:18:11 2007
@@ -0,0 +1,58 @@
+/****************************************************************
+ * 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.mailboxmanager;
+
+/**
+ * Indicates that the failure is caused by a reference
+ * to a mailbox which does not exist.
+ */
+public class MailboxNotFoundException extends MailboxManagerException {
+
+    private static final long serialVersionUID = -8493370806722264915L;
+
+    private static String message(String mailboxName) {
+        final String result;
+        if (mailboxName == null) {
+            result = "Mailbox not found";
+        } else {
+            result = "Mailbox '" + mailboxName + "' not found.";
+        }
+        return result;
+    }
+    
+    private final String mailboxName;
+    
+    /**
+     * 
+     * @param mailboxName name of the mailbox, not null
+     */
+    public MailboxNotFoundException(String mailboxName) {
+        super(message(mailboxName));
+        this.mailboxName = mailboxName;
+    }
+
+    /**
+     * Gets the name of the mailbox which cannot be found.
+     * @return
+     */
+    public final String getMailboxName() {
+        return mailboxName;
+    }
+}

Modified: james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/manager/MailboxManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/manager/MailboxManager.java?view=diff&rev=564881&r1=564880&r2=564881
==============================================================================
--- james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/manager/MailboxManager.java
(original)
+++ james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/manager/MailboxManager.java
Sat Aug 11 02:18:11 2007
@@ -86,6 +86,13 @@
     
     GeneralMailboxSession getGeneralMailboxSession(String mailboxName) throws MailboxManagerException;
     
+    /**
+     * Gets an session suitable for IMAP.
+     * @param mailboxName the name of the mailbox, not null
+     * @return <code>ImapMailboxSession</code>, not null
+     * @throws MailboxManagerException when the mailbox cannot be opened
+     * @throws MailboxNotFoundException when the given mailbox does not exist
+     */
     ImapMailboxSession getImapMailboxSession(String mailboxName) throws MailboxManagerException;
 
     void createMailbox(String mailboxName) throws MailboxManagerException;

Modified: james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/scripts/ExamineEmpty.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/scripts/ExamineEmpty.test?view=diff&rev=564881&r1=564880&r2=564881
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/scripts/ExamineEmpty.test
(original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/scripts/ExamineEmpty.test
Sat Aug 11 02:18:11 2007
@@ -33,7 +33,7 @@
 S: \* OK \[UIDVALIDITY \d+\]
 S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
-S: abcd OK \[READ-ONLY\] EXAMINE completed
+S: abcd OK \[READ-ONLY\] EXAMINE completed.
 
 C: abcd EXAMINE test.subfolder
 S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
@@ -42,7 +42,7 @@
 S: \* OK \[UIDVALIDITY \d+\]
 S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
-S: abcd OK \[READ-ONLY\] EXAMINE completed
+S: abcd OK \[READ-ONLY\] EXAMINE completed.
 
 C: abcd EXAMINE test1
 S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
@@ -51,17 +51,17 @@
 S: \* OK \[UIDVALIDITY \d+\]
 S: \* OK No messages unseen
 S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
-S: abcd OK \[READ-ONLY\] EXAMINE completed
+S: abcd OK \[READ-ONLY\] EXAMINE completed.
 
 C: abcd EXAMINE subfolder1
 S: abcd NO EXAMINE failed. No such mailbox.
 
 # Cleanup
 C: a1 DELETE test1.subfolder1
-S: a1 OK DELETE completed
+S: a1 OK DELETE completed.
 C: a1 DELETE test1
-S: a1 OK DELETE completed
+S: a1 OK DELETE completed.
 C: a1 DELETE test.subfolder
-S: a1 OK DELETE completed
+S: a1 OK DELETE completed.
 C: a1 DELETE test
-S: a1 OK DELETE completed
\ No newline at end of file
+S: a1 OK DELETE completed.
\ No newline at end of file

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?view=diff&rev=564881&r1=564880&r2=564881
==============================================================================
--- 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
Sat Aug 11 02:18:11 2007
@@ -23,7 +23,9 @@
 
 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.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.SelectedImapMailbox;
@@ -34,6 +36,7 @@
 import org.apache.james.imapserver.processor.base.SelectedMailboxSessionImpl;
 import org.apache.james.imapserver.store.MailboxException;
 import org.apache.james.mailboxmanager.MailboxManagerException;
+import org.apache.james.mailboxmanager.MailboxNotFoundException;
 import org.apache.james.mailboxmanager.MessageResult;
 import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
 import org.apache.james.mailboxmanager.manager.MailboxManager;
@@ -42,9 +45,13 @@
 abstract public class AbstractMailboxSelectionProcessor extends
         AbstractMailboxAwareProcessor {
 
+    final StatusResponseFactory statusResponseFactory;
+    
     public AbstractMailboxSelectionProcessor(final ImapProcessor next,
-            final MailboxManagerProvider mailboxManagerProvider) {
+            final MailboxManagerProvider mailboxManagerProvider, 
+            final StatusResponseFactory statusResponseFactory) {
         super(next, mailboxManagerProvider);
+        this.statusResponseFactory = statusResponseFactory;
     }
 
     protected final ImapResponseMessage doProcess(String mailboxName,
@@ -57,26 +64,36 @@
             String fullMailboxName = buildFullName(session, mailboxName);
             selectMailbox(fullMailboxName, session, isExamine);
             ImapMailboxSession mailbox = ImapSessionUtils.getMailbox(session);
-            // TODO: compact this into a single API call for meta-data about the repository
-            final Flags permanentFlags = mailbox.getPermanentFlags();
-            final boolean writeable = mailbox.isWriteable();
-            final boolean resetRecent = !isExamine;
-            final int recentCount = mailbox.getRecentCount(resetRecent);
-            final long uidValidity = mailbox.getUidValidity();
-            final MessageResult firstUnseen = mailbox
-                    .getFirstUnseen(MessageResult.MSN);
-            final int messageCount = mailbox.getMessageCount();
-            final int msn;
-            if (firstUnseen == null) {
-                msn = -1;
-            } else {
-                msn = firstUnseen.getMsn();
-            }
-            result = new ExamineAndSelectResponse(command, permanentFlags,
-                    writeable, recentCount, uidValidity, msn, messageCount, tag);
+            result = process(isExamine, tag, command, mailbox);
+        } catch (MailboxNotFoundException e) {
+            result = 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,
ImapMailboxSession mailbox) 
+                throws MailboxException, MailboxManagerException {
+        ImapResponseMessage result;
+        // TODO: compact this into a single API call for meta-data about the repository
+        final Flags permanentFlags = mailbox.getPermanentFlags();
+        final boolean writeable = mailbox.isWriteable() && !isExamine;
+        final boolean resetRecent = !isExamine;
+        final int recentCount = mailbox.getRecentCount(resetRecent);
+        final long uidValidity = mailbox.getUidValidity();
+        final MessageResult firstUnseen = mailbox
+        .getFirstUnseen(MessageResult.MSN);
+        final int messageCount = mailbox.getMessageCount();
+        final int msn;
+        if (firstUnseen == null) {
+            msn = -1;
+        } else {
+            msn = firstUnseen.getMsn();
+        }
+        result = new ExamineAndSelectResponse(command, permanentFlags,
+                writeable, recentCount, uidValidity, msn, messageCount, tag);
         return result;
     }
 

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?view=diff&rev=564881&r1=564880&r2=564881
==============================================================================
--- 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
Sat Aug 11 02:18:11 2007
@@ -24,6 +24,7 @@
 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.imap.message.request.imap4rev1.ExamineRequest;
@@ -34,8 +35,9 @@
 public class ExamineProcessor extends AbstractMailboxSelectionProcessor {
 
     public ExamineProcessor(final ImapProcessor next,
-            final MailboxManagerProvider mailboxManagerProvider) {
-        super(next, mailboxManagerProvider);
+            final MailboxManagerProvider mailboxManagerProvider,
+            final StatusResponseFactory statusResponseFactory) {
+        super(next, mailboxManagerProvider, statusResponseFactory);
     }
 
     protected boolean isAcceptable(ImapMessage message) {

Modified: james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/Imap4Rev1ProcessorFactory.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/Imap4Rev1ProcessorFactory.java?view=diff&rev=564881&r1=564880&r2=564881
==============================================================================
--- james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/Imap4Rev1ProcessorFactory.java
(original)
+++ james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/Imap4Rev1ProcessorFactory.java
Sat Aug 11 02:18:11 2007
@@ -61,7 +61,7 @@
         final ExpungeProcessor expungeProcessor = new ExpungeProcessor(
                 authenticateProcessor, mailboxManagerProvider);
         final ExamineProcessor examineProcessor = new ExamineProcessor(
-                expungeProcessor, mailboxManagerProvider);
+                expungeProcessor, mailboxManagerProvider, statusResponseFactory);
         final AppendProcessor appendProcessor = new AppendProcessor(
                 examineProcessor, mailboxManagerProvider, statusResponseFactory);
         final StoreProcessor storeProcessor = new StoreProcessor(
@@ -76,7 +76,7 @@
         final SearchProcessor searchProcessor = new SearchProcessor(
                 listProcessor);
         final SelectProcessor selectProcessor = new SelectProcessor(
-                searchProcessor, mailboxManagerProvider);
+                searchProcessor, mailboxManagerProvider, statusResponseFactory);
         final ImapProcessor result = new FetchProcessor(selectProcessor);
         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?view=diff&rev=564881&r1=564880&r2=564881
==============================================================================
--- 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
Sat Aug 11 02:18:11 2007
@@ -24,6 +24,7 @@
 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.imap.message.request.imap4rev1.SelectRequest;
@@ -34,8 +35,9 @@
 public class SelectProcessor extends AbstractMailboxSelectionProcessor {
 
     public SelectProcessor(final ImapProcessor next,
-            final MailboxManagerProvider mailboxManagerProvider) {
-        super(next, mailboxManagerProvider);
+            final MailboxManagerProvider mailboxManagerProvider,
+            final StatusResponseFactory statusResponseFactory) {
+        super(next, mailboxManagerProvider, statusResponseFactory);
     }
 
     protected boolean isAcceptable(ImapMessage message) {

Modified: james/server/trunk/phoenix-deployment/src/test/org/apache/james/experimental/imapserver/ExperimentalAuthenticatedStateTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/test/org/apache/james/experimental/imapserver/ExperimentalAuthenticatedStateTest.java?view=diff&rev=564881&r1=564880&r2=564881
==============================================================================
--- james/server/trunk/phoenix-deployment/src/test/org/apache/james/experimental/imapserver/ExperimentalAuthenticatedStateTest.java
(original)
+++ james/server/trunk/phoenix-deployment/src/test/org/apache/james/experimental/imapserver/ExperimentalAuthenticatedStateTest.java
Sat Aug 11 02:18:11 2007
@@ -31,10 +31,6 @@
         // Check whether this is correct behaviour
     }
     
-    public void testExamineEmpty() throws Exception {
-        // TODO: \recent flag is returned by FLAGS - specification seems ambiguous on this
-    }
-    
     public void testSelectEmpty() throws Exception {
 //      TODO: \recent flag is returned by FLAGS - specification seems ambiguous on this
     }

Modified: james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java?view=diff&rev=564881&r1=564880&r2=564881
==============================================================================
--- james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
(original)
+++ james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
Sat Aug 11 02:18:11 2007
@@ -28,6 +28,7 @@
 import org.apache.james.mailboxmanager.GeneralMessageSet;
 import org.apache.james.mailboxmanager.ListResult;
 import org.apache.james.mailboxmanager.MailboxManagerException;
+import org.apache.james.mailboxmanager.MailboxNotFoundException;
 import org.apache.james.mailboxmanager.MessageResult;
 import org.apache.james.mailboxmanager.impl.ListResultImpl;
 import org.apache.james.mailboxmanager.mailbox.GeneralMailbox;
@@ -114,8 +115,7 @@
                 } else {
                     getLog().info("Mailbox '" + mailboxName + "' not found.");
                     getMailboxCache().notFound(mailboxName);
-                    throw new MailboxManagerException("Mailbox '" + mailboxName
-                            + "' not found.");
+                    throw new MailboxNotFoundException(mailboxName);
                 }
             }
         } catch (TorqueException e) {



---------------------------------------------------------------------
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