james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r995164 - in /james/imap/trunk: processor/src/main/java/org/apache/james/imap/processor/RenameProcessor.java store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
Date Wed, 08 Sep 2010 17:28:37 GMT
Author: norman
Date: Wed Sep  8 17:28:36 2010
New Revision: 995164

URL: http://svn.apache.org/viewvc?rev=995164&view=rev
Log:
move rename of INBOX handling to processor to make the mailbox implementation not imap specific
(IMAP-208)

Modified:
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/RenameProcessor.java
    james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/RenameProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/RenameProcessor.java?rev=995164&r1=995163&r2=995164&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/RenameProcessor.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/RenameProcessor.java
Wed Sep  8 17:28:36 2010
@@ -19,7 +19,10 @@
 
 package org.apache.james.imap.processor;
 
+import javax.mail.Flags;
+
 import org.apache.james.imap.api.ImapCommand;
+import org.apache.james.imap.api.ImapConstants;
 import org.apache.james.imap.api.ImapMessage;
 import org.apache.james.imap.api.display.HumanReadableText;
 import org.apache.james.imap.api.message.request.ImapRequest;
@@ -33,6 +36,8 @@ import org.apache.james.mailbox.MailboxE
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxNotFoundException;
 import org.apache.james.mailbox.MailboxPath;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageRange;
 
 public class RenameProcessor extends AbstractMailboxProcessor {
 
@@ -53,7 +58,24 @@ public class RenameProcessor extends Abs
         final MailboxPath newPath = buildFullPath(session, request.getNewName());
         try {
             final MailboxManager mailboxManager = getMailboxManager();
-            mailboxManager.renameMailbox(existingPath, newPath, ImapSessionUtils.getMailboxSession(session));
+            MailboxSession mailboxsession = ImapSessionUtils.getMailboxSession(session);
+            if (existingPath.getName().equalsIgnoreCase(ImapConstants.INBOX_NAME)) {
+
+                // if the mailbox is INBOX we need to move move the messages
+                // https://issues.apache.org/jira/browse/IMAP-188                       
   
+                MessageRange range = MessageRange.all();
+                // create the mailbox if it not exist yet
+                if (mailboxManager.mailboxExists(newPath, mailboxsession) == false) {
+                    mailboxManager.createMailbox(newPath, mailboxsession);
+                }
+                mailboxManager.copyMessages(range, existingPath, newPath, mailboxsession);
+                
+                org.apache.james.mailbox.MessageManager inbox = mailboxManager.getMailbox(existingPath,
mailboxsession);
+                inbox.setFlags(new Flags(Flags.Flag.DELETED), true, false, range, mailboxsession);
+                inbox.expunge(range, mailboxsession);
+            } else {
+                mailboxManager.renameMailbox(existingPath, newPath, mailboxsession);
+            }
             okComplete(command, tag, responder);
             unsolicitedResponses(session, responder, false);
         } catch (MailboxExistsException e) {

Modified: james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java?rev=995164&r1=995163&r2=995164&view=diff
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
(original)
+++ james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
Wed Sep  8 17:28:36 2010
@@ -25,8 +25,6 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Random;
 
-import javax.mail.Flags;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.james.mailbox.BadCredentialsException;
@@ -292,38 +290,15 @@ public abstract class StoreMailboxManage
                         final String subNewName = to.getName() + subOriginalName.substring(from.getName().length());
                         final MailboxPath fromPath = new MailboxPath(children, subOriginalName);
                         final MailboxPath toPath = new MailboxPath(children, subNewName);
-                        
-                        
-                        // TODO: Move to processor
-                        if (sub.getName().equalsIgnoreCase("INBOX") == false) {
-                           
-                            sub.setName(subNewName);
-                            mapper.save(sub);
-                            dispatcher.mailboxRenamed(fromPath, toPath, session.getSessionId());
-
-                            if (log.isDebugEnabled())
-                                log.debug("Rename mailbox sub-mailbox " + subOriginalName
+ " to " + subNewName);
-                            
-                        } else {
-                           
-                            // if the mailbox is INBOX we need to move move the messages
-                            // https://issues.apache.org/jira/browse/IMAP-188           
               
-                            MessageRange range = MessageRange.all();
-                            
-                            // create the mailbox if it not exist yet
-                            if (mailboxExists(toPath, session) == false) {
-                                createMailbox(toPath, session);
-                            }
-                            copyMessages(range, fromPath, toPath, session);
-                            
-                            org.apache.james.mailbox.MessageManager inbox = getMailbox(fromPath,
session);
-                            inbox.setFlags(new Flags(Flags.Flag.DELETED), true, false, range,
session);
-                            inbox.expunge(range, session);
-                            
-                        }
-
 
+                        sub.setName(subNewName);
+                        mapper.save(sub);
+                        dispatcher.mailboxRenamed(fromPath, toPath, session.getSessionId());
 
+                        if (log.isDebugEnabled())
+                            log.debug("Rename mailbox sub-mailbox " + subOriginalName + "
to " + subNewName);
+                            
+                      
                     }
                 } finally {
                     lock.unlock(children);



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