james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r514102 [1/2] - in /james/server/sandbox/seda-imap/src: java/org/apache/james/imapserver/ java/org/apache/james/imapserver/commands/ test/org/apache/james/imapserver/commands/
Date Sat, 03 Mar 2007 08:44:24 GMT
Author: rdonkin
Date: Sat Mar  3 00:44:22 2007
New Revision: 514102

URL: http://svn.apache.org/viewvc?view=rev&rev=514102
Log:
Factored parsing into separate classes.

Added:
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapDecoder.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractImapCommandParser.java
      - copied, changed from r508943, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/BadResponseMessage.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExamineCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandParserFactory.java
      - copied, changed from r508943, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandFactory.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StandardImapDecoder.java
    james/server/sandbox/seda-imap/src/test/org/apache/james/imapserver/commands/BadResponseMessageTest.java
Removed:
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandFactory.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/UidEnabledCommand.java
Modified:
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapHandler.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapRequestHandler.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/SelectedMailboxSession.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractUidCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CheckCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CheckCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandTemplate.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExamineCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ListCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ListCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LoginCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LoginCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LogoutCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LogoutCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LsubCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LsubCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/NoopCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/NoopCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/RenameCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/RenameCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SearchCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SearchCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SelectCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SelectCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StatusCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StatusCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StoreCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StoreCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SubscribeCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SubscribeCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/UidCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/UidCommandParser.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/UnsubscribeCommand.java
    james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/UnsubscribeCommandParser.java

Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapDecoder.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapDecoder.java?view=auto&rev=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapDecoder.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapDecoder.java Sat Mar  3 00:44:22 2007
@@ -0,0 +1,25 @@
+/****************************************************************
+ * 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;
+
+import org.apache.james.imapserver.commands.ImapCommandMessage;
+
+public interface ImapDecoder {
+    public ImapCommandMessage decode(final ImapRequestLineReader request);
+}

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapHandler.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapHandler.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapHandler.java Sat Mar  3 00:44:22 2007
@@ -19,15 +19,15 @@
 
 package org.apache.james.imapserver;
 
+import java.io.IOException;
+import java.net.Socket;
+
 import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
 import org.apache.avalon.excalibur.pool.Poolable;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.james.Constants;
 import org.apache.james.core.AbstractJamesHandler;
 import org.apache.james.imapserver.encode.OutputStreamImapResponseWriter;
-
-import java.io.IOException;
-import java.net.Socket;
 
 /**
  * The handler class for IMAP connections.

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapRequestHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapRequestHandler.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapRequestHandler.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapRequestHandler.java Sat Mar  3 00:44:22 2007
@@ -24,25 +24,25 @@
 
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.logger.Logger;
-import org.apache.james.imapserver.commands.CommandParser;
-import org.apache.james.imapserver.commands.ImapCommand;
-import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.commands.ImapCommandMessage;
+import org.apache.james.imapserver.commands.ImapResponseMessage;
+import org.apache.james.imapserver.commands.StandardImapDecoder;
 import org.apache.james.imapserver.encode.OutputStreamImapResponseWriter;
 
 /**
  * @version $Revision: 109034 $
  */
 public final class ImapRequestHandler extends AbstractLogEnabled {
-    
-    private final ImapCommandFactory imapCommands = new ImapCommandFactory();
-    private static final String REQUEST_SYNTAX = "Protocol Error: Was expecting <tag SPACE command [arguments]>";
 
+    // TODO: inject depedency
+    private final ImapDecoder decoder = new StandardImapDecoder();
+    
     /**
      * @see org.apache.avalon.framework.logger.AbstractLogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger)
      */
     public void enableLogging(Logger logger) { 
         super.enableLogging(logger);
-        setupLogger(imapCommands);
+        setupLogger(decoder);
     }
     
     /**
@@ -67,7 +67,7 @@
             request.nextChar();
         }
         catch ( ProtocolException e ) {
-            getLogger().debug("Cannot handling request: ", e);
+            getLogger().debug("Unexpected end of line. Cannot handle request: ", e);
             return false;
         }
 
@@ -87,44 +87,9 @@
                                    ImapResponse response,
                                    ImapSession session)
     {
-        String tag = null;
-        String commandName = null;
-
-        try {
-            tag = CommandParser.tag( request );
-        }
-        catch ( ProtocolException e ) {
-            getLogger().debug("error parsing request", e);
-            response.badResponse( REQUEST_SYNTAX );
-            return;
-        }
-
-        final Logger logger = getLogger(); 
-        if (logger.isDebugEnabled()) { 
-            logger.debug( "Got <tag>: " + tag );
-        }
-        
-        try {
-            commandName = CommandParser.atom( request );
-        }
-        catch ( ProtocolException e ) {
-            getLogger().debug("error parsing request", e);            
-            response.commandError( REQUEST_SYNTAX , tag);
-            return;
-        }
-
-        if (logger.isDebugEnabled()) { 
-            logger.debug( "Got <command>: " + commandName); 
-        }
-        
-        ImapCommand command = imapCommands.getCommand( commandName );
-        if ( command == null )
-        {
-            response.commandError( "Invalid command.", tag);
-            return;
-        }
-
-        command.process( request, response, session, tag );
+        ImapCommandMessage message = decoder.decode(request);
+        ImapResponseMessage responseMessage = message.process(session);
+        responseMessage.encode(response, session);
     }
 
 

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/SelectedMailboxSession.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/SelectedMailboxSession.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/SelectedMailboxSession.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/SelectedMailboxSession.java Sat Mar  3 00:44:22 2007
@@ -20,18 +20,9 @@
 package org.apache.james.imapserver;
 
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import javax.mail.Flags;
 
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.james.imapserver.store.MailboxException;
 import org.apache.james.mailboxmanager.MailboxListener;
 import org.apache.james.mailboxmanager.MailboxManagerException;
 import org.apache.james.mailboxmanager.MessageResult;

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractImapCommandParser.java (from r508943, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractImapCommandParser.java?view=diff&rev=514102&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandParser.java&r1=508943&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractImapCommandParser.java&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractImapCommandParser.java Sat Mar  3 00:44:22 2007
@@ -27,25 +27,53 @@
 
 import javax.mail.Flags;
 
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
 import org.apache.james.imapserver.ImapConstants;
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
 import org.apache.james.imapserver.store.MessageFlags;
 
 /**
- *
+ * TODO: find better name for class
  * @version $Revision: 109034 $
  */
-public abstract class CommandParser
+public abstract class AbstractImapCommandParser extends AbstractLogEnabled implements ImapCommandParser
 {
     private final ImapCommand command;
     
     
-    public CommandParser(final ImapCommand command) {
+    public AbstractImapCommandParser(final ImapCommand command) {
         super();
         this.command = command;
     }
-
+    
+    /**
+     * Parses a request into a command message
+     * for later processing.
+     * @param request <code>ImapRequestLineReader</code>, not null
+     * @return <code>ImapCommandMessage</code>, not null
+     */
+    public final ImapCommandMessage parse( ImapRequestLineReader request, String tag ) {
+        ImapCommandMessage result;
+        try {
+            
+            AbstractImapCommandMessage message = decode(request, tag);
+            final Logger logger = getLogger();
+            if (logger != null) {
+                message.enableLogging(logger);
+            }
+            result = message;
+            
+        } catch ( ProtocolException e ) {
+            getLogger().debug("error processing command ", e);
+            String msg = e.getMessage() + " Command should be '" +
+                    command.getExpectedMessage() + "'";
+            result = new ErrorResponseMessage( msg, tag );
+        }
+        return result;
+    }
+    
     /**
      * Parses a request into a command message
      * for later processing.

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractUidCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractUidCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractUidCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractUidCommandParser.java Sat Mar  3 00:44:22 2007
@@ -22,7 +22,7 @@
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
 
-abstract class AbstractUidCommandParser extends CommandParser {
+abstract class AbstractUidCommandParser extends AbstractImapCommandParser {
 
     private final ImapCommand command;
     

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommand.java Sat Mar  3 00:44:22 2007
@@ -21,8 +21,6 @@
 
 
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 /**
  * Handles processeing for the APPEND imap command.
@@ -33,13 +31,6 @@
 {
     public static final String NAME = "APPEND";
     public static final String ARGS = "<mailbox> [<flag_list>] [<date_time>] literal";
-
-    private AppendCommandParser parser = new AppendCommandParser(this);
-
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        final AbstractImapCommandMessage result = parser.decode(request, tag);
-        return result;
-    }
 
     /** @see ImapCommand#getName */
     public String getName()

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommandParser.java Sat Mar  3 00:44:22 2007
@@ -27,11 +27,11 @@
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
 
-class AppendCommandParser extends CommandParser
+class AppendCommandParser extends AbstractImapCommandParser
 {        
 
-    public AppendCommandParser(ImapCommand command) {
-        super(command);
+    public AppendCommandParser() {
+        super(new AppendCommand());
     }
 
     /**

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommand.java Sat Mar  3 00:44:22 2007
@@ -19,8 +19,6 @@
 
 package org.apache.james.imapserver.commands;
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 /**
  * Handles processeing for the AUTHENTICATE imap command.
@@ -32,13 +30,6 @@
     public static final String NAME = "AUTHENTICATE";
     public static final String ARGS = "<auth_type> *(CRLF base64)";
     
-    private final AuthenticateCommandParser parser = new AuthenticateCommandParser(this);
-    
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        final AbstractImapCommandMessage result = parser.decode(request, tag);
-        return result;
-    }
-
     /** @see ImapCommand#getName */
     public String getName()
     {

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommandParser.java Sat Mar  3 00:44:22 2007
@@ -21,10 +21,10 @@
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
 
-class AuthenticateCommandParser extends CommandParser {
+class AuthenticateCommandParser extends AbstractImapCommandParser {
 
-    public AuthenticateCommandParser(ImapCommand command) {
-        super(command);
+    public AuthenticateCommandParser() {
+        super(new AuthenticateCommand());
     }
 
     protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {

Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/BadResponseMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/BadResponseMessage.java?view=auto&rev=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/BadResponseMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/BadResponseMessage.java Sat Mar  3 00:44:22 2007
@@ -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.commands;
+
+import org.apache.james.imapserver.ImapResponse;
+import org.apache.james.imapserver.ImapSession;
+
+/**
+ * Carries the response to a request with bad syntax..
+ * 
+ */
+public class BadResponseMessage implements ImapCommandMessage,
+        ImapResponseMessage {
+
+    private final String message;
+    
+    public BadResponseMessage(final String message) {
+        super();
+        this.message = message;
+    }
+
+    public ImapResponseMessage process(ImapSession session) {
+        return this;
+    }
+
+    public void encode(ImapResponse response, ImapSession session) {
+        response.badResponse(message);
+    }
+
+}

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommand.java Sat Mar  3 00:44:22 2007
@@ -19,8 +19,6 @@
 
 package org.apache.james.imapserver.commands;
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 /**
  * Handles processeing for the CAPABILITY imap command.
@@ -33,13 +31,6 @@
     public static final String ARGS = null;
 
     public static final String CAPABILITY_RESPONSE = NAME + SP + VERSION + SP + CAPABILITIES;
-
-    private final CapabilityCommandParser parser = new CapabilityCommandParser(this);
-    
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        final AbstractImapCommandMessage result = parser.decode(request, tag);
-        return result;
-    }
 
     /** @see ImapCommand#getName */
     public String getName()

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommandParser.java Sat Mar  3 00:44:22 2007
@@ -21,10 +21,10 @@
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
 
-class CapabilityCommandParser extends CommandParser {
+class CapabilityCommandParser extends AbstractImapCommandParser {
 
-    public CapabilityCommandParser(ImapCommand command) {
-        super(command);
+    public CapabilityCommandParser() {
+        super(new CapabilityCommand());
     }
 
     protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CheckCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CheckCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CheckCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CheckCommand.java Sat Mar  3 00:44:22 2007
@@ -19,8 +19,6 @@
 
 package org.apache.james.imapserver.commands;
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 /**
  * Handles processing for the CHECK imap command.
@@ -31,13 +29,6 @@
 {
     public static final String NAME = "CHECK";
     public static final String ARGS = null;
-
-    private final CheckCommandParser parser = new CheckCommandParser(this);
-    
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        final AbstractImapCommandMessage result = parser.decode(request, tag);
-        return result;
-    }
 
     /** @see ImapCommand#getName */
     public String getName()

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CheckCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CheckCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CheckCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CheckCommandParser.java Sat Mar  3 00:44:22 2007
@@ -21,10 +21,10 @@
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
 
-class CheckCommandParser extends CommandParser {
+class CheckCommandParser extends AbstractImapCommandParser {
 
-    public CheckCommandParser(ImapCommand command) {
-        super(command);
+    public CheckCommandParser() {
+        super(new CheckCommand());
     }
 
     protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommand.java Sat Mar  3 00:44:22 2007
@@ -19,8 +19,6 @@
 
 package org.apache.james.imapserver.commands;
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 /**
  * Handles processeing for the CHECK imap command.
@@ -31,13 +29,6 @@
 {
     public static final String NAME = "CLOSE";
     public static final String ARGS = null;
-    
-    private final CloseCommandParser parser = new CloseCommandParser(this);
-
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        final AbstractImapCommandMessage result = parser.decode(request, tag);
-        return result;
-    }
 
     /** @see ImapCommand#getName */
     public String getName()

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommandParser.java Sat Mar  3 00:44:22 2007
@@ -21,10 +21,10 @@
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
 
-class CloseCommandParser extends CommandParser {
+class CloseCommandParser extends AbstractImapCommandParser {
 
-    public CloseCommandParser(ImapCommand command) {
-        super(command);
+    public CloseCommandParser() {
+        super(new CloseCommand());
     }
 
     protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandTemplate.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandTemplate.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandTemplate.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandTemplate.java Sat Mar  3 00:44:22 2007
@@ -20,15 +20,8 @@
 package org.apache.james.imapserver.commands;
 
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.logger.Logger;
-import org.apache.james.imapserver.AuthorizationException;
 import org.apache.james.imapserver.ImapConstants;
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ImapResponse;
-import org.apache.james.imapserver.ImapSession;
 import org.apache.james.imapserver.ImapSessionState;
-import org.apache.james.imapserver.ProtocolException;
-import org.apache.james.imapserver.store.MailboxException;
 
 /**
  * Base class for all command implementations. This class provides common
@@ -38,7 +31,7 @@
  */
 abstract class CommandTemplate
         extends AbstractLogEnabled
-        implements ImapCommand, ImapConstants, ImapCommandParser
+        implements ImapCommand, ImapConstants
 {
     /**
      * By default, valid in any state (unless overridden by subclass.
@@ -48,66 +41,6 @@
     {
         return true;
     }
-
-    /**
-     * Template methods for handling command processing. This method reads
-     * argument values (validating them), and checks the request for correctness.
-     * If correct, the command processing is delegated to the specific command
-     * implemenation.
-     *
-     * @see ImapCommand#process
-     */
-    public void process( ImapRequestLineReader request,
-                         ImapResponse response,
-                         ImapSession session, String tag )
-    {
-        try {
-            doProcess( request, response, session, tag );
-        }
-        catch ( MailboxException e ) {
-            getLogger().debug("error processing command ", e);
-            response.commandFailed( this, e.getResponseCode(), e.getMessage() );
-        }
-        catch ( AuthorizationException e ) {
-            getLogger().debug("error processing command ", e);
-            String msg = "Authorization error: Lacking permissions to perform requested operation.";
-            response.commandFailed( this, msg, tag );
-        }
-        catch ( ProtocolException e ) {
-            getLogger().debug("error processing command ", e);
-            String msg = e.getMessage() + " Command should be '" +
-                    getExpectedMessage() + "'";
-            response.commandError( msg, tag);
-        }
-    }
-
-    
-    /**
-     * Parses a request into a command message
-     * for later processing.
-     * @param request <code>ImapRequestLineReader</code>, not null
-     * @return <code>ImapCommandMessage</code>, not null
-     */
-    public final ImapCommandMessage parse( ImapRequestLineReader request, String tag ) {
-        ImapCommandMessage result;
-        try {
-            
-            AbstractImapCommandMessage message = decode(request, tag);
-            final Logger logger = getLogger();
-            if (logger != null) {
-                message.enableLogging(logger);
-            }
-            result = message;
-            
-        } catch ( ProtocolException e ) {
-            getLogger().debug("error processing command ", e);
-            String msg = e.getMessage() + " Command should be '" +
-                    getExpectedMessage() + "'";
-            result = new ErrorResponseMessage( msg, tag );
-        }
-        return result;
-    }
-
     
     /**
      * Provides a message which describes the expected format and arguments
@@ -129,40 +62,6 @@
 
         return syntax.toString();
     }
-    
-    /**
-     * Parses a request into a command message
-     * for later processing.
-     * @param request <code>ImapRequestLineReader</code>, not null
-     * @param tag TODO
-     * @return <code>ImapCommandMessage</code>, not null
-     * @throws ProtocolException if the request cannot be parsed
-     */
-    protected abstract AbstractImapCommandMessage decode( ImapRequestLineReader request, String tag ) 
-        throws ProtocolException;
-    
-    /**
-     * This is the method overridden by specific command implementations to
-     * perform commend-specific processing.
-     *
-     * @param request The client request
-     * @param response The server response
-     * @param session The current client session
-     * @param tag TODO
-     */
-    protected final void doProcess( ImapRequestLineReader request,
-                                       ImapResponse response,
-                                       ImapSession session, String tag )
-            throws ProtocolException, MailboxException, AuthorizationException {
-        AbstractImapCommandMessage message = decode( request, tag );
-        final Logger logger = getLogger();
-        if (logger != null) {
-            message.enableLogging(logger);
-        }
-        ImapResponseMessage responseMessage = message.doProcess( session );
-        responseMessage.encode(response, session);
-    }
-
 
     /**
      * Provides the syntax for the command arguments if any. This value is used

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommand.java Sat Mar  3 00:44:22 2007
@@ -19,21 +19,17 @@
 
 package org.apache.james.imapserver.commands;
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 /**
  * Handles processeing for the COPY imap command.
  *
  * @version $Revision: 109034 $
  */
-class CopyCommand extends SelectedStateCommand implements UidEnabledCommand
+class CopyCommand extends SelectedStateCommand
 {
     public static final String NAME = "COPY";
     public static final String ARGS = "<message-set> <mailbox>";
 
-    private final CopyCommandParser parser = new CopyCommandParser(this);
-    
     /** @see ImapCommand#getName */
     public String getName()
     {
@@ -44,14 +40,6 @@
     public String getArgSyntax()
     {
         return ARGS;
-    }
-
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        return decode(request, false, tag);
-    }
-    
-    public AbstractImapCommandMessage decode(final ImapRequestLineReader request, final boolean useUids, String tag) throws ProtocolException {
-        return parser.decode(request, tag, useUids);
     }
 }
 /*

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommandParser.java Sat Mar  3 00:44:22 2007
@@ -23,11 +23,12 @@
 
 class CopyCommandParser extends AbstractUidCommandParser {
 
-    public CopyCommandParser(ImapCommand command) {
-        super(command);
+    public CopyCommandParser() {
+        super(new CopyCommand());
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, boolean useUids) throws ProtocolException {
+    protected AbstractImapCommandMessage decode(ImapCommand command, 
+            ImapRequestLineReader request, String tag, boolean useUids) throws ProtocolException {
         IdRange[] idSet = parseIdRange( request );
         String mailboxName = mailbox( request );
         endLine( request );

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommand.java Sat Mar  3 00:44:22 2007
@@ -19,8 +19,6 @@
 
 package org.apache.james.imapserver.commands;
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 /**
  * Handles processeing for the CREATE imap command.
@@ -31,8 +29,6 @@
 {
     public static final String NAME = "CREATE";
     public static final String ARGS = "<mailbox>";
-
-    private final CreateCommandParser parser = new CreateCommandParser(this);
     
     /** @see ImapCommand#getName */
     public String getName()
@@ -44,11 +40,6 @@
     public String getArgSyntax()
     {
         return ARGS;
-    }
-
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        final AbstractImapCommandMessage result = parser.decode(request, tag);
-        return result;
     }
 }
 

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommandParser.java Sat Mar  3 00:44:22 2007
@@ -21,10 +21,10 @@
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
 
-class CreateCommandParser extends CommandParser {
+class CreateCommandParser extends AbstractImapCommandParser {
 
-    public CreateCommandParser(ImapCommand command) {
-        super(command);
+    public CreateCommandParser() {
+        super(new CreateCommand());
     }
 
     protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommand.java Sat Mar  3 00:44:22 2007
@@ -19,8 +19,6 @@
 
 package org.apache.james.imapserver.commands;
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 /**
  * Handles processeing for the DELETE imap command.
@@ -31,8 +29,6 @@
 {
     public static final String NAME = "DELETE";
     public static final String ARGS = "<mailbox>";
-    
-    private final DeleteCommandParser parser = new DeleteCommandParser(this);
 
     /** @see ImapCommand#getName */
     public String getName()
@@ -44,11 +40,6 @@
     public String getArgSyntax()
     {
         return ARGS;
-    }
-
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        final AbstractImapCommandMessage result = parser.decode(request, tag);
-        return result;
     }
 }
 

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommandParser.java Sat Mar  3 00:44:22 2007
@@ -21,10 +21,10 @@
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
 
-class DeleteCommandParser extends CommandParser {
+class DeleteCommandParser extends AbstractImapCommandParser {
 
-    public DeleteCommandParser(ImapCommand command) {
-        super(command);
+    public DeleteCommandParser() {
+        super(new DeleteCommand());
     }
 
     protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExamineCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExamineCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExamineCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExamineCommand.java Sat Mar  3 00:44:22 2007
@@ -21,6 +21,7 @@
 
 /**
  * TODO: sort out inheritance heirarchy.
+ * TODO: this should not inherit from select
  * @version $Revision: 109034 $
  */
 class ExamineCommand extends SelectCommand
@@ -28,7 +29,7 @@
     public static final String NAME = "EXAMINE";
 
     public ExamineCommand() {
-        super(true);
+        super();
     }
     
     public String getName()

Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExamineCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExamineCommandParser.java?view=auto&rev=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExamineCommandParser.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExamineCommandParser.java Sat Mar  3 00:44:22 2007
@@ -0,0 +1,37 @@
+/****************************************************************
+ * 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.commands;
+
+import org.apache.james.imapserver.ImapRequestLineReader;
+import org.apache.james.imapserver.ProtocolException;
+
+class ExamineCommandParser extends AbstractImapCommandParser {
+    
+    public ExamineCommandParser() {
+        super(new ExamineCommand());
+    }
+
+    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
+        final String mailboxName = mailbox( request );
+        endLine( request );
+        final SelectCommandMessage result = new SelectCommandMessage(command, mailboxName, true, tag);
+        return result;
+    }
+    
+}

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommand.java Sat Mar  3 00:44:22 2007
@@ -19,8 +19,6 @@
 
 package org.apache.james.imapserver.commands;
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 /**
  * Handles processeing for the EXPUNGE imap command.
@@ -31,9 +29,7 @@
 {
     public static final String NAME = "EXPUNGE";
     public static final String ARGS = null;
-    
-    private final ExpungeCommandParser parser = new ExpungeCommandParser(this);
-    
+
     /** @see ImapCommand#getName */
     public String getName()
     {
@@ -44,11 +40,6 @@
     public String getArgSyntax()
     {
         return ARGS;
-    }
-
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        final AbstractImapCommandMessage result = parser.decode(request, tag);
-        return result;
     }
 }
 /*

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommandParser.java Sat Mar  3 00:44:22 2007
@@ -21,10 +21,10 @@
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
 
-class ExpungeCommandParser extends CommandParser {
+class ExpungeCommandParser extends AbstractImapCommandParser {
 
-    public ExpungeCommandParser(ImapCommand command) {
-        super(command);
+    public ExpungeCommandParser() {
+        super(new ExpungeCommand());
     }
 
     protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommand.java Sat Mar  3 00:44:22 2007
@@ -21,8 +21,6 @@
 
 
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 
 /**
@@ -30,13 +28,11 @@
  *
  * @version $Revision: 109034 $
  */
-class FetchCommand extends SelectedStateCommand implements UidEnabledCommand
+class FetchCommand extends SelectedStateCommand 
 {
     public static final String NAME = "FETCH";
     public static final String ARGS = "<message-set> <fetch-profile>";
 
-    private FetchCommandParser parser = new FetchCommandParser(this);
-
     /** @see ImapCommand#getName */
     public String getName()
     {
@@ -47,16 +43,6 @@
     public String getArgSyntax()
     {
         return ARGS;
-    }
-
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        final AbstractImapCommandMessage result = decode(request, false, tag);
-        return result;
-    }
-
-    public AbstractImapCommandMessage decode(ImapRequestLineReader request, boolean useUids, String tag) throws ProtocolException {
-        final AbstractImapCommandMessage result = parser.decode(request, tag, useUids);
-        return result;
     }
 }
 /*

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommandParser.java Sat Mar  3 00:44:22 2007
@@ -23,8 +23,8 @@
 
 class FetchCommandParser extends AbstractUidCommandParser
 {
-    public FetchCommandParser(ImapCommand command) {
-        super(command);
+    public FetchCommandParser() {
+        super(new FetchCommand());
     }
 
     public FetchRequest fetchRequest( ImapRequestLineReader request )

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommand.java Sat Mar  3 00:44:22 2007
@@ -19,9 +19,6 @@
 
 package org.apache.james.imapserver.commands;
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ImapResponse;
-import org.apache.james.imapserver.ImapSession;
 import org.apache.james.imapserver.ImapSessionState;
 
 /**
@@ -43,19 +40,6 @@
      * @return <code>true</code> if the command is valid in this state.
      */
     boolean validForState( ImapSessionState state );
-
-    /**
-     * Performs all processing of the current Imap request. Reads command
-     * arguments from the request, performs processing, and writes responses
-     * back to the request object, which are sent to the client.
-     * @param request The current client request
-     * @param response The current server response
-     * @param session The current session
-     * @param tag TODO
-     */
-    void process( ImapRequestLineReader request,
-                  ImapResponse response,
-                  ImapSession session, String tag );
 
     /**
      * Provides the syntax for the command arguments if any. This value is used

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandParserFactory.java (from r508943, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandFactory.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandParserFactory.java?view=diff&rev=514102&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandFactory.java&r1=508943&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandParserFactory.java&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandFactory.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandParserFactory.java Sat Mar  3 00:44:22 2007
@@ -32,39 +32,39 @@
  *
  * @version $Revision: 109034 $
  */
-public class ImapCommandFactory
+public class ImapCommandParserFactory
         extends AbstractLogEnabled
 {
     private Map _imapCommands;
 
-    public ImapCommandFactory()
+    public ImapCommandParserFactory()
     {
         _imapCommands = new HashMap();
 
         // Commands valid in any state
         // CAPABILITY, NOOP, and LOGOUT
-        _imapCommands.put( CapabilityCommand.NAME, CapabilityCommand.class );
-        _imapCommands.put( NoopCommand.NAME, NoopCommand.class );
-        _imapCommands.put( LogoutCommand.NAME, LogoutCommand.class );
+        _imapCommands.put( CapabilityCommand.NAME, CapabilityCommandParser.class );
+        _imapCommands.put( NoopCommand.NAME, NoopCommandParser.class );
+        _imapCommands.put( LogoutCommand.NAME, LogoutCommandParser.class );
 
         // Commands valid in NON_AUTHENTICATED state.
         // AUTHENTICATE and LOGIN
-        _imapCommands.put( AuthenticateCommand.NAME, AuthenticateCommand.class );
-        _imapCommands.put( LoginCommand.NAME, LoginCommand.class );
+        _imapCommands.put( AuthenticateCommand.NAME, AuthenticateCommandParser.class );
+        _imapCommands.put( LoginCommand.NAME, LoginCommandParser.class );
 
         // Commands valid in AUTHENTICATED or SELECTED state.
         // RFC2060: SELECT, EXAMINE, CREATE, DELETE, RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, LSUB, STATUS, and APPEND
-        _imapCommands.put( SelectCommand.NAME, SelectCommand.class );
-        _imapCommands.put( ExamineCommand.NAME, ExamineCommand.class );
-        _imapCommands.put( CreateCommand.NAME, CreateCommand.class );
-        _imapCommands.put( DeleteCommand.NAME, DeleteCommand.class );
-        _imapCommands.put( RenameCommand.NAME, RenameCommand.class );
-        _imapCommands.put( SubscribeCommand.NAME, SubscribeCommand.class );
-        _imapCommands.put( UnsubscribeCommand.NAME, UnsubscribeCommand.class );
-        _imapCommands.put( ListCommand.NAME, ListCommand.class );
-        _imapCommands.put( LsubCommand.NAME, LsubCommand.class );
-        _imapCommands.put( StatusCommand.NAME, StatusCommand.class );
-        _imapCommands.put( AppendCommand.NAME, AppendCommand.class );
+        _imapCommands.put( SelectCommand.NAME, SelectCommandParser.class );
+        _imapCommands.put( ExamineCommand.NAME, ExamineCommandParser.class );
+        _imapCommands.put( CreateCommand.NAME, CreateCommandParser.class );
+        _imapCommands.put( DeleteCommand.NAME, DeleteCommandParser.class );
+        _imapCommands.put( RenameCommand.NAME, RenameCommandParser.class );
+        _imapCommands.put( SubscribeCommand.NAME, SubscribeCommandParser.class );
+        _imapCommands.put( UnsubscribeCommand.NAME, UnsubscribeCommandParser.class );
+        _imapCommands.put( ListCommand.NAME, ListCommandParser.class );
+        _imapCommands.put( LsubCommand.NAME, LsubCommandParser.class );
+        _imapCommands.put( StatusCommand.NAME, StatusCommandParser.class );
+        _imapCommands.put( AppendCommand.NAME, AppendCommandParser.class );
 
 //        // RFC2342 NAMESPACE
 //        _imapCommands.put( "NAMESPACE", NamespaceCommand.class );
@@ -79,17 +79,17 @@
 
         // Commands only valid in SELECTED state.
         // CHECK, CLOSE, EXPUNGE, SEARCH, FETCH, STORE, COPY, and UID
-        _imapCommands.put( CheckCommand.NAME, CheckCommand.class );
-        _imapCommands.put( CloseCommand.NAME, CloseCommand.class );
-        _imapCommands.put( ExpungeCommand.NAME, ExpungeCommand.class );
-        _imapCommands.put( CopyCommand.NAME, CopyCommand.class );
-        _imapCommands.put( SearchCommand.NAME, SearchCommand.class );
-        _imapCommands.put( FetchCommand.NAME, FetchCommand.class );
-        _imapCommands.put( StoreCommand.NAME, StoreCommand.class );
-        _imapCommands.put( UidCommand.NAME, UidCommand.class );
+        _imapCommands.put( CheckCommand.NAME, CheckCommandParser.class );
+        _imapCommands.put( CloseCommand.NAME, CloseCommandParser.class );
+        _imapCommands.put( ExpungeCommand.NAME, ExpungeCommandParser.class );
+        _imapCommands.put( CopyCommand.NAME, CopyCommandParser.class );
+        _imapCommands.put( SearchCommand.NAME, SearchCommandParser.class );
+        _imapCommands.put( FetchCommand.NAME, FetchCommandParser.class );
+        _imapCommands.put( StoreCommand.NAME, StoreCommandParser.class );
+        _imapCommands.put( UidCommand.NAME, UidCommandParser.class );
     }
 
-    public ImapCommand getCommand( String commandName )
+    public ImapCommandParser getParser( String commandName )
     {
         Class cmdClass = ( Class ) _imapCommands.get( commandName.toUpperCase() );
 
@@ -101,17 +101,18 @@
         }
     }
 
-    private ImapCommand createCommand( Class commandClass )
+    private ImapCommandParser createCommand( Class commandClass )
     {
         final Logger logger = getLogger(); 
         try {
-            ImapCommand cmd = ( ImapCommand ) commandClass.newInstance();
+            ImapCommandParser cmd = ( ImapCommandParser ) commandClass.newInstance();
             setupLogger(cmd);
             if (logger.isDebugEnabled()) {
                 logger.debug("Created command " + commandClass); 
             }
-            if ( cmd instanceof UidCommand ) {
-                ( ( UidCommand) cmd ).setCommandFactory( this );
+            // TODO: introduce interface
+            if ( cmd instanceof UidCommandParser ) {
+                ( ( UidCommandParser) cmd ).setCommandFactory( this );
             }
             return cmd;
         }

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ListCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ListCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ListCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ListCommand.java Sat Mar  3 00:44:22 2007
@@ -20,8 +20,6 @@
 package org.apache.james.imapserver.commands;
 
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 /**
  * Handles processeing for the LIST imap command.
@@ -33,8 +31,6 @@
     public static final String NAME = "LIST";
     public static final String ARGS = "<reference-name> <mailbox-name-with-wildcards>";
 
-    private final ListCommandParser parser = new ListCommandParser(this);
-
     /** @see ImapCommand#getName */
     public String getName()
     {
@@ -46,13 +42,6 @@
     {
         return ARGS;
     }
-
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        final AbstractImapCommandMessage result = parser.decode(request, tag);
-        return result;
-    }
-    
-
 }
 
 /*

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ListCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ListCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ListCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ListCommandParser.java Sat Mar  3 00:44:22 2007
@@ -22,7 +22,11 @@
 import org.apache.james.imapserver.ProtocolException;
 class ListCommandParser extends AbstractUidCommandParser
 {
-    public ListCommandParser(ImapCommand command) {
+    public ListCommandParser() {
+        super(new ListCommand());
+    }
+
+    ListCommandParser(ImapCommand command) {
         super(command);
     }
 

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LoginCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LoginCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LoginCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LoginCommand.java Sat Mar  3 00:44:22 2007
@@ -19,8 +19,6 @@
 
 package org.apache.james.imapserver.commands;
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 
 /**
@@ -33,8 +31,6 @@
     public static final String NAME = "LOGIN";
     public static final String ARGS = "<userid> <password>";
 
-    private final LoginCommandParser parser = new LoginCommandParser(this);
-     
     /** @see ImapCommand#getName */
     public String getName()
     {
@@ -45,11 +41,6 @@
     public String getArgSyntax()
     {
         return ARGS;
-    }
-
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        final AbstractImapCommandMessage result = parser.decode(request, tag);
-        return result;
     }
 }
 

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LoginCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LoginCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LoginCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LoginCommandParser.java Sat Mar  3 00:44:22 2007
@@ -21,10 +21,10 @@
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
 
-class LoginCommandParser extends CommandParser {
+class LoginCommandParser extends AbstractImapCommandParser {
 
-    public LoginCommandParser(ImapCommand command) {
-        super(command);
+    public LoginCommandParser() {
+        super(new LoginCommand());
     }
 
     protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LogoutCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LogoutCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LogoutCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LogoutCommand.java Sat Mar  3 00:44:22 2007
@@ -19,8 +19,6 @@
 
 package org.apache.james.imapserver.commands;
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 /**
  * Handles processeing for the LOGOUT imap command.
@@ -32,8 +30,6 @@
     public static final String NAME = "LOGOUT";
     public static final String ARGS = null;
     public static final String BYE_MESSAGE = VERSION + SP + "Server logging out";
-
-    private final LogoutCommandParser parser = new LogoutCommandParser(this);
     
     /** @see ImapCommand#getName */
     public String getName()
@@ -45,11 +41,6 @@
     public String getArgSyntax()
     {
         return ARGS;
-    }
-
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        final AbstractImapCommandMessage result = parser.decode(request, tag);
-        return result;
     }
 }
 

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LogoutCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LogoutCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LogoutCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LogoutCommandParser.java Sat Mar  3 00:44:22 2007
@@ -21,10 +21,10 @@
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
 
-class LogoutCommandParser extends CommandParser {
+class LogoutCommandParser extends AbstractImapCommandParser {
 
-    public LogoutCommandParser(ImapCommand command) {
-        super(command);
+    public LogoutCommandParser() {
+        super(new LogoutCommand());
     }
 
     protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LsubCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LsubCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LsubCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LsubCommand.java Sat Mar  3 00:44:22 2007
@@ -19,8 +19,6 @@
 
 package org.apache.james.imapserver.commands;
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 
 /**
@@ -30,16 +28,9 @@
 {
     public static final String NAME = "LSUB";
 
-    private final LsubCommandParser parser = new LsubCommandParser(this);
-
     /** @see ImapCommand#getName */
     public String getName()
     {
         return NAME;
-    }
-    
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        final AbstractImapCommandMessage result = parser.decode(request, tag);
-        return result;
     }
 }

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LsubCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LsubCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LsubCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LsubCommandParser.java Sat Mar  3 00:44:22 2007
@@ -20,8 +20,8 @@
 
 class LsubCommandParser extends ListCommandParser {
 
-    public LsubCommandParser(ImapCommand command) {
-        super(command);
+    public LsubCommandParser() {
+        super(new LsubCommand());
     }
 
     protected ListCommandMessage createMessage(ImapCommand command, String referenceName, String mailboxPattern, String tag) {

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/NoopCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/NoopCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/NoopCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/NoopCommand.java Sat Mar  3 00:44:22 2007
@@ -19,8 +19,6 @@
 
 package org.apache.james.imapserver.commands;
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 /**
  * Handles processeing for the NOOP imap command.
@@ -32,8 +30,6 @@
     public static final String NAME = "NOOP";
     public static final String ARGS = null;
     
-    private final NoopCommandParser parser = new NoopCommandParser(this);
-    
     /** @see ImapCommand#getName */
     public String getName()
     {
@@ -44,11 +40,6 @@
     public String getArgSyntax()
     {
         return ARGS;
-    }
-
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        final AbstractImapCommandMessage result = parser.decode(request, tag);
-        return result;
     }
 }
 

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/NoopCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/NoopCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/NoopCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/NoopCommandParser.java Sat Mar  3 00:44:22 2007
@@ -21,10 +21,10 @@
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
 
-class NoopCommandParser extends CommandParser {
+class NoopCommandParser extends AbstractImapCommandParser {
 
-    public NoopCommandParser(ImapCommand command) {
-        super(command);
+    public NoopCommandParser() {
+        super(new NoopCommand());
     }
 
     protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/RenameCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/RenameCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/RenameCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/RenameCommand.java Sat Mar  3 00:44:22 2007
@@ -19,8 +19,6 @@
 
 package org.apache.james.imapserver.commands;
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 /**
  * Handles processeing for the RENAME imap command.
@@ -31,8 +29,6 @@
 {
     public static final String NAME = "RENAME";
     public static final String ARGS = "existing-mailbox-name SPACE new-mailbox-name";
-
-    private final RenameCommandParser parser = new RenameCommandParser(this);
     
     /** @see ImapCommand#getName */
     public String getName()
@@ -44,11 +40,6 @@
     public String getArgSyntax()
     {
         return ARGS;
-    }
-
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        final AbstractImapCommandMessage result = parser.decode(request, tag);
-        return result;
     }
 }
 

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/RenameCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/RenameCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/RenameCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/RenameCommandParser.java Sat Mar  3 00:44:22 2007
@@ -21,10 +21,10 @@
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
 
-class RenameCommandParser extends CommandParser {
+class RenameCommandParser extends AbstractImapCommandParser {
 
-    public RenameCommandParser(ImapCommand command) {
-        super(command);
+    public RenameCommandParser() {
+        super(new RenameCommand());
     }
 
     protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SearchCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SearchCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SearchCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SearchCommand.java Sat Mar  3 00:44:22 2007
@@ -20,21 +20,17 @@
 package org.apache.james.imapserver.commands;
 
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 /**
  * Handles processeing for the SEARCH imap command.
  *
  * @version $Revision: 109034 $
  */
-class SearchCommand extends SelectedStateCommand implements UidEnabledCommand
+class SearchCommand extends SelectedStateCommand 
 {
     public static final String NAME = "SEARCH";
     public static final String ARGS = "<search term>";
 
-    private SearchCommandParser parser = new SearchCommandParser(this);
-
     /** @see ImapCommand#getName */
     public String getName()
     {
@@ -45,14 +41,6 @@
     public String getArgSyntax()
     {
         return ARGS;
-    }
-
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        return decode(request, false, tag);
-    }
-
-    public AbstractImapCommandMessage decode(ImapRequestLineReader request, boolean useUids, String tag) throws ProtocolException {
-        return parser.decode(request, tag, useUids);
     }
 }
 /*

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SearchCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SearchCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SearchCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SearchCommandParser.java Sat Mar  3 00:44:22 2007
@@ -26,8 +26,8 @@
 
 class SearchCommandParser extends AbstractUidCommandParser
 {
-    public SearchCommandParser(ImapCommand command) {
-        super(command);
+    public SearchCommandParser() {
+        super(new SearchCommand());
     }
 
     /**

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SelectCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SelectCommand.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SelectCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SelectCommand.java Sat Mar  3 00:44:22 2007
@@ -20,8 +20,6 @@
 package org.apache.james.imapserver.commands;
 
 
-import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ProtocolException;
 
 /**
  * Handles processeing for the SELECT imap command.
@@ -33,16 +31,6 @@
     public static final String NAME = "SELECT";
     public static final String ARGS = "mailbox";
     
-    private final SelectCommandParser parser;
-
-    protected SelectCommand(boolean isExamine) {
-        parser = new SelectCommandParser(this, isExamine);
-    }
-    
-    public SelectCommand() {
-        this(false);
-    }
-
     /** @see ImapCommand#getName */
     public String getName()
     {
@@ -53,11 +41,6 @@
     public String getArgSyntax()
     {
         return ARGS;
-    }
-
-    protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
-        final AbstractImapCommandMessage result = parser.decode(request, tag);
-        return result;
     }
 }
 

Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SelectCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SelectCommandParser.java?view=diff&rev=514102&r1=514101&r2=514102
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SelectCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SelectCommandParser.java Sat Mar  3 00:44:22 2007
@@ -21,18 +21,16 @@
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
 
-class SelectCommandParser extends CommandParser {
-    private final boolean isExamine;
+class SelectCommandParser extends AbstractImapCommandParser {
     
-    public SelectCommandParser(ImapCommand command, boolean isExamine) {
-        super(command);
-        this.isExamine = isExamine;
+    public SelectCommandParser() {
+        super(new SelectCommand());
     }
 
     protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
         final String mailboxName = mailbox( request );
         endLine( request );
-        final SelectCommandMessage result = new SelectCommandMessage(command, mailboxName, isExamine, tag);
+        final SelectCommandMessage result = new SelectCommandMessage(command, mailboxName, false, tag);
         return result;
     }
     



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