You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by rd...@apache.org on 2007/02/04 14:46:24 UTC
svn commit: r503406 [1/3] - in /james/server/sandbox/seda-imap/src:
java/org/apache/james/imapserver/ java/org/apache/james/imapserver/commands/
java/org/apache/james/imapserver/encode/
java/org/apache/james/smtpserver/core/filter/fastfail/ test/org/ap...
Author: rdonkin
Date: Sun Feb 4 05:46:22 2007
New Revision: 503406
URL: http://svn.apache.org/viewvc?view=rev&rev=503406
Log:
Stage one of refactoring. Separated decoding (parsing), processing and encoding for each command.
Added:
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapResponseWriter.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractCommandResponseMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandCompleteResponseMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandFailedResponseMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ErrorResponseMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandParser.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapResponseMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/encode/
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/encode/OutputStreamImapResponseWriter.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/encode/RecordingImapResponseWriter.java
james/server/sandbox/seda-imap/src/test/org/apache/james/imapserver/ImapResponseTest.java
james/server/sandbox/seda-imap/src/test/org/apache/james/imapserver/MockImapResponseWriter.java
james/server/sandbox/seda-imap/src/test/org/apache/james/imapserver/MockImapSession.java
james/server/sandbox/seda-imap/src/test/org/apache/james/imapserver/commands/
james/server/sandbox/seda-imap/src/test/org/apache/james/imapserver/commands/CommandFailedResponseMessageTest.java
james/server/sandbox/seda-imap/src/test/org/apache/james/imapserver/commands/ErrorResponseMessageTest.java
james/server/sandbox/seda-imap/src/test/org/apache/james/imapserver/commands/MockCommand.java
james/server/sandbox/seda-imap/src/test/org/apache/james/imapserver/encode/
james/server/sandbox/seda-imap/src/test/org/apache/james/imapserver/encode/RecordingImapResponseWriterTest.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/ImapResponse.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapSession.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/AuthenticateCommand.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/CheckCommand.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/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/CreateCommand.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/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/FetchCommand.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/LoginCommand.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/NoopCommand.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/SearchCommand.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/StatusCommand.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/SubscribeCommand.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/UidEnabledCommand.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/smtpserver/core/filter/fastfail/ValidSenderDomainHandler.java
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=503406&r1=503405&r2=503406
==============================================================================
--- 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 Sun Feb 4 05:46:22 2007
@@ -24,6 +24,7 @@
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;
@@ -70,7 +71,8 @@
public void forceConnectionClose(final String message) {
getLogger().debug("forceConnectionClose: "+message);
- ImapResponse response = new ImapResponse(outs);
+ final OutputStreamImapResponseWriter writer = new OutputStreamImapResponseWriter(outs);
+ ImapResponse response = new ImapResponse(writer);
response.byeResponse(message);
endSession();
}
@@ -126,7 +128,8 @@
*/
protected void handleProtocol() throws IOException {
try {
- ImapResponse response = new ImapResponse( outs );
+ final OutputStreamImapResponseWriter writer = new OutputStreamImapResponseWriter( outs );
+ ImapResponse response = new ImapResponse( writer);
// Write welcome message
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=503406&r1=503405&r2=503406
==============================================================================
--- 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 Sun Feb 4 05:46:22 2007
@@ -27,6 +27,7 @@
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.encode.OutputStreamImapResponseWriter;
/**
* @version $Revision: 109034 $
@@ -71,7 +72,7 @@
return false;
}
- ImapResponse response = new ImapResponse( output );
+ ImapResponse response = new ImapResponse( new OutputStreamImapResponseWriter( output ));
response.enableLogging(getLogger());
doProcessRequest( request, response, session );
Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapResponse.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapResponse.java?view=diff&rev=503406&r1=503405&r2=503406
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapResponse.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapResponse.java Sun Feb 4 05:46:22 2007
@@ -19,29 +19,31 @@
package org.apache.james.imapserver;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-
import javax.mail.Flags;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.Logger;
import org.apache.james.imapserver.commands.ImapCommand;
import org.apache.james.imapserver.store.MessageFlags;
-import org.apache.james.util.InternetPrintWriter;
/**
* Class providing methods to send response messages from the server
* to the client.
*/
-public class ImapResponse extends AbstractLogEnabled implements ImapConstants {
+public class ImapResponse extends AbstractLogEnabled implements ImapConstants, ImapResponseWriter {
- private PrintWriter writer;
+ public static final String FETCH = "FETCH";
+ public static final String EXPUNGE = "EXPUNGE";
+ public static final String RECENT = "RECENT";
+ public static final String EXISTS = "EXISTS";
+ public static final String FLAGS = "FLAGS";
+ public static final String FAILED = "failed.";
+ private final ImapResponseWriter writer;
private String tag = UNTAGGED;
- public ImapResponse( OutputStream output )
+ public ImapResponse( final ImapResponseWriter writer )
{
- this.writer = new InternetPrintWriter( output, true );
+ this.writer = writer;
}
public void setTag( String tag )
@@ -112,11 +114,11 @@
message( NO );
responseCode( responseCode );
commandName( command );
- message( "failed." );
+ message( FAILED );
message( reason );
end();
final Logger logger = getLogger();
- if (logger.isInfoEnabled()) {
+ if (logger!= null && logger.isInfoEnabled()) {
logger.info("COMMAND FAILED [" + responseCode + "] - " + reason);
}
}
@@ -136,7 +138,7 @@
message( message );
end();
final Logger logger = getLogger();
- if (logger.isInfoEnabled()) {
+ if (logger != null && logger.isInfoEnabled()) {
logger.info("ERROR - " + message);
}
}
@@ -151,7 +153,7 @@
message( message );
end();
final Logger logger = getLogger();
- if (logger.isInfoEnabled()) {
+ if (logger != null && logger.isInfoEnabled()) {
logger.info("BAD - " + message);
}
}
@@ -174,7 +176,7 @@
public void flagsResponse( Flags flags )
{
untagged();
- message( "FLAGS" );
+ message( FLAGS );
message( MessageFlags.format(flags) );
end();
}
@@ -183,7 +185,7 @@
{
untagged();
message( count );
- message( "EXISTS" );
+ message( EXISTS );
end();
}
@@ -191,7 +193,7 @@
{
untagged();
message( count );
- message( "RECENT" );
+ message( RECENT );
end();
}
@@ -199,7 +201,7 @@
{
untagged();
message( msn );
- message( "EXPUNGE" );
+ message( EXPUNGE );
end();
}
@@ -207,7 +209,7 @@
{
untagged();
message( msn );
- message( "FETCH" );
+ message( FETCH );
message( "(" + msgData + ")" );
end();
}
@@ -250,50 +252,48 @@
untaggedResponse(BYE + SP + message);
}
- private void untagged()
+ public void untagged()
{
- writer.print( UNTAGGED );
+ writer.untagged();
}
private void tag()
{
- writer.print( tag );
+ writer.tag(tag);
}
- private void commandName( ImapCommand command )
+ private void commandName( final ImapCommand command )
{
- String name = command.getName();
- writer.print( SP );
- writer.print( name );
+ final String name = command.getName();
+ commandName(name);
+ }
+
+ public void commandName(final String name) {
+ writer.commandName(name);
}
- private void message( String message )
+ public void message( final String message )
{
if ( message != null ) {
- writer.print( SP );
- writer.print( message );
+ writer.message(message);
}
}
- private void message( int number )
+ public void message( final int number )
{
- writer.print( SP );
- writer.print( number );
+ writer.message(number);
}
- private void responseCode( String responseCode )
+ public void responseCode( final String responseCode )
{
if ( responseCode != null ) {
- writer.print( " [" );
- writer.print( responseCode );
- writer.print( "]" );
+ writer.responseCode(responseCode);
}
}
- private void end()
+ public void end()
{
- writer.println();
- writer.flush();
+ writer.end();
}
public void permanentFlagsResponse(Flags flags) {
@@ -301,5 +301,9 @@
message(OK);
responseCode("PERMANENTFLAGS " + MessageFlags.format(flags));
end();
+ }
+
+ public void tag(String tag) {
+ writer.tag(tag);
}
}
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapResponseWriter.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapResponseWriter.java?view=auto&rev=503406
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapResponseWriter.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapResponseWriter.java Sun Feb 4 05:46:22 2007
@@ -0,0 +1,66 @@
+/****************************************************************
+ * 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;
+
+/**
+ * <p>Writes IMAP response.</p>
+ * <p>Factors out basic IMAP reponse writing operations
+ * from higher level ones.</p>
+ */
+public interface ImapResponseWriter {
+
+ /**
+ * Starts an untagged response.
+ *
+ */
+ void untagged();
+
+ /**
+ * Starts a tagged response.
+ * @param tag the tag, not null
+ */
+ void tag(String tag);
+
+ /**
+ * Writes a command name.
+ * @param commandName the command name, not null
+ */
+ void commandName( String commandName );
+
+ /**
+ * Writes a message.
+ * @param message the message, not null
+ */
+ void message( String message );
+
+ void message( int number );
+
+ /**
+ * Writes a response code.
+ * @param responseCode the response code, not null
+ */
+ void responseCode( String responseCode );
+
+ /**
+ * Ends a response.
+ *
+ */
+ void end();
+}
Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapSession.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapSession.java?view=diff&rev=503406&r1=503405&r2=503406
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapSession.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/ImapSession.java Sun Feb 4 05:46:22 2007
@@ -39,6 +39,7 @@
/**
* Sends any unsolicited responses to the client, such as EXISTS and FLAGS
* responses when the selected mailbox is modified by another user.
+ * TODO: this probably should not throw a MailboxException
* @param response The response to write to
*/
void unsolicitedResponses( ImapResponse response, boolean useUid ) throws MailboxException;
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractCommandResponseMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractCommandResponseMessage.java?view=auto&rev=503406
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractCommandResponseMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractCommandResponseMessage.java Sun Feb 4 05:46:22 2007
@@ -0,0 +1,57 @@
+/****************************************************************
+ * 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.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.james.imapserver.ImapResponse;
+import org.apache.james.imapserver.ImapSession;
+import org.apache.james.imapserver.store.MailboxException;
+
+public abstract class AbstractCommandResponseMessage extends AbstractLogEnabled implements ImapResponseMessage {
+
+ private final ImapCommand command;
+
+ public AbstractCommandResponseMessage(final ImapCommand command) {
+ super();
+ this.command = command;
+ }
+
+ public ImapCommand getCommand() {
+ return command;
+ }
+
+ public void encode(ImapResponse response, ImapSession session) {
+ try {
+ doEncode(response, session, command);
+ } catch (MailboxException e) {
+ // TODO: it seems wrong for session to throw a mailbox exception
+ // TODO: really, errors in unsolicited response should not
+ // TODO: impact the execution of this command
+ final Logger logger = getLogger();
+ if (logger != null) {
+ logger.debug("error processing command ", e);
+ }
+ response.commandFailed( command, e.getResponseCode(), e.getMessage() );
+ }
+ }
+ abstract void doEncode(ImapResponse response, ImapSession session, ImapCommand command) throws MailboxException;
+
+}
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=503406&r1=503405&r2=503406
==============================================================================
--- 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 Sun Feb 4 05:46:22 2007
@@ -29,7 +29,6 @@
import javax.mail.internet.MimeMessage;
import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ImapResponse;
import org.apache.james.imapserver.ImapSession;
import org.apache.james.imapserver.ProtocolException;
import org.apache.james.imapserver.store.MailboxException;
@@ -47,13 +46,9 @@
public static final String ARGS = "<mailbox> [<flag_list>] [<date_time>] literal";
private AppendCommandParser parser = new AppendCommandParser();
+ private CommandCompleteResponseMessage response = new CommandCompleteResponseMessage(false, this);
- /** @see CommandTemplate#doProcess */
- protected void doProcess( ImapRequestLineReader request,
- ImapResponse response,
- ImapSession session )
- throws ProtocolException, MailboxException
- {
+ protected AbstractImapCommandMessage decode(ImapRequestLineReader request) throws ProtocolException {
String mailboxName = parser.mailbox( request );
Flags flags = parser.optionalAppendFlags( request );
if ( flags == null ) {
@@ -65,27 +60,10 @@
}
MimeMessage message = parser.mimeMessage( request );
parser.endLine( request );
-
- 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);
- }
-
- session.unsolicitedResponses( response, false);
- response.commandComplete( this );
+ // TODO: use an object pool
+ final AppendCommandMessage result = new AppendCommandMessage(mailboxName,
+ flags, datetime, message);
+ return result;
}
/** @see ImapCommand#getName */
@@ -100,8 +78,61 @@
return ARGS;
}
+ private class AppendCommandMessage extends AbstractImapCommandMessage {
+ private String mailboxName;
+ private Flags flags;
+ private Date datetime;
+ private MimeMessage message;
+
+ public AppendCommandMessage(String mailboxName, Flags flags,
+ Date datetime, MimeMessage message) {
+ super();
+ this.mailboxName = mailboxName;
+ this.flags = flags;
+ this.datetime = datetime;
+ this.message = message;
+ }
+
+ public Date getDatetime() {
+ return datetime;
+ }
+
+ public Flags getFlags() {
+ return flags;
+ }
+
+ public String getMailboxName() {
+ return mailboxName;
+ }
+
+ public MimeMessage getMessage() {
+ return message;
+ }
+
+ public ImapResponseMessage doProcess( final ImapSession session ) throws MailboxException {
+ 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 response;
+ }
+ }
+
private class AppendCommandParser extends CommandParser
- {
+ {
/**
* If the next character in the request is a '(', tries to read
* a "flag_list" argument from the request. If not, returns a
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=503406&r1=503405&r2=503406
==============================================================================
--- 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 Sun Feb 4 05:46:22 2007
@@ -19,10 +19,11 @@
package org.apache.james.imapserver.commands;
+import org.apache.james.imapserver.AuthorizationException;
import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ImapResponse;
import org.apache.james.imapserver.ImapSession;
import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.store.MailboxException;
/**
* Handles processeing for the AUTHENTICATE imap command.
@@ -33,20 +34,30 @@
{
public static final String NAME = "AUTHENTICATE";
public static final String ARGS = "<auth_type> *(CRLF base64)";
-
- /** @see CommandTemplate#doProcess */
- protected void doProcess( ImapRequestLineReader request,
- ImapResponse response,
- ImapSession session
- ) throws ProtocolException
- {
+
+ protected AbstractImapCommandMessage decode(ImapRequestLineReader request) throws ProtocolException {
String authType = parser.astring( request );
- parser.endLine( request );
-
- response.commandFailed( this, "Unsupported authentication mechanism '" +
- authType + "'" );
+ parser.endLine( request );
+ final AuthenticateCommandMessage result = new AuthenticateCommandMessage(authType);
+ return result;
}
+ private class AuthenticateCommandMessage extends AbstractImapCommandMessage {
+
+ private final String authType;
+
+ public AuthenticateCommandMessage(final String authType) {
+ this.authType = authType;
+ }
+
+ protected ImapResponseMessage doProcess(ImapSession session) throws MailboxException, AuthorizationException, ProtocolException {
+ final CommandFailedResponseMessage result = new CommandFailedResponseMessage(AuthenticateCommand.this,
+ "Unsupported authentication mechanism '" + authType + "'");
+ return result;
+ }
+
+ }
+
/** @see ImapCommand#getName */
public String getName()
{
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=503406&r1=503405&r2=503406
==============================================================================
--- 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 Sun Feb 4 05:46:22 2007
@@ -19,6 +19,7 @@
package org.apache.james.imapserver.commands;
+import org.apache.james.imapserver.AuthorizationException;
import org.apache.james.imapserver.ImapRequestLineReader;
import org.apache.james.imapserver.ImapResponse;
import org.apache.james.imapserver.ImapSession;
@@ -37,16 +38,11 @@
public static final String CAPABILITY_RESPONSE = NAME + SP + VERSION + SP + CAPABILITIES;
- /** @see CommandTemplate#doProcess */
- protected void doProcess( ImapRequestLineReader request,
- ImapResponse response,
- ImapSession session )
- throws ProtocolException, MailboxException
- {
+ private final CapabilityCommandMessage message = new CapabilityCommandMessage();
+
+ protected AbstractImapCommandMessage decode(ImapRequestLineReader request) throws ProtocolException {
parser.endLine( request );
- response.untaggedResponse( CAPABILITY_RESPONSE );
- session.unsolicitedResponses( response, false);
- response.commandComplete( this );
+ return message;
}
/** @see ImapCommand#getName */
@@ -59,6 +55,28 @@
public String getArgSyntax()
{
return ARGS;
+ }
+
+ private static class CapabilityReponseMessage extends AbstractCommandResponseMessage {
+
+ public CapabilityReponseMessage(ImapCommand command) {
+ super(command);
+ }
+
+ void doEncode(ImapResponse response, ImapSession session, ImapCommand command) throws MailboxException {
+ response.untaggedResponse( CAPABILITY_RESPONSE );
+ session.unsolicitedResponses( response, false);
+ response.commandComplete( command );
+ }
+
+ }
+
+ private class CapabilityCommandMessage extends AbstractImapCommandMessage {
+
+ protected ImapResponseMessage doProcess(ImapSession session) throws MailboxException, AuthorizationException, ProtocolException {
+ final CapabilityReponseMessage result = new CapabilityReponseMessage(CapabilityCommand.this);
+ return result;
+ }
}
}
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=503406&r1=503405&r2=503406
==============================================================================
--- 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 Sun Feb 4 05:46:22 2007
@@ -20,13 +20,10 @@
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.ProtocolException;
-import org.apache.james.imapserver.store.MailboxException;
/**
- * Handles processeing for the CHECK imap command.
+ * Handles processing for the CHECK imap command.
*
* @version $Revision: 109034 $
*/
@@ -35,14 +32,9 @@
public static final String NAME = "CHECK";
public static final String ARGS = null;
- /** @see CommandTemplate#doProcess */
- protected void doProcess( ImapRequestLineReader request,
- ImapResponse response,
- ImapSession session ) throws ProtocolException, MailboxException
- {
+ protected AbstractImapCommandMessage decode(ImapRequestLineReader request) throws ProtocolException {
parser.endLine( request );
- session.unsolicitedResponses( response , false);
- response.commandComplete( this );
+ return new CompleteCommandMessage(false);
}
/** @see ImapCommand#getName */
@@ -57,3 +49,30 @@
return ARGS;
}
}
+
+/*
+ 6.4.1. CHECK Command
+
+ Arguments: none
+
+ Responses: no specific responses for this command
+
+ Result: OK - check completed
+ BAD - command unknown or arguments invalid
+
+ The CHECK command requests a checkpoint of the currently selected
+ mailbox. A checkpoint refers to any implementation-dependent
+ housekeeping associated with the mailbox (e.g. resolving the
+ server's in-memory state of the mailbox with the state on its
+ disk) that is not normally executed as part of each command. A
+ checkpoint MAY take a non-instantaneous amount of real time to
+ complete. If a server implementation has no such housekeeping
+ considerations, CHECK is equivalent to NOOP.
+
+ There is no guarantee that an EXISTS untagged response will happen
+ as a result of CHECK. NOOP, not CHECK, SHOULD be used for new
+ mail polling.
+
+ Example: C: FXXZ CHECK
+ S: FXXZ OK CHECK Completed
+*/
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=503406&r1=503405&r2=503406
==============================================================================
--- 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 Sun Feb 4 05:46:22 2007
@@ -19,6 +19,7 @@
package org.apache.james.imapserver.commands;
+import org.apache.james.imapserver.AuthorizationException;
import org.apache.james.imapserver.ImapRequestLineReader;
import org.apache.james.imapserver.ImapResponse;
import org.apache.james.imapserver.ImapSession;
@@ -38,29 +39,45 @@
{
public static final String NAME = "CLOSE";
public static final String ARGS = null;
+
+ private final CloseCommandMessage message = new CloseCommandMessage();
+ private final CloseResponseMessage response = new CloseResponseMessage(this);
- /** @see CommandTemplate#doProcess */
- protected void doProcess( ImapRequestLineReader request,
- ImapResponse response,
- ImapSession session )
- throws ProtocolException, MailboxException
- {
- parser.endLine( request );
- ImapMailboxSession mailbox = session.getSelected().getMailbox();
- if ( session.getSelected().getMailbox().isWriteable() ) {
- try {
- mailbox.expunge(GeneralMessageSetImpl.all(),MessageResult.NOTHING);
- } catch (MailboxManagerException e) {
- throw new MailboxException(e);
- }
+ private static class CloseResponseMessage extends AbstractCommandResponseMessage {
+ public CloseResponseMessage(ImapCommand command) {
+ super(command);
+ }
+
+ void doEncode(ImapResponse response, ImapSession session, ImapCommand command) throws MailboxException {
+ //TODO: the following comment was present in the code before refactoring
+ //TODO: doesn't seem to match the implementation
+ //TODO: check that implementation is correct
+// Don't send unsolicited responses on close.
+ session.unsolicitedResponses( response, false );
+ response.commandComplete( command );
}
- session.deselect();
-
-// Don't send unsolicited responses on close.
- session.unsolicitedResponses( response, false );
- response.commandComplete( this );
}
+
+ private class CloseCommandMessage extends AbstractImapCommandMessage {
+ protected ImapResponseMessage doProcess(ImapSession session) 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();
+ return response;
+ }
+ }
+
+ protected AbstractImapCommandMessage decode(ImapRequestLineReader request) throws ProtocolException {
+ parser.endLine( request );
+ return message;
+ }
/** @see ImapCommand#getName */
public String getName()
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandCompleteResponseMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandCompleteResponseMessage.java?view=auto&rev=503406
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandCompleteResponseMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandCompleteResponseMessage.java Sun Feb 4 05:46:22 2007
@@ -0,0 +1,68 @@
+/****************************************************************
+ * 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;
+import org.apache.james.imapserver.store.MailboxException;
+
+public class CommandCompleteResponseMessage extends AbstractCommandResponseMessage implements ImapResponseMessage {
+
+ /**
+ * Creates a command completed response message that
+ * does not write unsolicited responses.
+ * @param command <code>ImapCommand</code>, not null
+ * @return <code>ImapResponseMessage</code>, not null
+ */
+ public static final ImapResponseMessage createWithNoUnsolictedResponses(final ImapCommand command) {
+ final CommandCompleteResponseMessage result = new CommandCompleteResponseMessage(command);
+ return result;
+ }
+
+ private final boolean useUids;
+ private final boolean writeUnsolicited;
+
+ private CommandCompleteResponseMessage(final ImapCommand command) {
+ super(command);
+ writeUnsolicited = false;
+ this.useUids = false;
+ }
+
+ /**
+ * Constructs a command completed response message
+ * that writes unsolicited responses.
+ *
+ * @see #createWithNoUnsolictedResponses(ImapCommand)
+ * @param useUids true if uids should be used, false otherwise
+ * @param command <code>ImapCommand</code>, not null
+ */
+ public CommandCompleteResponseMessage(final boolean useUids, final ImapCommand command) {
+ super(command);
+ writeUnsolicited = true;
+ this.useUids = useUids;
+ }
+
+ void doEncode(ImapResponse response, ImapSession session, ImapCommand command) throws MailboxException {
+ if (writeUnsolicited) {
+ session.unsolicitedResponses( response, useUids);
+ }
+ response.commandComplete( command );
+ }
+}
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandFailedResponseMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandFailedResponseMessage.java?view=auto&rev=503406
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandFailedResponseMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandFailedResponseMessage.java Sun Feb 4 05:46:22 2007
@@ -0,0 +1,50 @@
+/****************************************************************
+ * 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;
+
+class CommandFailedResponseMessage implements ImapResponseMessage {
+
+ private final ImapCommand command;
+ private final String responseCode;
+ private final String reason;
+
+ public CommandFailedResponseMessage(final ImapCommand command, final String reason) {
+ this(command, null, reason);
+ }
+
+ public CommandFailedResponseMessage(final ImapCommand command, final String responseCode, final String reason) {
+ super();
+ this.command = command;
+ this.responseCode = responseCode;
+ this.reason = reason;
+ }
+
+ public void encode(ImapResponse response, ImapSession session) {
+ if (responseCode == null) {
+ response.commandFailed(command, reason);
+ } else {
+ response.commandFailed(command, responseCode, reason);
+ }
+ }
+
+}
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=503406&r1=503405&r2=503406
==============================================================================
--- 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 Sun Feb 4 05:46:22 2007
@@ -20,6 +20,7 @@
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;
@@ -27,6 +28,7 @@
import org.apache.james.imapserver.ImapSession;
import org.apache.james.imapserver.ImapSessionState;
import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.encode.RecordingImapResponseWriter;
import org.apache.james.imapserver.store.MailboxException;
/**
@@ -37,7 +39,7 @@
*/
abstract class CommandTemplate
extends AbstractLogEnabled
- implements ImapCommand, ImapConstants
+ implements ImapCommand, ImapConstants, ImapCommandParser
{
protected CommandParser parser = new CommandParser();
@@ -82,6 +84,38 @@
}
}
+
+ /**
+ * Parses a request into a command message
+ * for later processing.
+ * @param request <code>ImapRequestLineReader</code>, not null
+ * @return <code>ImapCommandMessage</code>, not null
+ */
+ public ImapCommandMessage parse( ImapRequestLineReader request ) {
+ ImapCommandMessage message;
+ try {
+
+ message = decode(request);
+
+ } catch ( ProtocolException e ) {
+ getLogger().debug("error processing command ", e);
+ String msg = e.getMessage() + " Command should be '" +
+ getExpectedMessage() + "'";
+ message = new ErrorResponseMessage( msg );
+ }
+ return message;
+ }
+
+ /**
+ * Parses a request into a command message
+ * for later processing.
+ * @param request <code>ImapRequestLineReader</code>, not null
+ * @return <code>ImapCommandMessage</code>, not null
+ * @throws ProtocolException if the request cannot be parsed
+ */
+ protected abstract AbstractImapCommandMessage decode( ImapRequestLineReader request )
+ throws ProtocolException;
+
/**
* This is the method overridden by specific command implementations to
* perform commend-specific processing.
@@ -90,10 +124,14 @@
* @param response The server response
* @param session The current client session
*/
- protected abstract void doProcess( ImapRequestLineReader request,
+ protected final void doProcess( ImapRequestLineReader request,
ImapResponse response,
ImapSession session )
- throws ProtocolException, MailboxException, AuthorizationException;
+ throws ProtocolException, MailboxException, AuthorizationException {
+ AbstractImapCommandMessage message = decode( request );
+ ImapResponseMessage responseMessage = message.doProcess( session );
+ responseMessage.encode(response, session);
+ }
/**
* Provides a message which describes the expected format and arguments
@@ -132,5 +170,55 @@
public CommandParser getParser()
{
return parser;
+ }
+
+ protected abstract class AbstractImapCommandMessage implements ImapCommandMessage {
+
+ public ImapResponseMessage process(ImapSession session) {
+ ImapResponseMessage result;
+ final Logger logger = getLogger();
+ try {
+ result = doProcess( session );
+ }
+ catch ( MailboxException e ) {
+ if (logger != null) {
+ logger.debug("error processing command ", e);
+ }
+ result = new CommandFailedResponseMessage( CommandTemplate.this, e.getResponseCode(), e.getMessage() );
+ }
+ 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( CommandTemplate.this, null, msg );
+ }
+ catch ( ProtocolException e ) {
+ if (logger != null) {
+ logger.debug("error processing command ", e);
+ }
+ String msg = e.getMessage() + " Command should be '" +
+ getExpectedMessage() + "'";
+ result = new ErrorResponseMessage( msg );
+ }
+ return result;
+ }
+
+ protected abstract ImapResponseMessage doProcess(ImapSession session) throws MailboxException, AuthorizationException, ProtocolException;
+ }
+
+ protected class CompleteCommandMessage extends AbstractImapCommandMessage {
+
+ private final boolean useUids;
+
+ public CompleteCommandMessage(final boolean useUids) {
+ this.useUids = useUids;
+ }
+
+ protected ImapResponseMessage doProcess(ImapSession session) throws MailboxException, AuthorizationException, ProtocolException {
+ final CommandCompleteResponseMessage result = new CommandCompleteResponseMessage(useUids, CommandTemplate.this);
+ return result;
+ }
+
}
}
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=503406&r1=503405&r2=503406
==============================================================================
--- 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 Sun Feb 4 05:46:22 2007
@@ -19,8 +19,8 @@
package org.apache.james.imapserver.commands;
+import org.apache.james.imapserver.AuthorizationException;
import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ImapResponse;
import org.apache.james.imapserver.ImapSession;
import org.apache.james.imapserver.ProtocolException;
import org.apache.james.imapserver.store.MailboxException;
@@ -39,49 +39,6 @@
public static final String NAME = "COPY";
public static final String ARGS = "<message-set> <mailbox>";
- /** @see CommandTemplate#doProcess */
- protected void doProcess( ImapRequestLineReader request,
- ImapResponse response,
- ImapSession session )
- throws ProtocolException, MailboxException
- {
- doProcess( request, response, session, false );
- }
-
- public void doProcess( ImapRequestLineReader request,
- ImapResponse response,
- ImapSession session,
- boolean useUids)
- throws ProtocolException, MailboxException
- {
- IdRange[] idSet = parser.parseIdRange( request );
- String mailboxName = parser.mailbox( request );
- parser.endLine( request );
-
- ImapMailboxSession currentMailbox = session.getSelected().getMailbox();
-
-
- try {
- mailboxName=session.buildFullName(mailboxName);
- if (!session.getMailboxManager().existsMailbox(mailboxName)) {
- 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,mailboxName);
- }
- } catch (MailboxManagerException e) {
- throw new MailboxException(e);
- }
-
-
-
- session.unsolicitedResponses( response, useUids);
- response.commandComplete( this );
- }
-
/** @see ImapCommand#getName */
public String getName()
{
@@ -93,4 +50,82 @@
{
return ARGS;
}
+
+ private class CopyCommandMessage extends AbstractImapCommandMessage {
+
+ private final IdRange[] idSet;
+ private final String mailboxName;
+ private final boolean useUids;
+
+ public CopyCommandMessage(final IdRange[] idSet, final String mailboxName, final boolean useUids) {
+ super();
+ this.idSet = idSet;
+ this.mailboxName = mailboxName;
+ this.useUids = useUids;
+ }
+
+ protected ImapResponseMessage doProcess(ImapSession session) throws MailboxException, AuthorizationException, ProtocolException {
+ ImapMailboxSession currentMailbox = session.getSelected().getMailbox();
+ try {
+ String fullMailboxName = session.buildFullName(this.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, CopyCommand.this);
+ return result;
+ }
+ }
+
+ protected AbstractImapCommandMessage decode(ImapRequestLineReader request) throws ProtocolException {
+ return decode(request, false);
+ }
+
+ public AbstractImapCommandMessage decode(final ImapRequestLineReader request, final boolean useUids) throws ProtocolException {
+ IdRange[] idSet = parser.parseIdRange( request );
+ String mailboxName = parser.mailbox( request );
+ parser.endLine( request );
+ final CopyCommandMessage result = new CopyCommandMessage(idSet, mailboxName, useUids);
+ return result;
+ }
}
+/*
+6.4.7. COPY Command
+
+ Arguments: message set
+ mailbox name
+
+ Responses: no specific responses for this command
+
+ Result: OK - copy completed
+ NO - copy error: can't copy those messages or to that
+ name
+ BAD - command unknown or arguments invalid
+
+ The COPY command copies the specified message(s) to the end of the
+ specified destination mailbox. The flags and internal date of the
+ message(s) SHOULD be preserved in the copy.
+
+ If the destination mailbox does not exist, a server SHOULD return
+ an error. It SHOULD NOT automatically create the mailbox. Unless
+ it is certain that the destination mailbox can not be created, the
+ server MUST send the response code "[TRYCREATE]" as the prefix of
+ the text of the tagged NO response. This gives a hint to the
+ client that it can attempt a CREATE command and retry the COPY if
+ the CREATE is successful.
+
+ If the COPY command is unsuccessful for any reason, server
+ implementations MUST restore the destination mailbox to its state
+ before the COPY attempt.
+
+ Example: C: A003 COPY 2:4 MEETING
+ S: A003 OK COPY completed
+*/
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=503406&r1=503405&r2=503406
==============================================================================
--- 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 Sun Feb 4 05:46:22 2007
@@ -21,7 +21,6 @@
import org.apache.james.imapserver.AuthorizationException;
import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ImapResponse;
import org.apache.james.imapserver.ImapSession;
import org.apache.james.imapserver.ProtocolException;
import org.apache.james.imapserver.store.MailboxException;
@@ -37,27 +36,6 @@
public static final String NAME = "CREATE";
public static final String ARGS = "<mailbox>";
- /** @see CommandTemplate#doProcess */
- protected void doProcess( ImapRequestLineReader request,
- ImapResponse response,
- ImapSession session )
- throws ProtocolException, MailboxException, AuthorizationException
- {
- String mailboxName = parser.mailbox( request );
- parser.endLine( request );
-
-
- try {
-
- mailboxName=session.buildFullName(mailboxName);
- session.getMailboxManager().createMailbox(mailboxName );
- } catch (MailboxManagerException e) {
- throw new MailboxException(e);
- }
- session.unsolicitedResponses( response, false );
- response.commandComplete( this );
- }
-
/** @see ImapCommand#getName */
public String getName()
{
@@ -70,6 +48,30 @@
return ARGS;
}
+ protected AbstractImapCommandMessage decode(ImapRequestLineReader request) throws ProtocolException {
+ String mailboxName = parser.mailbox( request );
+ parser.endLine( request );
+ final CreateCommandMessage result = new CreateCommandMessage(mailboxName);
+ return result;
+ }
+
+ private class CreateCommandMessage extends AbstractImapCommandMessage {
+ private final String mailboxName;
+ public CreateCommandMessage(final String mailboxName) {
+ this.mailboxName = mailboxName;
+ }
+
+ protected ImapResponseMessage doProcess(ImapSession session) throws MailboxException, AuthorizationException, ProtocolException {
+ try {
+
+ final String fullMailboxName=session.buildFullName(this.mailboxName);
+ session.getMailboxManager().createMailbox(fullMailboxName );
+ } catch (MailboxManagerException e) {
+ throw new MailboxException(e);
+ }
+ return new CommandCompleteResponseMessage(false, CreateCommand.this);
+ }
+ }
}
/*
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=503406&r1=503405&r2=503406
==============================================================================
--- 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 Sun Feb 4 05:46:22 2007
@@ -21,12 +21,10 @@
import org.apache.james.imapserver.AuthorizationException;
import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ImapResponse;
import org.apache.james.imapserver.ImapSession;
import org.apache.james.imapserver.ProtocolException;
import org.apache.james.imapserver.store.MailboxException;
import org.apache.james.mailboxmanager.MailboxManagerException;
-import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
/**
* Handles processeing for the DELETE imap command.
@@ -38,33 +36,6 @@
public static final String NAME = "DELETE";
public static final String ARGS = "<mailbox>";
- /** @see CommandTemplate#doProcess */
- protected void doProcess( ImapRequestLineReader request,
- ImapResponse response,
- ImapSession session )
- throws ProtocolException, MailboxException, AuthorizationException
- {
-
- String mailboxName = parser.mailbox( request );
- parser.endLine( request );
-
- try {
- mailboxName = session.buildFullName(mailboxName);
- if (session.getSelected() != null) {
- if (session.getSelected().getMailbox().getName().equals(
- mailboxName)) {
- session.deselect();
- }
- }
- session.getMailboxManager().deleteMailbox(mailboxName);
- } catch (MailboxManagerException e) {
- throw new MailboxException(e);
- }
-
- session.unsolicitedResponses( response, false );
- response.commandComplete( this );
- }
-
/** @see ImapCommand#getName */
public String getName()
{
@@ -75,6 +46,41 @@
public String getArgSyntax()
{
return ARGS;
+ }
+
+ protected AbstractImapCommandMessage decode(ImapRequestLineReader request) throws ProtocolException {
+ String mailboxName = parser.mailbox( request );
+ parser.endLine( request );
+ final DeleteCommandMessage result = new DeleteCommandMessage(mailboxName);
+ return result;
+ }
+
+ private class DeleteCommandMessage extends AbstractImapCommandMessage {
+ private final String mailboxName;
+ public DeleteCommandMessage(final String mailboxName) {
+ super();
+ this.mailboxName = mailboxName;
+ }
+
+ protected ImapResponseMessage doProcess(ImapSession session) throws MailboxException, AuthorizationException, ProtocolException {
+ try {
+ final String fullMailboxName = session.buildFullName(this.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, DeleteCommand.this);
+ return result;
+ }
+
+
}
}
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ErrorResponseMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ErrorResponseMessage.java?view=auto&rev=503406
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ErrorResponseMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ErrorResponseMessage.java Sun Feb 4 05:46:22 2007
@@ -0,0 +1,44 @@
+/****************************************************************
+ * 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 an error response.
+ *
+ */
+public class ErrorResponseMessage implements ImapResponseMessage, ImapCommandMessage {
+
+ private final String message;
+
+ public ErrorResponseMessage(final String message) {
+ this.message = message;
+ }
+
+ public void encode(ImapResponse response, ImapSession session) {
+ response.commandError(message);
+ }
+
+ public ImapResponseMessage process(ImapSession session) {
+ return this;
+ }
+}
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=503406&r1=503405&r2=503406
==============================================================================
--- 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 Sun Feb 4 05:46:22 2007
@@ -20,12 +20,17 @@
package org.apache.james.imapserver.commands;
/**
+ * TODO: sort out inheritance heirarchy.
* @version $Revision: 109034 $
*/
class ExamineCommand extends SelectCommand
{
public static final String NAME = "EXAMINE";
+ public ExamineCommand() {
+ super(true);
+ }
+
public String getName()
{
return NAME;
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=503406&r1=503405&r2=503406
==============================================================================
--- 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 Sun Feb 4 05:46:22 2007
@@ -19,8 +19,8 @@
package org.apache.james.imapserver.commands;
+import org.apache.james.imapserver.AuthorizationException;
import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ImapResponse;
import org.apache.james.imapserver.ImapSession;
import org.apache.james.imapserver.ProtocolException;
import org.apache.james.imapserver.store.MailboxException;
@@ -38,29 +38,8 @@
{
public static final String NAME = "EXPUNGE";
public static final String ARGS = null;
-
- /** @see CommandTemplate#doProcess */
- protected void doProcess( ImapRequestLineReader request,
- ImapResponse response,
- ImapSession session )
- throws ProtocolException, MailboxException
- {
- parser.endLine( request );
-
- ImapMailboxSession mailbox = session.getSelected().getMailbox();
- if (!mailbox.isWriteable()) {
- response.commandFailed( this, "Mailbox selected read only." );
- }
-
- try {
- mailbox.expunge(GeneralMessageSetImpl.all(),MessageResult.NOTHING);
- } catch (MailboxManagerException e) {
- throw new MailboxException(e);
- }
-
- session.unsolicitedResponses( response, false );
- response.commandComplete( this );
- }
+
+ private ExpungeCommandMessage message = new ExpungeCommandMessage();
/** @see ImapCommand#getName */
public String getName()
@@ -72,6 +51,31 @@
public String getArgSyntax()
{
return ARGS;
+ }
+
+ protected AbstractImapCommandMessage decode(ImapRequestLineReader request) throws ProtocolException {
+ parser.endLine( request );
+ return message;
+ }
+
+ private class ExpungeCommandMessage extends AbstractImapCommandMessage {
+
+ protected ImapResponseMessage doProcess(ImapSession session) throws MailboxException, AuthorizationException, ProtocolException {
+ ImapResponseMessage result;
+ ImapMailboxSession mailbox = session.getSelected().getMailbox();
+ if (!mailbox.isWriteable()) {
+ result = new CommandFailedResponseMessage(ExpungeCommand.this, "Mailbox selected read only." );
+ } else {
+ try {
+ mailbox.expunge(GeneralMessageSetImpl.all(),MessageResult.NOTHING);
+ result = new CommandCompleteResponseMessage(false, ExpungeCommand.this);
+ } catch (MailboxManagerException e) {
+ throw new MailboxException(e);
+ }
+ }
+ return result;
+ }
+
}
}
/*
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=503406&r1=503405&r2=503406
==============================================================================
--- 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 Sun Feb 4 05:46:22 2007
@@ -34,6 +34,7 @@
import javax.mail.internet.MimeMessage;
import org.apache.james.core.MimeMessageWrapper;
+import org.apache.james.imapserver.AuthorizationException;
import org.apache.james.imapserver.ImapRequestLineReader;
import org.apache.james.imapserver.ImapResponse;
import org.apache.james.imapserver.ImapSession;
@@ -62,54 +63,6 @@
private FetchCommandParser parser = new FetchCommandParser();
- /** @see CommandTemplate#doProcess */
- protected void doProcess( ImapRequestLineReader request,
- ImapResponse response,
- ImapSession session )
- throws ProtocolException, MailboxException
- {
- doProcess( request, response, session, false );
- }
-
- public void doProcess( ImapRequestLineReader request,
- ImapResponse response,
- ImapSession session,
- boolean useUids )
- throws ProtocolException, MailboxException
- {
- IdRange[] idSet = parser.parseIdRange( request );
- FetchRequest fetch = parser.fetchRequest( request );
- parser.endLine( request );
-
- if (useUids) {
- fetch.uid = true;
- }
-
- // TODO only fetch needed results
- int resultToFetch = MessageResult.FLAGS | MessageResult.MIME_MESSAGE
- | MessageResult.INTERNAL_DATE | MessageResult.MSN
- | MessageResult.SIZE;
- ImapMailboxSession mailbox = session.getSelected().getMailbox();
- for (int i = 0; i < idSet.length; i++) {
- GeneralMessageSet messageSet=GeneralMessageSetImpl.range(idSet[i].getLowVal(),idSet[i].getHighVal(),useUids);
- MessageResult[] result;
- try {
- result = mailbox.getMessages(messageSet,resultToFetch);
- } catch (MailboxManagerException e) {
- throw new MailboxException(e);
- }
- for (int j = 0; j < result.length; j++) {
- String msgData = outputMessage( fetch, result[j], mailbox, useUids );
- response.fetchResponse( result[j].getMsn(), msgData );
-
- }
- }
-
- boolean omitExpunged = (!useUids);
- session.unsolicitedResponses( response, omitExpunged , useUids);
- response.commandComplete( this );
- }
-
private String outputMessage(FetchRequest fetch, MessageResult result,
ImapMailboxSession mailbox, boolean useUids)
throws MailboxException, ProtocolException {
@@ -548,6 +501,108 @@
}
}
+ protected AbstractImapCommandMessage decode(ImapRequestLineReader request) throws ProtocolException {
+ final AbstractImapCommandMessage result = decode(request, false);
+ return result;
+ }
+
+ public AbstractImapCommandMessage decode(ImapRequestLineReader request, boolean useUids) throws ProtocolException {
+ IdRange[] idSet = parser.parseIdRange( request );
+ FetchRequest fetch = parser.fetchRequest( request );
+ parser.endLine( request );
+
+ final FetchCommandMessage result = new FetchCommandMessage(useUids, idSet, fetch);
+ return result;
+ }
+
+ private class FetchCommandMessage extends AbstractImapCommandMessage {
+ private final boolean useUids;
+ private final IdRange[] idSet;
+ private final FetchRequest fetch;
+
+
+ public FetchCommandMessage(final boolean useUids, final IdRange[] idSet, final FetchRequest fetch) {
+ super();
+ this.useUids = useUids;
+ this.idSet = idSet;
+ this.fetch = fetch;
+ if (useUids) {
+ fetch.uid = true;
+ }
+ }
+
+
+ protected ImapResponseMessage doProcess(ImapSession session) throws MailboxException, AuthorizationException, ProtocolException {
+
+ FetchResponseMessage result = new FetchResponseMessage(FetchCommand.this, useUids);
+ // TODO only fetch needed results
+ int resultToFetch = MessageResult.FLAGS | MessageResult.MIME_MESSAGE
+ | MessageResult.INTERNAL_DATE | MessageResult.MSN
+ | MessageResult.SIZE;
+ ImapMailboxSession mailbox = session.getSelected().getMailbox();
+ for (int i = 0; i < idSet.length; i++) {
+ GeneralMessageSet messageSet=GeneralMessageSetImpl.range(idSet[i].getLowVal(),idSet[i].getHighVal(),useUids);
+ MessageResult[] fetchResults;
+ try {
+ fetchResults = mailbox.getMessages(messageSet,resultToFetch);
+ } catch (MailboxManagerException e) {
+ throw new MailboxException(e);
+ }
+ for (int j = 0; j < fetchResults.length; j++) {
+ String msgData = outputMessage( fetch, fetchResults[j], mailbox, useUids );
+ // TODO: this is inefficient
+ // TODO: stream output upon response
+ result.addMessageData(fetchResults[j].getMsn(), msgData );
+ }
+ }
+ return result;
+ }
+ }
+
+ private static class FetchResponseMessage extends AbstractCommandResponseMessage {
+
+ private final boolean useUids;
+
+ public FetchResponseMessage(final ImapCommand command, final boolean useUids) {
+ super(command);
+ this.useUids = useUids;
+ }
+
+ private List messages = new ArrayList();
+
+ public void addMessageData(int number, String messageData) {
+ final MessageData data = new MessageData(number, messageData);
+ messages.add(data);
+ }
+
+ void doEncode(ImapResponse response, ImapSession session, ImapCommand command) throws MailboxException {
+ for (final Iterator it=messages.iterator();it.hasNext();) {
+ MessageData data = (MessageData) it.next();
+ data.encode(response);
+ }
+ boolean omitExpunged = (!useUids);
+ session.unsolicitedResponses( response, omitExpunged , useUids);
+ response.commandComplete( command );
+
+ }
+
+ private class MessageData {
+ // TODO: this is not an efficient solution
+ // TODO: would be better to lazy load and stream on output
+ // TODO: this is just a transitional solution
+ private final int number;
+ private final String data;
+ public MessageData(final int number, final String data) {
+ super();
+ this.number = number;
+ this.data = data;
+ }
+
+ public void encode(ImapResponse response) {
+ response.fetchResponse(number, data);
+ }
+ }
+ }
}
/*
6.4.5. FETCH Command
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandMessage.java?view=auto&rev=503406
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandMessage.java Sun Feb 4 05:46:22 2007
@@ -0,0 +1,41 @@
+/****************************************************************
+ * 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.ImapSession;
+
+/**
+ * <p>
+ * Processable IMAP command.
+ * </p>
+ * <p>
+ * <strong>Note:</strong> this is a transitional API
+ * and is liable to change.
+ * </p>
+ */
+public interface ImapCommandMessage {
+
+ /**
+ * Performs processing of the command.
+ * @param session <code>ImapSession</code>
+ * @return response, not null
+ */
+ ImapResponseMessage process( ImapSession session );
+}
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandParser.java?view=auto&rev=503406
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandParser.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandParser.java Sun Feb 4 05:46:22 2007
@@ -0,0 +1,41 @@
+/****************************************************************
+ * 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;
+
+/**
+ * <p>
+ * Parses IMAP request into a command message.
+ * </p>
+ * <p>
+ * <strong>Note:</strong> this is a transitional API
+ * and is liable to change.
+ * </p>
+ */
+public interface ImapCommandParser {
+ /**
+ * Parses IMAP request.
+ * TODO: consider error handling
+ * @param request <code>ImapRequestLineReader</code>, not null
+ * @return <code>ImapCommandMessage</code>
+ */
+ ImapCommandMessage parse(ImapRequestLineReader request);
+}
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapResponseMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapResponseMessage.java?view=auto&rev=503406
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapResponseMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapResponseMessage.java Sun Feb 4 05:46:22 2007
@@ -0,0 +1,40 @@
+/****************************************************************
+ * 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;
+
+/**
+ * <p>Responds to an IMAP command.</p>
+ * <p>
+ * <strong>Note:</strong> this is a transitional API
+ * and is liable to change.
+ * </p>
+ */
+public interface ImapResponseMessage {
+
+ /**
+ * Writes response.
+ * @param response <code>ImapResponse</code>, not null
+ * @param session <code>ImapSession</code>, not null
+ */
+ void encode( ImapResponse response, ImapSession session );
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org