james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r644937 - in /james/server/trunk: imap-api/src/main/java/org/apache/james/api/imap/display/ imap-api/src/main/java/org/apache/james/api/imap/imap4rev1/ imap-codec-library/src/main/java/org/apache/james/imap/message/request/base/ imap-codec-...
Date Fri, 04 Apr 2008 21:22:45 GMT
Author: rdonkin
Date: Fri Apr  4 14:22:42 2008
New Revision: 644937

URL: http://svn.apache.org/viewvc?rev=644937&view=rev
Log:
Switch from deprecated to improved fault handling

Removed:
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/response/imap4rev1/legacy/BadResponse.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/BadResponseEncoder.java
    james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/BadResponseEncodeTest.java
Modified:
    james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java
    james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/imap4rev1/Imap4Rev1MessageFactory.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/base/BaseImap4Rev1MessageFactory.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/main/DefaultImapDecoder.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/main/DefaultImapEncoderFactory.java
    james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/base/UnknownRequestImapProcessor.java
    james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/main/DefaultImapProcessorFactory.java

Modified: james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java?rev=644937&r1=644936&r2=644937&view=diff
==============================================================================
--- james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java
(original)
+++ james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java
Fri Apr  4 14:22:42 2008
@@ -58,6 +58,10 @@
     = new HumanReadableTextKey("org.apache.james.imap.INVALID_COMMAND", 
             "failed. Command not valid in this state.");
     
+    public static final HumanReadableTextKey ILLEGAL_TAG
+    = new HumanReadableTextKey("org.apache.james.imap.ILLEGAL_TAG", 
+            "Illegal tag.");
+    
     public static final HumanReadableTextKey ILLEGAL_ARGUMENTS
     = new HumanReadableTextKey("org.apache.james.imap.ILLEGAL_ARGUMENTS", 
             "failed. Illegal arguments.");

Modified: james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/imap4rev1/Imap4Rev1MessageFactory.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/imap4rev1/Imap4Rev1MessageFactory.java?rev=644937&r1=644936&r2=644937&view=diff
==============================================================================
--- james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/imap4rev1/Imap4Rev1MessageFactory.java
(original)
+++ james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/imap4rev1/Imap4Rev1MessageFactory.java
Fri Apr  4 14:22:42 2008
@@ -47,7 +47,7 @@
      */
     public StatusResponse taggedBad(String tag, ImapCommand command, HumanReadableTextKey
displayTextKey);
     
-    public ImapMessage createBadRequestMessage(final String message);
+    public StatusResponse bye(HumanReadableTextKey message);
     
     public ImapMessage createAppendMessage(ImapCommand command, String mailboxName, Flags
flags, 
             Date datetime, MimeMessage message, String tag); 

Modified: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/base/BaseImap4Rev1MessageFactory.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/base/BaseImap4Rev1MessageFactory.java?rev=644937&r1=644936&r2=644937&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/base/BaseImap4Rev1MessageFactory.java
(original)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/request/base/BaseImap4Rev1MessageFactory.java
Fri Apr  4 14:22:42 2008
@@ -56,7 +56,6 @@
 import org.apache.james.imap.message.request.imap4rev1.StoreRequest;
 import org.apache.james.imap.message.request.imap4rev1.SubscribeRequest;
 import org.apache.james.imap.message.request.imap4rev1.UnsubscribeRequest;
-import org.apache.james.imap.message.response.imap4rev1.legacy.BadResponse;
 
 /**
  * Naive, factory creates unpooled instances.
@@ -159,11 +158,7 @@
     public ImapMessage createUnsubscribeMessage(ImapCommand command, String mailboxName,
String tag) {
         return new UnsubscribeRequest(command, mailboxName, tag);
     }
-
-    public ImapMessage createBadRequestMessage(String message) {
-        return new BadResponse(message);
-    }
-
+    
     public ImapMessage createCheckMessage(ImapCommand command, String tag) {
         return new CheckRequest(command, tag);
     }
@@ -171,5 +166,9 @@
     public StatusResponse taggedBad(String tag, ImapCommand command,
             HumanReadableTextKey displayTextKey) {
         return statusResponseFactory.taggedBad(tag, command, displayTextKey);
+    }
+
+    public StatusResponse bye(HumanReadableTextKey displayTextKey) {
+        return statusResponseFactory.bye(displayTextKey);
     }
 }

Modified: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/main/DefaultImapDecoder.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/main/DefaultImapDecoder.java?rev=644937&r1=644936&r2=644937&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/main/DefaultImapDecoder.java
(original)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/main/DefaultImapDecoder.java
Fri Apr  4 14:22:42 2008
@@ -60,8 +60,8 @@
             message = decodeCommandTagged(request, logger, tag);
         }
         catch ( ProtocolException e ) {
-            logger.debug("error parsing request", e);
-            message = messageFactory.createBadRequestMessage( REQUEST_SYNTAX );
+            logger.debug("Cannot parse tag", e);
+            message = messageFactory.bye(HumanReadableTextKey.ILLEGAL_TAG);
         }
         return message;
     }

Modified: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/main/DefaultImapEncoderFactory.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/main/DefaultImapEncoderFactory.java?rev=644937&r1=644936&r2=644937&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/main/DefaultImapEncoderFactory.java
(original)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/main/DefaultImapEncoderFactory.java
Fri Apr  4 14:22:42 2008
@@ -28,7 +28,6 @@
 import org.apache.james.imapserver.codec.encode.imap4rev1.FlagsResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.RecentResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.StatusResponseEncoder;
-import org.apache.james.imapserver.codec.encode.imap4rev1.legacy.BadResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.legacy.CapabilityResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.server.LSubResponseEncoder;
 import org.apache.james.imapserver.codec.encode.imap4rev1.server.ListResponseEncoder;
@@ -55,8 +54,7 @@
         final ListResponseEncoder listResponseEncoder = new ListResponseEncoder(lsubResponseEncoder);
         final FlagsResponseEncoder flagsResponseEncoder = new FlagsResponseEncoder(listResponseEncoder);
         final CapabilityResponseEncoder capabilityResponseEncoder = new CapabilityResponseEncoder(flagsResponseEncoder);
-        final BadResponseEncoder result = new BadResponseEncoder(capabilityResponseEncoder);
-        return result;
+        return capabilityResponseEncoder;
     }
 
     public ImapEncoder buildImapEncoder() {

Modified: james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/base/UnknownRequestImapProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/base/UnknownRequestImapProcessor.java?rev=644937&r1=644936&r2=644937&view=diff
==============================================================================
--- james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/base/UnknownRequestImapProcessor.java
(original)
+++ james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/base/UnknownRequestImapProcessor.java
Fri Apr  4 14:22:42 2008
@@ -21,15 +21,24 @@
 
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.logger.Logger;
+import org.apache.james.api.imap.ImapCommand;
 import org.apache.james.api.imap.ImapMessage;
+import org.apache.james.api.imap.display.HumanReadableTextKey;
 import org.apache.james.api.imap.message.request.ImapRequest;
 import org.apache.james.api.imap.message.response.ImapResponseMessage;
+import org.apache.james.api.imap.message.response.imap4rev1.StatusResponseFactory;
 import org.apache.james.api.imap.process.ImapProcessor;
 import org.apache.james.api.imap.process.ImapSession;
-import org.apache.james.imap.message.response.imap4rev1.legacy.BadResponse;
 
 public class UnknownRequestImapProcessor extends AbstractLogEnabled implements ImapProcessor
{
 
+    private final StatusResponseFactory factory;
+    
+    public UnknownRequestImapProcessor(StatusResponseFactory factory) {
+        super();
+        this.factory = factory;
+    }
+
     public ImapResponseMessage process(ImapMessage message, ImapSession session) {
         Logger logger = getLogger();
         if (logger != null && logger.isDebugEnabled()) {
@@ -38,9 +47,11 @@
         final ImapResponseMessage result;
         if (message instanceof ImapRequest) {
             ImapRequest request = (ImapRequest) message;
-            result = new BadResponse("Unknown command.", request.getTag());
+            final String tag = request.getTag();
+            final ImapCommand command = request.getCommand();
+            result = factory.taggedBad(tag, command, HumanReadableTextKey.UNKNOWN_COMMAND);
         } else {
-            result = new BadResponse("Unknown command.");
+            result = factory.untaggedBad(HumanReadableTextKey.UNKNOWN_COMMAND);
         }
         return result;
     }

Modified: james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/main/DefaultImapProcessorFactory.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/main/DefaultImapProcessorFactory.java?rev=644937&r1=644936&r2=644937&view=diff
==============================================================================
--- james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/main/DefaultImapProcessorFactory.java
(original)
+++ james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/main/DefaultImapProcessorFactory.java
Fri Apr  4 14:22:42 2008
@@ -40,7 +40,7 @@
     public static final ImapProcessor createDefaultProcessor(final UsersRepository usersRepository,
             final MailboxManagerProvider mailboxManagerProvider, final UserMetaDataRespository
userMetaDataRepository) {
         final StatusResponseFactory statusResponseFactory = new UnpooledStatusResponseFactory();
-        final UnknownRequestImapProcessor unknownRequestImapProcessor = new UnknownRequestImapProcessor();
+        final UnknownRequestImapProcessor unknownRequestImapProcessor = new UnknownRequestImapProcessor(statusResponseFactory);
         final IMAPSubscriber subscriber = new UserMetaDataIMAPSubscriber(userMetaDataRepository);
         final ImapProcessor imap4rev1Chain = Imap4Rev1ProcessorFactory.createDefaultChain(unknownRequestImapProcessor,

                 usersRepository, mailboxManagerProvider, statusResponseFactory, subscriber);



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