james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r537643 [3/4] - in /james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src: main/java/org/apache/james/experimental/imapserver/ main/java/org/apache/james/experimental/imapserver/decode/ main/java/org/apache/james/experi...
Date Sun, 13 May 2007 19:25:44 GMT
Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/RenameRequest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/RenameRequest.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/RenameRequest.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/RenameRequest.java Sun May 13 12:25:39 2007
@@ -0,0 +1,43 @@
+/****************************************************************
+ * 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.experimental.imapserver.message.request.imap4rev1;
+
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.processor.imap4rev1.RenameProcessor;
+
+public class RenameRequest extends AbstractImapRequest {
+    private final String existingName;
+    private final String newName;
+    
+    public RenameRequest(final ImapCommand command, final String existingName, final String newName, 
+            final String tag) {
+        super(tag, command, new RenameProcessor());
+        this.existingName = existingName;
+        this.newName = newName;
+    }
+
+    public final String getExistingName() {
+		return existingName;
+	}
+
+	public final String getNewName() {
+		return newName;
+	}
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/SearchRequest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/SearchRequest.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/SearchRequest.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/SearchRequest.java Sun May 13 12:25:39 2007
@@ -0,0 +1,45 @@
+/****************************************************************
+ * 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.experimental.imapserver.message.request.imap4rev1;
+
+import javax.mail.search.SearchTerm;
+
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.processor.imap4rev1.SearchProcessor;
+
+public class SearchRequest extends AbstractImapRequest {
+    private final SearchTerm searchTerm;
+    private final boolean useUids;
+
+    public SearchRequest(final ImapCommand command, final SearchTerm searchTerm, final boolean useUids,
+            final String tag) {
+        super(tag, command, new SearchProcessor());
+        this.searchTerm = searchTerm;
+        this.useUids = useUids;
+    }
+
+    public final SearchTerm getSearchTerm() {
+		return searchTerm;
+	}
+
+	public final boolean isUseUids() {
+		return useUids;
+	}
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/SelectRequest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/SelectRequest.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/SelectRequest.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/SelectRequest.java Sun May 13 12:25:39 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.experimental.imapserver.message.request.imap4rev1;
+
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.processor.imap4rev1.ExamineAndSelectProcessor;
+
+public class SelectRequest extends AbstractImapRequest {
+    private final String mailboxName;
+    
+    public SelectRequest(final ImapCommand command, final String mailboxName, final String tag) {
+        super(tag, command, new ExamineAndSelectProcessor());
+        this.mailboxName = mailboxName;
+    }
+
+	public final String getMailboxName() {
+		return mailboxName;
+	}
+    
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/StatusRequest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/StatusRequest.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/StatusRequest.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/StatusRequest.java Sun May 13 12:25:39 2007
@@ -0,0 +1,43 @@
+/****************************************************************
+ * 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.experimental.imapserver.message.request.imap4rev1;
+
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.StatusDataItems;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.processor.imap4rev1.StatusProcessor;
+
+public class StatusRequest extends AbstractImapRequest {
+    private final String mailboxName;
+    private final StatusDataItems statusDataItems;
+    
+    public StatusRequest(final ImapCommand command, final String mailboxName, final StatusDataItems statusDataItems, final String tag) {
+        super(tag, command, new StatusProcessor());
+        this.mailboxName = mailboxName;
+        this.statusDataItems = statusDataItems;
+    }
+    
+    public final String getMailboxName() {
+		return mailboxName;
+	}
+
+	public final StatusDataItems getStatusDataItems() {
+		return statusDataItems;
+	}
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/StoreRequest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/StoreRequest.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/StoreRequest.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/StoreRequest.java Sun May 13 12:25:39 2007
@@ -0,0 +1,59 @@
+/****************************************************************
+ * 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.experimental.imapserver.message.request.imap4rev1;
+
+import javax.mail.Flags;
+
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.IdRange;
+import org.apache.james.experimental.imapserver.message.StoreDirective;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.processor.imap4rev1.StoreProcessor;
+
+public class StoreRequest extends AbstractImapRequest {
+    private final IdRange[] idSet;
+    private final StoreDirective directive;
+    private final Flags flags;
+    private final boolean useUids;
+    
+    public StoreRequest(final ImapCommand command, final IdRange[] idSet, final StoreDirective directive, final Flags flags, 
+            final boolean useUids, final String tag) {
+        super(tag, command, new StoreProcessor());
+        this.idSet = idSet;
+        this.directive = directive;
+        this.flags = flags;
+        this.useUids = useUids;
+    }
+    
+    public final StoreDirective getDirective() {
+		return directive;
+	}
+
+	public final Flags getFlags() {
+		return flags;
+	}
+
+	public final IdRange[] getIdSet() {
+		return idSet;
+	}
+
+	public final boolean isUseUids() {
+		return useUids;
+	}
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/SubscribeRequest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/SubscribeRequest.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/SubscribeRequest.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/SubscribeRequest.java Sun May 13 12:25:39 2007
@@ -0,0 +1,36 @@
+/****************************************************************
+ * 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.experimental.imapserver.message.request.imap4rev1;
+
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.processor.imap4rev1.SubscribeProcessor;
+
+public class SubscribeRequest extends AbstractImapRequest {
+    private final String mailboxName;
+    
+    public SubscribeRequest(final ImapCommand command, final String mailboxName, final String tag) {
+        super(tag, command, new SubscribeProcessor());
+        this.mailboxName = mailboxName;
+    }
+
+	public final String getMailboxName() {
+		return mailboxName;
+	}
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/UnsubscribeRequest.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/UnsubscribeRequest.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/UnsubscribeRequest.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/message/request/imap4rev1/UnsubscribeRequest.java Sun May 13 12:25:39 2007
@@ -0,0 +1,36 @@
+/****************************************************************
+ * 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.experimental.imapserver.message.request.imap4rev1;
+
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.processor.imap4rev1.UnsubscribeProcessor;
+
+public class UnsubscribeRequest extends AbstractImapRequest {
+    private final String mailboxName;
+
+    public UnsubscribeRequest(final ImapCommand command, final String mailboxName, final String tag) {
+        super(tag, command, new UnsubscribeProcessor());
+        this.mailboxName = mailboxName;
+    }
+
+	public final String getMailboxName() {
+		return mailboxName;
+	}
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/AbstractImapRequestProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/AbstractImapRequestProcessor.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/AbstractImapRequestProcessor.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/AbstractImapRequestProcessor.java Sun May 13 12:25:39 2007
@@ -0,0 +1,83 @@
+/****************************************************************
+ * 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.experimental.imapserver.processor;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.james.experimental.imapserver.AuthorizationException;
+import org.apache.james.experimental.imapserver.ImapSession;
+import org.apache.james.experimental.imapserver.ProtocolException;
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.CommandFailedResponseMessage;
+import org.apache.james.experimental.imapserver.message.ErrorResponseMessage;
+import org.apache.james.experimental.imapserver.message.ImapResponseMessage;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.store.MailboxException;
+
+abstract public class AbstractImapRequestProcessor extends AbstractLogEnabled implements ImapRequestProcessor {
+
+    public ImapResponseMessage process(AbstractImapRequest message, ImapSession session) {
+        ImapResponseMessage result;
+        final Logger logger = getLogger();
+        final ImapCommand command = message.getCommand();
+        final String tag = message.getTag();
+        try {
+            result = doProcess(message, command, tag, session);
+        }
+        catch ( MailboxException e ) {
+            if (logger != null) {
+                logger.debug("error processing command ", e);
+            }
+            result = new CommandFailedResponseMessage( command, e.getResponseCode(), 
+                    e.getMessage(), tag );
+        }
+        catch ( AuthorizationException e ) {
+            if (logger != null) {
+                logger.debug("error processing command ", e);
+            }
+            String msg = "Authorization error: Lacking permissions to perform requested operation.";
+            result = new CommandFailedResponseMessage( command, null, 
+                    msg, tag );
+        }
+        catch ( ProtocolException e ) {
+            if (logger != null) {
+                logger.debug("error processing command ", e);
+            }
+            String msg = e.getMessage() + " Command should be '" +
+                    command.getExpectedMessage() + "'";
+            result = new ErrorResponseMessage( msg, tag );
+        }
+        return result;
+    }
+    
+    final ImapResponseMessage doProcess(final AbstractImapRequest message, final ImapCommand command, 
+    		final String tag, ImapSession session) throws MailboxException, AuthorizationException, ProtocolException {
+        ImapResponseMessage result;
+        if ( !command.validForState( session.getState() ) ) {
+            result = 
+                new CommandFailedResponseMessage(command, 
+                        "Command not valid in this state", tag );
+        } else {
+            result = doProcess( message, session, tag, command );
+        }
+        return result;
+    }
+    
+    protected abstract ImapResponseMessage doProcess(final AbstractImapRequest message, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException;
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/ImapRequestProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/ImapRequestProcessor.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/ImapRequestProcessor.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/ImapRequestProcessor.java Sun May 13 12:25:39 2007
@@ -0,0 +1,43 @@
+/****************************************************************
+ * 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.experimental.imapserver.processor;
+
+import org.apache.james.experimental.imapserver.ImapSession;
+import org.apache.james.experimental.imapserver.message.ImapResponseMessage;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+
+/**
+ * <p>
+ * Processable IMAP command.
+ * </p>
+ * <p>
+ * <strong>Note:</strong> this is a transitional API
+ * and is liable to change.
+ * </p>
+ */
+public interface ImapRequestProcessor {
+    
+    /**
+     * Performs processing of the command.
+     * @param session <code>ImapSession</code> 
+     * @return response, not  null
+     */
+    ImapResponseMessage process(AbstractImapRequest message, ImapSession session );
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/AbstractListingProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/AbstractListingProcessor.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/AbstractListingProcessor.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/AbstractListingProcessor.java Sun May 13 12:25:39 2007
@@ -0,0 +1,147 @@
+/****************************************************************
+ * 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.experimental.imapserver.processor.imap4rev1;
+
+import org.apache.james.experimental.imapserver.AuthorizationException;
+import org.apache.james.experimental.imapserver.ImapConstants;
+import org.apache.james.experimental.imapserver.ImapSession;
+import org.apache.james.experimental.imapserver.ProtocolException;
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.ImapResponseMessage;
+import org.apache.james.experimental.imapserver.message.ListResponseMessage;
+import org.apache.james.experimental.imapserver.processor.AbstractImapRequestProcessor;
+import org.apache.james.experimental.imapserver.store.MailboxException;
+import org.apache.james.mailboxmanager.ListResult;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+import org.apache.james.mailboxmanager.impl.ListResultImpl;
+
+
+abstract class AbstractListingProcessor extends AbstractImapRequestProcessor {
+	
+	protected final ImapResponseMessage doProcess(final String baseReferenceName, final String mailboxPattern,
+			ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+
+        final ListResponseMessage result = new ListResponseMessage(command, tag);
+        String referenceName = baseReferenceName;
+        // Should the #user.userName section be removed from names returned?
+        boolean removeUserPrefix;
+
+        ListResult[] listResults;
+
+        String personalNamespace = ImapConstants.USER_NAMESPACE + ImapConstants.HIERARCHY_DELIMITER_CHAR +
+        session.getUser().getUserName();
+
+        if ( mailboxPattern.length() == 0 ) {
+            // An empty mailboxPattern signifies a request for the hierarchy delimiter
+            // and root name of the referenceName argument
+
+            String referenceRoot;
+            if ( referenceName.startsWith( ImapConstants.NAMESPACE_PREFIX ) )
+            {
+                // A qualified reference name - get the first element,
+                // and don't remove the user prefix
+                removeUserPrefix = false;
+                int firstDelimiter = referenceName.indexOf( ImapConstants.HIERARCHY_DELIMITER_CHAR );
+                if ( firstDelimiter == -1 ) {
+                    referenceRoot = referenceName;
+                }
+                else {
+                    referenceRoot = referenceName.substring(0, firstDelimiter );
+                }
+            }
+            else {
+                // A relative reference name - need to remove user prefix from results.
+                referenceRoot = "";
+                removeUserPrefix = true;
+
+            }
+
+            // Get the mailbox for the reference name.
+            listResults = new ListResult[1];
+            listResults[0]=new ListResultImpl(referenceRoot,ImapConstants.HIERARCHY_DELIMITER);
+        }
+        else {
+
+            // If the mailboxPattern is fully qualified, ignore the
+            // reference name.
+            if ( mailboxPattern.charAt( 0 ) == ImapConstants.NAMESPACE_PREFIX_CHAR ) {
+                referenceName="";
+            }
+
+            // If the search pattern is relative, need to remove user prefix from results.
+            removeUserPrefix = ( (referenceName+mailboxPattern).charAt(0) != ImapConstants.NAMESPACE_PREFIX_CHAR );
+
+            if (removeUserPrefix) {
+                referenceName=personalNamespace+"."+referenceName;
+            }
+
+            listResults = doList( session, referenceName, mailboxPattern );
+        }
+
+
+        int prefixLength = personalNamespace.length();
+
+        for (int i = 0; i < listResults.length; i++) {
+            StringBuffer message = new StringBuffer( "(" );
+            String[] attrs=listResults[i].getAttributes();
+            for (int j = 0; j < attrs.length; j++) {
+                if (j > 0) {
+                    message.append(' ');
+                }
+                message.append( attrs[j] );
+            }
+            message.append( ") \"" );
+            message.append( listResults[i].getHierarchyDelimiter() );
+            message.append( "\" " );
+
+            String mailboxName = listResults[i].getName();
+            if ( removeUserPrefix ) {
+                if ( mailboxName.length() <= prefixLength ) {
+                    mailboxName = "";
+                }
+                else {
+                    mailboxName = mailboxName.substring( prefixLength + 1 );
+                }
+            }
+
+            // TODO: need to check if the mailbox name needs quoting.
+            if ( mailboxName.length() == 0 ) {
+                message.append("\"\"");
+            }
+            else {
+                message.append( mailboxName );
+            }
+
+            result.addMessageData( message.toString() );
+        }
+        return result;
+    }
+    
+    protected abstract ListResult[] doList( ImapSession session, String base, String pattern ) throws MailboxException;
+    
+    protected final ListResult[] doList( ImapSession session, String base, String pattern, boolean subscribed ) throws MailboxException
+    {
+        try {
+            return session.getMailboxManager().list(base,pattern,false);
+        } catch (MailboxManagerException e) {
+            throw new MailboxException(e);  
+        }
+    }
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/AppendProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/AppendProcessor.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/AppendProcessor.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/AppendProcessor.java Sun May 13 12:25:39 2007
@@ -0,0 +1,91 @@
+/****************************************************************
+ * 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.experimental.imapserver.processor.imap4rev1;
+
+import java.util.Date;
+
+import javax.mail.internet.MimeMessage;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.james.experimental.imapserver.AuthorizationException;
+import org.apache.james.experimental.imapserver.ImapSession;
+import org.apache.james.experimental.imapserver.ProtocolException;
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.BadResponseMessage;
+import org.apache.james.experimental.imapserver.message.CommandCompleteResponseMessage;
+import org.apache.james.experimental.imapserver.message.ImapResponseMessage;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.message.request.imap4rev1.AppendRequest;
+import org.apache.james.experimental.imapserver.processor.AbstractImapRequestProcessor;
+import org.apache.james.experimental.imapserver.store.MailboxException;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
+
+
+public class AppendProcessor extends AbstractImapRequestProcessor {
+	
+	protected ImapResponseMessage doProcess(AbstractImapRequest message, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final ImapResponseMessage result;
+		if (message instanceof AppendRequest) {
+			final AppendRequest request = (AppendRequest) message;
+			result = doProcess(request, session, tag, command);
+		} else {
+			final Logger logger = getLogger();
+			if (logger != null)
+			{
+				logger.debug("Expected AppendRequest, was " + message);
+			}
+			result = new BadResponseMessage("Command unknown by Append processor.");
+		}
+		
+		return result;
+	}
+
+	private ImapResponseMessage doProcess(AppendRequest request, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final String mailboxName = request.getMailboxName();
+		final MimeMessage message = request.getMessage();
+		final Date datetime = request.getDatetime();
+		final ImapResponseMessage result = doProcess(mailboxName, message, datetime, session, tag, command);
+		return result;
+	}
+	
+	private ImapResponseMessage doProcess(String mailboxName, MimeMessage message, Date datetime, 
+			ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+        // TODO: Flags are ignore: check whether the specification says that they should be processed
+		ImapMailboxSession mailbox = null;
+        try {
+            mailboxName = session.buildFullName(mailboxName);
+            mailbox = session.getMailboxManager().getImapMailboxSession(mailboxName);
+        }
+        catch ( MailboxManagerException mme ) {
+            MailboxException me = new MailboxException(mme);
+            me.setResponseCode( "TRYCREATE" );
+            throw me;
+        }
+
+        try {
+            mailbox.appendMessage( message, datetime ,0);
+        } catch (MailboxManagerException e) {
+            // TODO why not TRYCREATE?
+            throw new MailboxException(e);
+        }
+        return new CommandCompleteResponseMessage(false, command, tag);
+	}
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/AuthenticateProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/AuthenticateProcessor.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/AuthenticateProcessor.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/AuthenticateProcessor.java Sun May 13 12:25:39 2007
@@ -0,0 +1,67 @@
+/****************************************************************
+ * 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.experimental.imapserver.processor.imap4rev1;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.james.experimental.imapserver.AuthorizationException;
+import org.apache.james.experimental.imapserver.ImapSession;
+import org.apache.james.experimental.imapserver.ProtocolException;
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.BadResponseMessage;
+import org.apache.james.experimental.imapserver.message.CommandFailedResponseMessage;
+import org.apache.james.experimental.imapserver.message.ImapResponseMessage;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.message.request.imap4rev1.AuthenticateRequest;
+import org.apache.james.experimental.imapserver.processor.AbstractImapRequestProcessor;
+import org.apache.james.experimental.imapserver.store.MailboxException;
+
+
+public class AuthenticateProcessor extends AbstractImapRequestProcessor {
+	
+	protected ImapResponseMessage doProcess(AbstractImapRequest message, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final ImapResponseMessage result;
+		if (message instanceof AuthenticateRequest) {
+			final AuthenticateRequest request = (AuthenticateRequest) message;
+			result = doProcess(request, session, tag, command);
+		} else {
+			final Logger logger = getLogger();
+			if (logger != null)
+			{
+				logger.debug("Expected AuthenticateRequest, was " + message);
+			}
+			result = new BadResponseMessage("Command unknown by Authenticate processor.");
+		}
+		
+		return result;
+	}
+
+	private ImapResponseMessage doProcess(AuthenticateRequest request, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final String authType = request.getAuthType();
+		final ImapResponseMessage result = doProcess(authType, session, tag, command);
+		return result;
+	}
+	
+	private ImapResponseMessage doProcess(String authType, 
+			ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+        final CommandFailedResponseMessage result = new CommandFailedResponseMessage(command, 
+                "Unsupported authentication mechanism '" + authType + "'", tag);
+        return result;
+	}
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CapabilityProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CapabilityProcessor.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CapabilityProcessor.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CapabilityProcessor.java Sun May 13 12:25:39 2007
@@ -0,0 +1,64 @@
+/****************************************************************
+ * 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.experimental.imapserver.processor.imap4rev1;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.james.experimental.imapserver.AuthorizationException;
+import org.apache.james.experimental.imapserver.ImapSession;
+import org.apache.james.experimental.imapserver.ProtocolException;
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.BadResponseMessage;
+import org.apache.james.experimental.imapserver.message.CapabilityReponseMessage;
+import org.apache.james.experimental.imapserver.message.ImapResponseMessage;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.message.request.imap4rev1.CapabilityRequest;
+import org.apache.james.experimental.imapserver.processor.AbstractImapRequestProcessor;
+import org.apache.james.experimental.imapserver.store.MailboxException;
+
+
+public class CapabilityProcessor extends AbstractImapRequestProcessor {
+	
+	protected ImapResponseMessage doProcess(AbstractImapRequest message, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final ImapResponseMessage result;
+		if (message instanceof CapabilityRequest) {
+			final CapabilityRequest request = (CapabilityRequest) message;
+			result = doProcess(request, session, tag, command);
+		} else {
+			final Logger logger = getLogger();
+			if (logger != null)
+			{
+				logger.debug("Expected CapabilityRequest, was " + message);
+			}
+			result = new BadResponseMessage("Command unknown by Capability processor.");
+		}
+		return result;
+	}
+
+	private ImapResponseMessage doProcess(CapabilityRequest request, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final ImapResponseMessage result = doProcess(session, tag, command);
+		return result;
+	}
+	
+	private ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+        // TODO: accurately report the capabilities of the server
+		final CapabilityReponseMessage result = new CapabilityReponseMessage(command, tag);
+        return result;
+	}
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CheckProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CheckProcessor.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CheckProcessor.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CheckProcessor.java Sun May 13 12:25:39 2007
@@ -0,0 +1,63 @@
+/****************************************************************
+ * 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.experimental.imapserver.processor.imap4rev1;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.james.experimental.imapserver.AuthorizationException;
+import org.apache.james.experimental.imapserver.ImapSession;
+import org.apache.james.experimental.imapserver.ProtocolException;
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.BadResponseMessage;
+import org.apache.james.experimental.imapserver.message.CommandCompleteResponseMessage;
+import org.apache.james.experimental.imapserver.message.ImapResponseMessage;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.message.request.imap4rev1.CheckRequest;
+import org.apache.james.experimental.imapserver.processor.AbstractImapRequestProcessor;
+import org.apache.james.experimental.imapserver.store.MailboxException;
+
+
+public class CheckProcessor extends AbstractImapRequestProcessor {
+	
+	protected ImapResponseMessage doProcess(AbstractImapRequest message, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final ImapResponseMessage result;
+		if (message instanceof CheckRequest) {
+			final CheckRequest request = (CheckRequest) message;
+			result = doProcess(request, session, tag, command);
+		} else {
+			final Logger logger = getLogger();
+			if (logger != null)
+			{
+				logger.debug("Expected CheckRequest, was " + message);
+			}
+			result = new BadResponseMessage("Command unknown by Check processor.");
+		}
+		return result;
+	}
+
+	private ImapResponseMessage doProcess(CheckRequest request, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final ImapResponseMessage result = doProcess(session, tag, command);
+		return result;
+	}
+	
+	private ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+        final CommandCompleteResponseMessage result = new CommandCompleteResponseMessage(false, command, tag);
+        return result;
+	}
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CloseProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CloseProcessor.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CloseProcessor.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CloseProcessor.java Sun May 13 12:25:39 2007
@@ -0,0 +1,76 @@
+/****************************************************************
+ * 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.experimental.imapserver.processor.imap4rev1;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.james.experimental.imapserver.AuthorizationException;
+import org.apache.james.experimental.imapserver.ImapSession;
+import org.apache.james.experimental.imapserver.ProtocolException;
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.BadResponseMessage;
+import org.apache.james.experimental.imapserver.message.CloseResponseMessage;
+import org.apache.james.experimental.imapserver.message.ImapResponseMessage;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.message.request.imap4rev1.CloseRequest;
+import org.apache.james.experimental.imapserver.processor.AbstractImapRequestProcessor;
+import org.apache.james.experimental.imapserver.store.MailboxException;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+import org.apache.james.mailboxmanager.MessageResult;
+import org.apache.james.mailboxmanager.impl.GeneralMessageSetImpl;
+import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
+
+
+public class CloseProcessor extends AbstractImapRequestProcessor {
+	
+	protected ImapResponseMessage doProcess(AbstractImapRequest message, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final ImapResponseMessage result;
+		if (message instanceof CloseRequest) {
+			final CloseRequest request = (CloseRequest) message;
+			result = doProcess(request, session, tag, command);
+		} else {
+			final Logger logger = getLogger();
+			if (logger != null)
+			{
+				logger.debug("Expected CloseRequest, was " + message);
+			}
+			result = new BadResponseMessage("Command unknown by Close processor.");
+		}
+		return result;
+	}
+
+	private ImapResponseMessage doProcess(CloseRequest request, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final ImapResponseMessage result = doProcess(session, tag, command);
+		return result;
+	}
+	
+	private ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+        ImapMailboxSession mailbox = session.getSelected().getMailbox();
+        if ( session.getSelected().getMailbox().isWriteable() ) {
+            try {
+                mailbox.expunge(GeneralMessageSetImpl.all(),MessageResult.NOTHING);
+            } catch (MailboxManagerException e) {
+               throw new MailboxException(e);
+            }
+        }
+        session.deselect();
+        final CloseResponseMessage result = new CloseResponseMessage(command, tag);
+        return result;
+	}
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CopyProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CopyProcessor.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CopyProcessor.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CopyProcessor.java Sun May 13 12:25:39 2007
@@ -0,0 +1,89 @@
+/****************************************************************
+ * 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.experimental.imapserver.processor.imap4rev1;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.james.experimental.imapserver.AuthorizationException;
+import org.apache.james.experimental.imapserver.ImapSession;
+import org.apache.james.experimental.imapserver.ProtocolException;
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.BadResponseMessage;
+import org.apache.james.experimental.imapserver.message.CommandCompleteResponseMessage;
+import org.apache.james.experimental.imapserver.message.IdRange;
+import org.apache.james.experimental.imapserver.message.ImapResponseMessage;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.message.request.imap4rev1.CopyRequest;
+import org.apache.james.experimental.imapserver.processor.AbstractImapRequestProcessor;
+import org.apache.james.experimental.imapserver.store.MailboxException;
+import org.apache.james.mailboxmanager.GeneralMessageSet;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+import org.apache.james.mailboxmanager.impl.GeneralMessageSetImpl;
+import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
+
+
+public class CopyProcessor extends AbstractImapRequestProcessor {
+	
+	protected ImapResponseMessage doProcess(AbstractImapRequest message, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final ImapResponseMessage result;
+		if (message instanceof CopyRequest) {
+			final CopyRequest request = (CopyRequest) message;
+			result = doProcess(request, session, tag, command);
+		} else {
+			final Logger logger = getLogger();
+			if (logger != null)
+			{
+				logger.debug("Expected CopyRequest, was " + message);
+			}
+			result = new BadResponseMessage("Command unknown by Copy processor.");
+		}
+		
+		return result;
+	}
+
+	private ImapResponseMessage doProcess(CopyRequest request, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final String mailboxName = request.getMailboxName();
+		final IdRange[] idSet = request.getIdSet();
+		final boolean useUids = request.isUseUids();
+		final ImapResponseMessage result = doProcess(mailboxName, idSet, useUids, session, tag, command);
+		return result;
+	}
+	
+	private ImapResponseMessage doProcess(String mailboxName, IdRange[] idSet, boolean useUids,
+			ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+        ImapMailboxSession currentMailbox = session.getSelected().getMailbox();
+        try {
+            String fullMailboxName = session.buildFullName(mailboxName);
+            if (!session.getMailboxManager().existsMailbox(fullMailboxName)) {
+                MailboxException e=new MailboxException("Mailbox does not exists");
+                e.setResponseCode( "TRYCREATE" );
+                throw e;
+            }
+            for (int i = 0; i < idSet.length; i++) {
+                GeneralMessageSet messageSet=GeneralMessageSetImpl.range(idSet[i].getLowVal(),idSet[i].getHighVal(),useUids);
+                session.getMailboxManager().copyMessages(currentMailbox,messageSet,fullMailboxName);
+            }
+        } catch (MailboxManagerException e) {
+            throw new MailboxException(e);
+        } 
+        final CommandCompleteResponseMessage result = 
+            new CommandCompleteResponseMessage(useUids, command, tag);
+        return result;
+	}
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CreateProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CreateProcessor.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CreateProcessor.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/CreateProcessor.java Sun May 13 12:25:39 2007
@@ -0,0 +1,73 @@
+/****************************************************************
+ * 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.experimental.imapserver.processor.imap4rev1;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.james.experimental.imapserver.AuthorizationException;
+import org.apache.james.experimental.imapserver.ImapSession;
+import org.apache.james.experimental.imapserver.ProtocolException;
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.BadResponseMessage;
+import org.apache.james.experimental.imapserver.message.CommandCompleteResponseMessage;
+import org.apache.james.experimental.imapserver.message.ImapResponseMessage;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.message.request.imap4rev1.CreateRequest;
+import org.apache.james.experimental.imapserver.processor.AbstractImapRequestProcessor;
+import org.apache.james.experimental.imapserver.store.MailboxException;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+
+
+public class CreateProcessor extends AbstractImapRequestProcessor {
+	
+	protected ImapResponseMessage doProcess(AbstractImapRequest message, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final ImapResponseMessage result;
+		if (message instanceof CreateRequest) {
+			final CreateRequest request = (CreateRequest) message;
+			result = doProcess(request, session, tag, command);
+		} else {
+			final Logger logger = getLogger();
+			if (logger != null)
+			{
+				logger.debug("Expected CreateRequest, was " + message);
+			}
+			result = new BadResponseMessage("Command unknown by Create processor.");
+		}
+		
+		return result;
+	}
+
+	private ImapResponseMessage doProcess(CreateRequest request, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final String mailboxName = request.getMailboxName();
+		final ImapResponseMessage result = doProcess(mailboxName, session, tag, command);
+		return result;
+	}
+	
+	private ImapResponseMessage doProcess(String mailboxName, 
+			ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+        try {
+
+            final String fullMailboxName=session.buildFullName(mailboxName);
+            session.getMailboxManager().createMailbox(fullMailboxName );
+        } catch (MailboxManagerException e) {
+           throw new MailboxException(e);
+        }
+        return new CommandCompleteResponseMessage(false, command, tag);
+	}
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/DeleteProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/DeleteProcessor.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/DeleteProcessor.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/DeleteProcessor.java Sun May 13 12:25:39 2007
@@ -0,0 +1,81 @@
+/****************************************************************
+ * 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.experimental.imapserver.processor.imap4rev1;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.james.experimental.imapserver.AuthorizationException;
+import org.apache.james.experimental.imapserver.ImapSession;
+import org.apache.james.experimental.imapserver.ProtocolException;
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.BadResponseMessage;
+import org.apache.james.experimental.imapserver.message.CommandCompleteResponseMessage;
+import org.apache.james.experimental.imapserver.message.ImapResponseMessage;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.message.request.imap4rev1.DeleteRequest;
+import org.apache.james.experimental.imapserver.processor.AbstractImapRequestProcessor;
+import org.apache.james.experimental.imapserver.store.MailboxException;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+
+
+public class DeleteProcessor extends AbstractImapRequestProcessor {
+	
+	protected ImapResponseMessage doProcess(AbstractImapRequest message, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final ImapResponseMessage result;
+		if (message instanceof DeleteRequest) {
+			final DeleteRequest request = (DeleteRequest) message;
+			result = doProcess(request, session, tag, command);
+		} else {
+			final Logger logger = getLogger();
+			if (logger != null)
+			{
+				logger.debug("Expected DeleteRequest, was " + message);
+			}
+			result = new BadResponseMessage("Command unknown by Delete processor.");
+		}
+		
+		return result;
+	}
+
+	private ImapResponseMessage doProcess(DeleteRequest request, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final String authType = request.getMailboxName();
+		final ImapResponseMessage result = doProcess(authType, session, tag, command);
+		return result;
+	}
+	
+	private ImapResponseMessage doProcess(String mailboxName, 
+			ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+        try {
+            final String fullMailboxName = session.buildFullName(mailboxName);
+            if (session.getSelected() != null) {
+                if (session.getSelected().getMailbox().getName().equals(
+                        fullMailboxName)) {
+                    session.deselect();
+                }
+            }
+            session.getMailboxManager().deleteMailbox(fullMailboxName);
+        } catch (MailboxManagerException e) {
+            throw new MailboxException(e);
+        }
+
+        final CommandCompleteResponseMessage result = 
+            new CommandCompleteResponseMessage(false, command, tag);
+        return result;
+	}
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/ExamineAndSelectProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/ExamineAndSelectProcessor.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/ExamineAndSelectProcessor.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/ExamineAndSelectProcessor.java Sun May 13 12:25:39 2007
@@ -0,0 +1,112 @@
+/****************************************************************
+ * 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.experimental.imapserver.processor.imap4rev1;
+
+import javax.mail.Flags;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.james.experimental.imapserver.AuthorizationException;
+import org.apache.james.experimental.imapserver.ImapSession;
+import org.apache.james.experimental.imapserver.ProtocolException;
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.BadResponseMessage;
+import org.apache.james.experimental.imapserver.message.ExamineAndSelectResponseMessage;
+import org.apache.james.experimental.imapserver.message.ImapResponseMessage;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.message.request.imap4rev1.ExamineRequest;
+import org.apache.james.experimental.imapserver.message.request.imap4rev1.SelectRequest;
+import org.apache.james.experimental.imapserver.processor.AbstractImapRequestProcessor;
+import org.apache.james.experimental.imapserver.store.MailboxException;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+import org.apache.james.mailboxmanager.MessageResult;
+import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
+
+
+public class ExamineAndSelectProcessor extends AbstractImapRequestProcessor {
+	
+	protected ImapResponseMessage doProcess(AbstractImapRequest message, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final ImapResponseMessage result;
+		if (message instanceof SelectRequest) {
+			final SelectRequest request = (SelectRequest) message;
+			result = doProcess(request, session, tag, command);
+			
+		} else if (message instanceof ExamineRequest) {
+			final ExamineRequest request = (ExamineRequest) message;
+			result = doProcess(request, session, tag, command);
+			
+		} else {
+			final Logger logger = getLogger();
+			if (logger != null)
+			{
+				logger.debug("Expected SelectRequest or ExamineRequest, was " + message);
+			}
+			result = new BadResponseMessage("Command unknown by Examine and Select processor.");
+		}
+		
+		return result;
+	}
+	
+	private ImapResponseMessage doProcess(ExamineRequest request, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final String mailboxName = request.getMailboxName();
+		final ImapResponseMessage result = doProcess(mailboxName, false, session, tag, command);
+		return result;
+	}
+
+	private ImapResponseMessage doProcess(SelectRequest request, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final String mailboxName = request.getMailboxName();
+		final ImapResponseMessage result = doProcess(mailboxName, false, session, tag, command);
+		return result;
+	}
+	
+	private ImapResponseMessage doProcess(String mailboxName, boolean isExamine,
+			ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+        ImapResponseMessage result;
+        session.deselect();
+        try {
+            String fullMailboxName=session.buildFullName(mailboxName);
+            selectMailbox(fullMailboxName, session, isExamine);
+            ImapMailboxSession mailbox = session.getSelected().getMailbox();
+            final Flags permanentFlags = mailbox.getPermanentFlags();
+            final boolean writeable = mailbox.isWriteable();
+            final boolean resetRecent = !isExamine;
+            final int recentCount = mailbox.getRecentCount(resetRecent);
+            final long uidValidity = mailbox.getUidValidity();
+            final MessageResult firstUnseen = mailbox.getFirstUnseen(MessageResult.MSN);
+            final int messageCount = mailbox.getMessageCount();
+            result = new ExamineAndSelectResponseMessage(command, permanentFlags, 
+                    writeable, recentCount, uidValidity, firstUnseen, messageCount,
+                    tag);
+        } catch (MailboxManagerException e) {
+            throw new MailboxException(e);
+        }
+        return result;
+	}
+    
+    private boolean selectMailbox(String mailboxName, ImapSession session, boolean readOnly) throws MailboxException, MailboxManagerException {
+        ImapMailboxSession mailbox = session.getMailboxManager().getImapMailboxSession(mailboxName);
+
+        if ( !mailbox.isSelectable() ) {
+            throw new MailboxException( "Nonselectable mailbox." );
+        }
+
+        session.setSelected( mailbox, readOnly );
+        return readOnly;
+    }
+}

Added: james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/ExpungeProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/ExpungeProcessor.java?view=auto&rev=537643
==============================================================================
--- james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/ExpungeProcessor.java (added)
+++ james/server/sandbox/seda-imap-modular/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/processor/imap4rev1/ExpungeProcessor.java Sun May 13 12:25:39 2007
@@ -0,0 +1,80 @@
+/****************************************************************
+ * 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.experimental.imapserver.processor.imap4rev1;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.james.experimental.imapserver.AuthorizationException;
+import org.apache.james.experimental.imapserver.ImapSession;
+import org.apache.james.experimental.imapserver.ProtocolException;
+import org.apache.james.experimental.imapserver.commands.ImapCommand;
+import org.apache.james.experimental.imapserver.message.BadResponseMessage;
+import org.apache.james.experimental.imapserver.message.CommandCompleteResponseMessage;
+import org.apache.james.experimental.imapserver.message.CommandFailedResponseMessage;
+import org.apache.james.experimental.imapserver.message.ImapResponseMessage;
+import org.apache.james.experimental.imapserver.message.request.AbstractImapRequest;
+import org.apache.james.experimental.imapserver.message.request.imap4rev1.ExpungeRequest;
+import org.apache.james.experimental.imapserver.processor.AbstractImapRequestProcessor;
+import org.apache.james.experimental.imapserver.store.MailboxException;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+import org.apache.james.mailboxmanager.MessageResult;
+import org.apache.james.mailboxmanager.impl.GeneralMessageSetImpl;
+import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
+
+
+public class ExpungeProcessor extends AbstractImapRequestProcessor {
+	
+	protected ImapResponseMessage doProcess(AbstractImapRequest message, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final ImapResponseMessage result;
+		if (message instanceof ExpungeRequest) {
+			final ExpungeRequest request = (ExpungeRequest) message;
+			result = doProcess(request, session, tag, command);
+		} else {
+			final Logger logger = getLogger();
+			if (logger != null)
+			{
+				logger.debug("Expected ExpungeRequest, was " + message);
+			}
+			result = new BadResponseMessage("Command unknown by Expunge processor.");
+		}
+		
+		return result;
+	}
+
+	private ImapResponseMessage doProcess(ExpungeRequest request, ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+		final ImapResponseMessage result = doProcess(session, tag, command);
+		return result;
+	}
+	
+	private ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+        ImapResponseMessage result;
+        ImapMailboxSession mailbox = session.getSelected().getMailbox();
+        if (!mailbox.isWriteable()) {
+            result = new CommandFailedResponseMessage(command, "Mailbox selected read only.", tag );
+        } else {
+            try {
+                mailbox.expunge(GeneralMessageSetImpl.all(),MessageResult.NOTHING);
+                result = new CommandCompleteResponseMessage(false, command, tag);
+            } catch (MailboxManagerException e) {
+                throw new MailboxException(e);
+            }
+        }
+        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