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/31 20:43:35 UTC
svn commit: r643095 - 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...
Author: rdonkin
Date: Mon Mar 31 11:43:32 2008
New Revision: 643095
URL: http://svn.apache.org/viewvc?rev=643095&view=rev
Log:
RENAME tested with hierarchical mailboxes.
Added:
james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/MailboxExistsException.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/AbstractTestRename.java
james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/RenameHierarchy.test
james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java
james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/base/AbstractImapRequestProcessor.java
james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/DeleteProcessor.java
james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/RenameProcessor.java
james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/om/BaseMailboxRow.java
Added: james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/MailboxExistsException.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/MailboxExistsException.java?rev=643095&view=auto
==============================================================================
--- james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/MailboxExistsException.java (added)
+++ james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/MailboxExistsException.java Mon Mar 31 11:43:32 2008
@@ -0,0 +1,48 @@
+/****************************************************************
+ * 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 operation failed
+ * since the mailbox already exists.
+ */
+public class MailboxExistsException extends MailboxManagerException {
+
+ private static final long serialVersionUID = -486951759505030166L;
+
+ private final String mailboxName;
+
+ public MailboxExistsException(String mailboxName) {
+ super("Mailbox '" + mailboxName + "' already exists.");
+ this.mailboxName = mailboxName;
+ }
+
+ /**
+ * Gets the name of the mailbox which alredy exists.
+ * @return the mailboxName, not null
+ */
+ public final String getMailboxName() {
+ return mailboxName;
+ }
+
+ public String toString() {
+ return getMessage();
+ }
+}
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?rev=643095&r1=643094&r2=643095&view=diff
==============================================================================
--- 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 Mon Mar 31 11:43:32 2008
@@ -88,6 +88,14 @@
void deleteMailbox(String mailboxName) throws MailboxManagerException;
+ /**
+ * Renames a mailbox.
+ * @param from original name for the mailbox
+ * @param to new name for the mailbox
+ * @throws MailboxManagerException
+ * @throws MailboxExistsException when the <code>to</code> mailbox exists
+ * @throws MailboxNotFound when the <code>from</code> mailbox does not exist
+ */
void renameMailbox(String from, String to) throws MailboxManagerException;
/**
Modified: james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestRename.java
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestRename.java?rev=643095&r1=643094&r2=643095&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestRename.java (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestRename.java Mon Mar 31 11:43:32 2008
@@ -30,12 +30,24 @@
public void testRenameUS() throws Exception {
scriptTest("Rename", Locale.US);
}
-//
-// public void testAppendToSelectedKOREA() throws Exception {
-// scriptTest("AppendToSelected", Locale.KOREA);
-// }
-//
-// public void testAppendToSelectedITALY() throws Exception {
-// scriptTest("AppendToSelected", Locale.ITALY);
-// }
+
+ public void testRenameKOREA() throws Exception {
+ scriptTest("Rename", Locale.KOREA);
+ }
+
+ public void testRenameITALY() throws Exception {
+ scriptTest("Rename", Locale.ITALY);
+ }
+
+ public void testRenameHierarchyUS() throws Exception {
+ scriptTest("RenameHierarchy", Locale.US);
+ }
+
+ public void testRenameHierarchyKO() throws Exception {
+ scriptTest("RenameHierarchy", Locale.KOREA);
+ }
+
+ public void testRenameHierarchyIT() throws Exception {
+ scriptTest("RenameHierarchy", Locale.ITALY);
+ }
}
Modified: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/RenameHierarchy.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/RenameHierarchy.test?rev=643095&r1=643094&r2=643095&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/RenameHierarchy.test (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/RenameHierarchy.test Mon Mar 31 11:43:32 2008
@@ -25,66 +25,73 @@
C: A5 CREATE one.two.three.four
S: A5 OK CREATE completed\.
C: A6 LIST "" "*"
-S: \* LIST "\." "one"
-S: \* LIST "\." "INBOX"
-S: \* LIST "\." "one\.two"
-S: \* LIST "\." "one\.two\.three"
-S: \* LIST "\." "one\.two\.three\.four"
-S: A6 OK List completed\.
+S: \* LIST \(\) "\." "INBOX"
+S: \* LIST \(\) "\." "one"
+S: \* LIST \(\) "\." "one\.two"
+S: \* LIST \(\) "\." "one\.two\.three"
+S: \* LIST \(\) "\." "one\.two\.three\.four"
+S: \* LIST \(\) "\." "selected"
+S: A6 OK LIST completed\.
C: A7 RENAME one.two alpha.beta
S: A7 OK RENAME completed\.
C: A8 LIST "" "*"
-S: \* LIST "\." "alpha\.beta"
-S: \* LIST "\." "alpha\.beta\.three"
-S: \* LIST "\." "alpha\.beta\.three\.four"
-S: \* LIST "\." "one"
-S: \* LIST "\." "INBOX"
-S: A8 OK List completed\.
+S: \* LIST \(\) "\." "INBOX"
+S: \* LIST \(\) "\." "alpha\.beta"
+S: \* LIST \(\) "\." "alpha\.beta\.three"
+S: \* LIST \(\) "\." "alpha\.beta\.three\.four"
+S: \* LIST \(\) "\." "one"
+S: \* LIST \(\) "\." "selected"
+S: A8 OK LIST completed\.
C: A9 RENAME alpha.beta.three.four alpha.beta.gamma.delta
S: A9 OK RENAME completed\.
C: A10 LIST "" "*"
-S: \* LIST "\." "one"
-S: \* LIST "\." "INBOX"
-S: \* LIST "\." "alpha\.beta"
-S: \* LIST "\." "alpha\.beta\.gamma\.delta"
-S: \* LIST "\." "alpha\.beta\.three"
-S: A10 OK List completed\.
+S: \* LIST \(\) "\." "INBOX"
+S: \* LIST \(\) "\." "alpha\.beta"
+S: \* LIST \(\) "\." "alpha\.beta\.gamma\.delta"
+S: \* LIST \(\) "\." "alpha\.beta\.three"
+S: \* LIST \(\) "\." "one"
+S: \* LIST \(\) "\." "selected"
+S: A10 OK LIST completed\.
C: A11 RENAME alpha.beta.three aleph
S: A11 OK RENAME completed\.
C: A12 LIST "" "*"
-S: \* LIST "\." "one"
-S: \* LIST "\." "aleph"
-S: \* LIST "\." "INBOX"
-S: \* LIST "\." "alpha\.beta"
-S: \* LIST "\." "alpha\.beta\.gamma\.delta"
-S: A12 OK List completed\.
+S: \* LIST \(\) "\." "INBOX"
+S: \* LIST \(\) "\." "aleph"
+S: \* LIST \(\) "\." "alpha\.beta"
+S: \* LIST \(\) "\." "alpha\.beta\.gamma\.delta"
+S: \* LIST \(\) "\." "one"
+S: \* LIST \(\) "\." "selected"
+S: A12 OK LIST completed\.
C: A13 RENAME aleph alpha.beta.gamma.delta.epsilon
S: A13 OK RENAME completed\.
C: A14 LIST "" "*"
-S: \* LIST "\." "one"
-S: \* LIST "\." "INBOX"
-S: \* LIST "\." "alpha\.beta"
-S: \* LIST "\." "alpha\.beta\.gamma\.delta"
-S: \* LIST "\." "alpha\.beta\.gamma\.delta\.epsilon"
-S: A14 OK List completed\.
+S: \* LIST \(\) "\." "INBOX"
+S: \* LIST \(\) "\." "alpha\.beta"
+S: \* LIST \(\) "\." "alpha\.beta\.gamma\.delta"
+S: \* LIST \(\) "\." "alpha\.beta\.gamma\.delta\.epsilon"
+S: \* LIST \(\) "\." "one"
+S: \* LIST \(\) "\." "selected"
+S: A14 OK LIST completed\.
C: A15 RENAME alpha.beta.gamma one
-S: A15 NO Mailbox exists\.
+S: A15 NO RENAME failed. Mailbox already exists\.
C: A16 LIST "" "*"
-S: \* LIST "\." "one"
-S: \* LIST "\." "INBOX"
-S: \* LIST "\." "alpha\.beta"
-S: \* LIST "\." "alpha\.beta\.gamma\.delta"
-S: \* LIST "\." "alpha\.beta\.gamma\.delta\.epsilon"
-S: A16 OK List completed\.
+S: \* LIST \(\) "\." "INBOX"
+S: \* LIST \(\) "\." "alpha\.beta"
+S: \* LIST \(\) "\." "alpha\.beta\.gamma\.delta"
+S: \* LIST \(\) "\." "alpha\.beta\.gamma\.delta\.epsilon"
+S: \* LIST \(\) "\." "one"
+S: \* LIST \(\) "\." "selected"
+S: A16 OK LIST completed\.
C: A17 DELETE one
S: A17 OK DELETE completed\.
C: A18 DELETE alpha
-S: A18 NO Mailbox doesn't exist: alpha
+S: A18 NO DELETE failed. No such mailbox\.
C: A19 LIST "" "*"
-S: \* LIST "\." "alpha\.beta"
-S: \* LIST "\." "alpha\.beta\.gamma\.delta"
-S: \* LIST "\." "alpha\.beta\.gamma\.delta\.epsilon"
-S: \* LIST "\." "INBOX"
-S: A19 OK List completed\.
+S: \* LIST \(\) "\." "INBOX"
+S: \* LIST \(\) "\." "alpha\.beta"
+S: \* LIST \(\) "\." "alpha\.beta\.gamma\.delta"
+S: \* LIST \(\) "\." "alpha\.beta\.gamma\.delta\.epsilon"
+S: \* LIST \(\) "\." "selected"
+S: A19 OK LIST completed\.
C: A20 DELETE aleph
-S: A20 NO Mailbox doesn't exist: aleph
+S: A20 NO DELETE failed. No such mailbox\.
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=643095&r1=643094&r2=643095&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 Mon Mar 31 11:43:32 2008
@@ -57,6 +57,11 @@
public static final HumanReadableTextKey FAILURE_NO_SUCH_MAILBOX
= new HumanReadableTextKey("org.apache.james.imap.FAILURE_NO_SUCH_MAILBOX",
"failed. No such mailbox.");
+
+
+ public static final HumanReadableTextKey FAILURE_MAILBOX_EXISTS
+ = new HumanReadableTextKey("org.apache.james.imap.FAILURE_NO_SUCH_MAILBOX",
+ "failed. Mailbox already exists.");
public static final HumanReadableTextKey COMPLETED
= new HumanReadableTextKey("org.apache.james.imap.COMPLETED",
Modified: james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/base/AbstractImapRequestProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/base/AbstractImapRequestProcessor.java?rev=643095&r1=643094&r2=643095&view=diff
==============================================================================
--- james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/base/AbstractImapRequestProcessor.java (original)
+++ james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/base/AbstractImapRequestProcessor.java Mon Mar 31 11:43:32 2008
@@ -36,6 +36,9 @@
import org.apache.james.imap.message.response.imap4rev1.legacy.CommandFailedResponse;
import org.apache.james.imap.message.response.imap4rev1.legacy.ErrorResponse;
import org.apache.james.imapserver.store.MailboxException;
+import org.apache.james.mailboxmanager.MailboxExistsException;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+import org.apache.james.mailboxmanager.MailboxNotFoundException;
abstract public class AbstractImapRequestProcessor extends
AbstractChainedImapProcessor implements ImapConstants {
@@ -55,38 +58,66 @@
protected final void process(final ImapRequest message, final Responder responder,
final ImapSession session) {
- final Logger logger = getLogger();
final ImapCommand command = message.getCommand();
final String tag = message.getTag();
try {
doProcess(message, command, tag, responder, session);
} catch (MailboxException e) {
- if (logger != null) {
- logger.debug("error processing command ", e);
- }
- final ImapResponseMessage response = new CommandFailedResponse(command, e.getResponseCode(), e
- .getMessage(), tag);
- responder.respond(response);
+ no(command, tag, responder, e);
} catch (AuthorizationException e) {
- if (logger != null) {
- logger.debug("error processing command ", e);
- }
- final String msg = "Authorization error: Lacking permissions to perform requested operation.";
- final ImapResponseMessage response = new CommandFailedResponse(command, null, msg, tag);
- responder.respond(response);
-
+ no(command, tag, responder, e);
} catch (ProtocolException e) {
+ no(command, tag, responder, e);
+ }
+ }
+
+ protected void no(final ImapCommand command, final String tag, final Responder responder, ProtocolException e) {
+ final Logger logger = getLogger();
+ if (logger != null) {
+ logger.debug("error processing command ", e);
+ }
+ final String msg = e.getMessage() + " Command should be '"
+ + command.getExpectedMessage() + "'";
+ final ImapResponseMessage response = new ErrorResponse(msg, tag);
+ responder.respond(response);
+ }
+
+ protected void no(final ImapCommand command, final String tag, final Responder responder, AuthorizationException e) {
+ final Logger logger = getLogger();
+ if (logger != null) {
+ logger.debug("error processing command ", e);
+ }
+ final String msg = "Authorization error: Lacking permissions to perform requested operation.";
+ final ImapResponseMessage response = new CommandFailedResponse(command, null, msg, tag);
+ responder.respond(response);
+ }
+
+ protected void no(final ImapCommand command, final String tag, final Responder responder, final MailboxManagerException e) {
+ final Logger logger = getLogger();
+ final ImapResponseMessage response;
+ if (e instanceof MailboxExistsException) {
+ response = factory.taggedNo(tag, command, HumanReadableTextKey.FAILURE_MAILBOX_EXISTS);
+ } else if (e instanceof MailboxNotFoundException) {
+ response = factory.taggedNo(tag, command, HumanReadableTextKey.FAILURE_NO_SUCH_MAILBOX);
+ } else {
if (logger != null) {
logger.debug("error processing command ", e);
}
- final String msg = e.getMessage() + " Command should be '"
- + command.getExpectedMessage() + "'";
- final ImapResponseMessage response = new ErrorResponse(msg, tag);
- responder.respond(response);
-
+ response = new CommandFailedResponse(command, null, e.getMessage(), tag);
}
+ responder.respond(response);
}
+ protected void no(final ImapCommand command, final String tag, final Responder responder, final MailboxException e) {
+ final Logger logger = getLogger();
+ if (logger != null) {
+ logger.debug("error processing command ", e);
+ }
+ final ImapResponseMessage response = new CommandFailedResponse(command, e.getResponseCode(), e
+ .getMessage(), tag);
+ responder.respond(response);
+ }
+
final void doProcess(final ImapRequest message,
final ImapCommand command, final String tag, Responder responder, ImapSession session)
throws MailboxException, AuthorizationException, ProtocolException {
Modified: james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/DeleteProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/DeleteProcessor.java?rev=643095&r1=643094&r2=643095&view=diff
==============================================================================
--- james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/DeleteProcessor.java (original)
+++ james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/DeleteProcessor.java Mon Mar 31 11:43:32 2008
@@ -21,16 +21,13 @@
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.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.DeleteRequest;
import org.apache.james.imapserver.processor.base.AbstractMailboxAwareProcessor;
-import org.apache.james.imapserver.processor.base.AuthorizationException;
import org.apache.james.imapserver.processor.base.ImapSessionUtils;
-import org.apache.james.imapserver.store.MailboxException;
import org.apache.james.mailboxmanager.MailboxManagerException;
import org.apache.james.mailboxmanager.manager.MailboxManager;
import org.apache.james.mailboxmanager.manager.MailboxManagerProvider;
@@ -47,8 +44,7 @@
}
protected void doProcess(ImapRequest message,
- ImapSession session, String tag, ImapCommand command, Responder responder)
- throws MailboxException, AuthorizationException, ProtocolException {
+ ImapSession session, String tag, ImapCommand command, Responder responder) {
final DeleteRequest request = (DeleteRequest) message;
final String mailboxName = request.getMailboxName();
try {
@@ -61,11 +57,11 @@
}
final MailboxManager mailboxManager = getMailboxManager(session);
mailboxManager.deleteMailbox(fullMailboxName);
+ unsolicitedResponses(session, responder, false);
+ okComplete(command, tag, responder);
+
} catch (MailboxManagerException e) {
- throw new MailboxException(e);
+ no(command, tag, responder, e);
}
-
- unsolicitedResponses(session, responder, false);
- okComplete(command, tag, responder);
}
}
Modified: james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/RenameProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/RenameProcessor.java?rev=643095&r1=643094&r2=643095&view=diff
==============================================================================
--- james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/RenameProcessor.java (original)
+++ james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/RenameProcessor.java Mon Mar 31 11:43:32 2008
@@ -21,16 +21,16 @@
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.display.HumanReadableTextKey;
import org.apache.james.api.imap.message.request.ImapRequest;
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.RenameRequest;
import org.apache.james.imapserver.processor.base.AbstractMailboxAwareProcessor;
-import org.apache.james.imapserver.processor.base.AuthorizationException;
-import org.apache.james.imapserver.store.MailboxException;
+import org.apache.james.mailboxmanager.MailboxExistsException;
import org.apache.james.mailboxmanager.MailboxManagerException;
+import org.apache.james.mailboxmanager.MailboxNotFoundException;
import org.apache.james.mailboxmanager.manager.MailboxManager;
import org.apache.james.mailboxmanager.manager.MailboxManagerProvider;
@@ -46,21 +46,25 @@
}
protected void doProcess(ImapRequest message,
- ImapSession session, String tag, ImapCommand command, Responder responder)
- throws MailboxException, AuthorizationException, ProtocolException {
+ ImapSession session, String tag, ImapCommand command, Responder responder) {
final RenameRequest request = (RenameRequest) message;
final String existingName = request.getExistingName();
final String newName = request.getNewName();
try {
+
final String fullExistingName = buildFullName(session, existingName);
final String fullNewName = buildFullName(session, newName);
final MailboxManager mailboxManager = getMailboxManager(session);
mailboxManager.renameMailbox(fullExistingName, fullNewName);
+ okComplete(command, tag, responder);
+ unsolicitedResponses(session, responder, false);
+
+ } catch (MailboxExistsException e) {
+ no(command, tag, responder, HumanReadableTextKey.FAILURE_MAILBOX_EXISTS);
+ } catch (MailboxNotFoundException e) {
+ no(command, tag, responder, HumanReadableTextKey.FAILURE_NO_SUCH_MAILBOX);
} catch (MailboxManagerException e) {
- throw new MailboxException(e);
+ no(command, tag, responder, e);
}
-
- okComplete(command, tag, responder);
- unsolicitedResponses(session, responder, false);
}
}
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?rev=643095&r1=643094&r2=643095&view=diff
==============================================================================
--- 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 Mon Mar 31 11:43:32 2008
@@ -33,6 +33,7 @@
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.james.mailboxmanager.GeneralMessageSet;
import org.apache.james.mailboxmanager.ListResult;
+import org.apache.james.mailboxmanager.MailboxExistsException;
import org.apache.james.mailboxmanager.MailboxManagerException;
import org.apache.james.mailboxmanager.MailboxNotFoundException;
import org.apache.james.mailboxmanager.MailboxSession;
@@ -160,7 +161,7 @@
// TODO put this into a serilizable transaction
MailboxRow mr = MailboxRowPeer.retrieveByName(mailboxName);
if (mr == null) {
- throw new MailboxManagerException("Mailbox not found");
+ throw new MailboxNotFoundException("Mailbox not found");
}
MailboxRowPeer.doDelete(mr);
managers.remove(mailboxName);
@@ -171,19 +172,26 @@
}
public void renameMailbox(String from, String to)
- throws MailboxManagerException {
+ throws MailboxManagerException {
+ getLog().debug("renameMailbox "+from+" to "+to);
try {
- getLog().debug("renameMailbox "+from+" to "+to);
synchronized (managers) {
+ if (existsMailbox(to)) {
+ throw new MailboxExistsException(to);
+ }
// TODO put this into a serilizable transaction
- MailboxRow mr = MailboxRowPeer.retrieveByName(from);
+ final MailboxRow mr;
+
+ mr = MailboxRowPeer.retrieveByName(from);
+
if (mr == null) {
- throw new MailboxManagerException("Mailbox not found");
+ throw new MailboxNotFoundException(from);
}
mr.setName(to);
mr.save();
+
managers.remove(from);
-
+
// rename submailbox
Criteria c = new Criteria();
c.add(MailboxRowPeer.NAME,
@@ -199,10 +207,9 @@
getLog().info("renameMailbox sub-mailbox "+subOrigName+" to "+subNewName);
}
}
- } catch (Exception e) {
+ } catch (TorqueException e) {
throw new MailboxManagerException(e);
}
-
}
public void copyMessages(GeneralMessageSet set, String from, String to, MailboxSession session) throws MailboxManagerException {
Modified: james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/om/BaseMailboxRow.java
URL: http://svn.apache.org/viewvc/james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/om/BaseMailboxRow.java?rev=643095&r1=643094&r2=643095&view=diff
==============================================================================
--- james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/om/BaseMailboxRow.java (original)
+++ james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/om/BaseMailboxRow.java Mon Mar 31 11:43:32 2008
@@ -1,24 +1,18 @@
package org.apache.james.mailboxmanager.torque.om;
-import java.math.BigDecimal;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
import org.apache.commons.lang.ObjectUtils;
import org.apache.torque.TorqueException;
import org.apache.torque.map.TableMap;
import org.apache.torque.om.BaseObject;
-import org.apache.torque.om.ComboKey;
-import org.apache.torque.om.DateKey;
import org.apache.torque.om.NumberKey;
import org.apache.torque.om.ObjectKey;
import org.apache.torque.om.SimpleKey;
-import org.apache.torque.om.StringKey;
-import org.apache.torque.om.Persistent;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.Transaction;
@@ -750,7 +744,7 @@
*
* @throws Exception
*/
- public void save() throws Exception
+ public void save() throws TorqueException
{
save(MailboxRowPeer.DATABASE_NAME);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org