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 ma...@apache.org on 2019/11/12 21:37:24 UTC

[james-project] 02/15: [Refactoring] move the call to CharsetUtil.getAvailableCharsetNames() inside badCharset method

This is an automated email from the ASF dual-hosted git repository.

matthieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 909a919479ae0d25459ce986ca1f6c4a67de5fb9
Author: Matthieu Baechler <ma...@apache.org>
AuthorDate: Thu Nov 7 21:58:04 2019 +0100

    [Refactoring] move the call to CharsetUtil.getAvailableCharsetNames() inside badCharset method
---
 .../org/apache/james/imap/api/message/response/StatusResponse.java | 7 +++----
 .../org/apache/james/imap/decode/parser/SearchCommandParser.java   | 3 +--
 .../james/imap/decode/parser/SearchCommandParserCharsetTest.java   | 3 +--
 .../imap/decode/parser/SearchCommandParserQuotedCharsetTest.java   | 3 +--
 4 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/protocols/imap/src/main/java/org/apache/james/imap/api/message/response/StatusResponse.java b/protocols/imap/src/main/java/org/apache/james/imap/api/message/response/StatusResponse.java
index 9f74cb7..148ef69 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/api/message/response/StatusResponse.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/api/message/response/StatusResponse.java
@@ -26,6 +26,7 @@ import java.util.Collections;
 import javax.mail.Flags;
 
 import org.apache.james.imap.api.ImapCommand;
+import org.apache.james.imap.api.display.CharsetUtil;
 import org.apache.james.imap.api.display.HumanReadableText;
 import org.apache.james.imap.api.message.IdRange;
 import org.apache.james.imap.api.message.MessageFlags;
@@ -211,12 +212,10 @@ public interface StatusResponse extends ImapResponseMessage {
         /**
          * Creates a RFC2060 <code>BADCHARSET</code> response code.
          * 
-         * @param charsetNames
-         *            <code>Collection<String></code> containing charset names
          * @return <code>ResponseCode</code>, not null
          */
-        public static ResponseCode badCharset(Collection<String> charsetNames) {
-            return new ResponseCode("BADCHARSET", charsetNames);
+        public static ResponseCode badCharset() {
+            return new ResponseCode("BADCHARSET", CharsetUtil.getAvailableCharsetNames());
         }
 
         /**
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/SearchCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/SearchCommandParser.java
index 22dc639..546f671 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/SearchCommandParser.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/SearchCommandParser.java
@@ -28,7 +28,6 @@ import java.util.List;
 import org.apache.james.imap.api.ImapCommand;
 import org.apache.james.imap.api.ImapConstants;
 import org.apache.james.imap.api.ImapMessage;
-import org.apache.james.imap.api.display.CharsetUtil;
 import org.apache.james.imap.api.display.HumanReadableText;
 import org.apache.james.imap.api.message.IdRange;
 import org.apache.james.imap.api.message.UidRange;
@@ -904,7 +903,7 @@ public class SearchCommandParser extends AbstractUidCommandParser {
 
     private ImapMessage unsupportedCharset(String tag, ImapCommand command) {
         final StatusResponseFactory factory = getStatusResponseFactory();
-        final ResponseCode badCharset = StatusResponse.ResponseCode.badCharset(CharsetUtil.getAvailableCharsetNames());
+        final ResponseCode badCharset = StatusResponse.ResponseCode.badCharset();
         return factory.taggedNo(tag, command, HumanReadableText.BAD_CHARSET, badCharset);
     }
 
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java b/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java
index 80b772e..7255c28 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java
@@ -34,7 +34,6 @@ import java.nio.charset.StandardCharsets;
 
 import org.apache.james.imap.api.ImapCommand;
 import org.apache.james.imap.api.ImapMessage;
-import org.apache.james.imap.api.display.CharsetUtil;
 import org.apache.james.imap.api.display.HumanReadableText;
 import org.apache.james.imap.api.message.request.SearchKey;
 import org.apache.james.imap.api.message.response.StatusResponse;
@@ -96,7 +95,7 @@ public class SearchCommandParserCharsetTest {
             eq(TAG),
             same(command),
             eq(HumanReadableText.BAD_CHARSET),
-            eq(StatusResponse.ResponseCode.badCharset(CharsetUtil.getAvailableCharsetNames())));
+            eq(StatusResponse.ResponseCode.badCharset()));
 
         verifyNoMoreInteractions(mockStatusResponseFactory);
     }
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java b/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java
index 2533f77..a819196 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java
@@ -35,7 +35,6 @@ import java.nio.charset.StandardCharsets;
 
 import org.apache.james.imap.api.ImapCommand;
 import org.apache.james.imap.api.ImapMessage;
-import org.apache.james.imap.api.display.CharsetUtil;
 import org.apache.james.imap.api.display.HumanReadableText;
 import org.apache.james.imap.api.message.request.SearchKey;
 import org.apache.james.imap.api.message.response.StatusResponse;
@@ -181,7 +180,7 @@ public class SearchCommandParserQuotedCharsetTest {
             eq(TAG),
             same(command),
             eq(HumanReadableText.BAD_CHARSET),
-            eq(StatusResponse.ResponseCode.badCharset(CharsetUtil.getAvailableCharsetNames())));
+            eq(StatusResponse.ResponseCode.badCharset()));
         verifyNoMoreInteractions(mockStatusResponseFactory);
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org