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 2009/05/11 10:45:25 UTC
svn commit: r773499 - in /james/imap/trunk:
api/src/main/java/org/apache/james/imap/api/display/
decode/src/main/java/org/apache/james/imap/decode/
decode/src/main/java/org/apache/james/imap/decode/base/
decode/src/main/java/org/apache/james/imap/decod...
Author: rdonkin
Date: Mon May 11 08:45:24 2009
New Revision: 773499
URL: http://svn.apache.org/viewvc?rev=773499&view=rev
Log:
Insist that ProtocolException uses HumanReadableTextKey. IMAP-72 https://issues.apache.org/jira/browse/IMAP-72
Modified:
james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableTextKey.java
james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/DecoderUtils.java
james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/FetchPartPathDecoder.java
james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java
james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/ProtocolException.java
james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/base/AbstractImapCommandParser.java
james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java
james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/SearchCommandParser.java
james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/StatusCommandParser.java
james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/StoreCommandParser.java
james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/UidCommandParser.java
Modified: james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableTextKey.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableTextKey.java?rev=773499&r1=773498&r2=773499&view=diff
==============================================================================
--- james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableTextKey.java (original)
+++ james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableTextKey.java Mon May 11 08:45:24 2009
@@ -139,6 +139,13 @@
"org.apache.james.imap.FAILURE_NO_SUCH_MAILBOX",
"failed. Mailbox already exists.");
+ public static final HumanReadableTextKey SOCKET_IO_FAILURE = new HumanReadableTextKey(
+ "org.apache.james.imap.SOCKET_IO_FAILURE",
+ "failed. IO failure.");
+
+ public static final HumanReadableTextKey BAD_IO_ENCODING = new HumanReadableTextKey(
+ "org.apache.james.imap.BAD_IO_ENCODING",
+ "failed. Illegal encoding.");
public static final HumanReadableTextKey COMPLETED = new HumanReadableTextKey(
"org.apache.james.imap.COMPLETED", "completed.");
Modified: james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/DecoderUtils.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/DecoderUtils.java?rev=773499&r1=773498&r2=773499&view=diff
==============================================================================
--- james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/DecoderUtils.java (original)
+++ james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/DecoderUtils.java Mon May 11 08:45:24 2009
@@ -27,6 +27,7 @@
import javax.mail.Flags;
+import org.apache.james.imap.api.display.HumanReadableTextKey;
import org.apache.james.imap.api.message.MessageFlags;
/**
@@ -152,7 +153,7 @@
.append(chars.toString()).toString();
}
- throw new ProtocolException(message);
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, message);
}
}
@@ -214,7 +215,8 @@
private static ProtocolException createTimeZoneException(
char zoneDeterminent, char zoneDigitOne, char zoneDigitTwo,
char zoneDigitThree, char zoneDigitFour) {
- return new ProtocolException("Expected time-zone but was "
+ return new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS,
+ "Expected time-zone but was "
+ zoneDeterminent + zoneDigitOne + zoneDigitTwo
+ zoneDigitThree + zoneDigitFour);
}
@@ -434,8 +436,8 @@
result = Calendar.DECEMBER;
break;
default:
- throw new ProtocolException("Expected month name but was "
- + monthFirstChar + monthSecondChar + monthThirdChar);
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS,
+ "Expected month name but was " + monthFirstChar + monthSecondChar + monthThirdChar);
}
return result;
}
@@ -455,8 +457,8 @@
case ' ':
return result;
}
- throw new ProtocolException("Expected SP, 0, 1, 2, or 3 but was "
- + dayHigh);
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS,
+ "Expected SP, 0, 1, 2, or 3 but was " + dayHigh);
}
/**
@@ -471,8 +473,8 @@
throws ProtocolException {
final int result = character - ASCII_ZERO;
if (result < 0 || result > 9) {
- throw new ProtocolException("Expected a digit but was '"
- + character + "'");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS,
+ "Expected a digit but was '" + character + "'");
}
return result;
}
Modified: james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/FetchPartPathDecoder.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/FetchPartPathDecoder.java?rev=773499&r1=773498&r2=773499&view=diff
==============================================================================
--- james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/FetchPartPathDecoder.java (original)
+++ james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/FetchPartPathDecoder.java Mon May 11 08:45:24 2009
@@ -22,6 +22,8 @@
import java.util.ArrayList;
import java.util.List;
+import org.apache.james.imap.api.display.HumanReadableTextKey;
+
public class FetchPartPathDecoder {
@@ -146,8 +148,8 @@
break;
default:
- throw new ProtocolException("Did not expect '" + next
- + "' here in body specification.");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS,
+ "Did not expect '" + next + "' here in body specification.");
}
} else {
storePartial();
@@ -164,7 +166,7 @@
mustBeE(sectionSpecification, at + 3);
storePartial();
} else {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
return MIME;
}
@@ -173,7 +175,7 @@
throws ProtocolException {
final char i = sectionSpecification.charAt(position);
if (!(i == 'i' || i == 'I')) {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
}
@@ -181,7 +183,7 @@
throws ProtocolException {
final char next = sectionSpecification.charAt(position);
if (!(next == 'm' || next == 'M')) {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
}
@@ -189,7 +191,7 @@
throws ProtocolException {
final char next = sectionSpecification.charAt(position);
if (!(next == 'n' || next == 'N')) {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
}
@@ -197,7 +199,7 @@
throws ProtocolException {
final char next = sectionSpecification.charAt(position);
if (!(next == 'o' || next == 'O')) {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
}
@@ -205,7 +207,7 @@
throws ProtocolException {
final char next = sectionSpecification.charAt(position);
if (!(next == 'e' || next == 'E')) {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
}
@@ -213,7 +215,7 @@
throws ProtocolException {
final char next = sectionSpecification.charAt(position);
if (!(next == 'a' || next == 'A')) {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
}
@@ -221,7 +223,7 @@
throws ProtocolException {
final char next = sectionSpecification.charAt(position);
if (!(next == 'd' || next == 'D')) {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
}
@@ -229,7 +231,7 @@
throws ProtocolException {
final char next = sectionSpecification.charAt(position);
if (!(next == 'r' || next == 'R')) {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
}
@@ -237,7 +239,7 @@
throws ProtocolException {
final char next = sectionSpecification.charAt(position);
if (!(next == 'x' || next == 'X')) {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
}
@@ -245,7 +247,7 @@
throws ProtocolException {
final char next = sectionSpecification.charAt(position);
if (!(next == 't' || next == 'T')) {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
}
@@ -253,7 +255,7 @@
throws ProtocolException {
final char next = sectionSpecification.charAt(position);
if (!(next == 'f' || next == 'F')) {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
}
@@ -261,7 +263,7 @@
throws ProtocolException {
final char next = sectionSpecification.charAt(position);
if (!(next == 'l' || next == 'L')) {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
}
@@ -269,7 +271,7 @@
throws ProtocolException {
final char next = sectionSpecification.charAt(position);
if (!(next == 's' || next == 'S')) {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
}
@@ -277,7 +279,7 @@
throws ProtocolException {
final char next = sectionSpecification.charAt(position);
if (!(next == '.')) {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
}
@@ -285,7 +287,7 @@
throws ProtocolException {
final char next = sectionSpecification.charAt(position);
if (!(next == '(')) {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
}
@@ -306,7 +308,7 @@
result = headerFields(at + 6, sectionSpecification);
}
} else {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
return result;
}
@@ -338,18 +340,18 @@
result = HEADER_NOT_FIELDS;
namesStartAt = skipSpaces(at + 11, sectionSpecification);
} else {
- throw new ProtocolException(
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS,
"Unknown body specification");
}
break;
default:
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
mustBeOpenParen(sectionSpecification, namesStartAt);
readHeaderNames(namesStartAt + 1, sectionSpecification);
} else {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
return result;
}
@@ -378,7 +380,7 @@
readHeaderNames(at + 1, lastWordStart, sectionSpecification);
}
} else {
- throw new ProtocolException("Closing parenthesis missing.");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Closing parenthesis missing.");
}
}
@@ -415,7 +417,7 @@
mustBeT(sectionSpecification, at + 3);
storePartial();
} else {
- throw new ProtocolException("Unknown body specification");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown body specification");
}
return TEXT;
}
Modified: james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java?rev=773499&r1=773498&r2=773499&view=diff
==============================================================================
--- james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java (original)
+++ james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java Mon May 11 08:45:24 2009
@@ -23,6 +23,8 @@
import java.io.InputStream;
import java.io.OutputStream;
+import org.apache.james.imap.api.display.HumanReadableTextKey;
+
/**
* Wraps the client input reader with a bunch of convenience methods, allowing
* lookahead=1 on the underlying character stream. TODO need to look at
@@ -62,7 +64,7 @@
}
if (next == '\r' || next == '\n') {
- throw new ProtocolException("Missing argument.");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Missing argument.");
}
return next;
@@ -86,10 +88,12 @@
try {
next = input.read();
} catch (IOException e) {
- throw new ProtocolException("Error reading from stream.", e);
+ throw new ProtocolException(HumanReadableTextKey.SOCKET_IO_FAILURE,
+ "Error reading from stream.", e);
}
if (next == -1) {
- throw new ProtocolException("Unexpected end of stream.");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS,
+ "Unexpected end of stream.");
}
nextSeen = true;
@@ -123,8 +127,8 @@
// Check if we found extra characters.
if (next != '\n') {
- throw new ProtocolException("Expected end-of-line, found '"
- + (char) next + "'.");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS,
+ "Expected end-of-line, found '" + (char) next + "'.");
}
}
@@ -165,7 +169,7 @@
count = input
.read(holder, readTotal, holder.length - readTotal);
if (count == -1) {
- throw new ProtocolException("Unexpected end of stream.");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unexpected end of stream.");
}
readTotal += count;
}
@@ -173,7 +177,8 @@
nextSeen = false;
nextChar = 0;
} catch (IOException e) {
- throw new ProtocolException("Error reading from stream.", e);
+ throw new ProtocolException(HumanReadableTextKey.SOCKET_IO_FAILURE,
+ "Error reading from stream.", e);
}
}
@@ -190,6 +195,7 @@
output.flush();
} catch (IOException e) {
throw new ProtocolException(
+ HumanReadableTextKey.SOCKET_IO_FAILURE,
"Unexpected exception in sending command continuation request.",
e);
}
Modified: james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/ProtocolException.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/ProtocolException.java?rev=773499&r1=773498&r2=773499&view=diff
==============================================================================
--- james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/ProtocolException.java (original)
+++ james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/ProtocolException.java Mon May 11 08:45:24 2009
@@ -19,6 +19,8 @@
package org.apache.james.imap.decode;
+import org.apache.james.imap.api.display.HumanReadableTextKey;
+
/**
* @version $Revision: 109034 $
*/
@@ -26,12 +28,25 @@
private static final long serialVersionUID = 8719349386686261422L;
- public ProtocolException(final String s) {
+ private final HumanReadableTextKey key;
+
+ public ProtocolException(final HumanReadableTextKey key, final String s) {
super(s);
+ this.key = key;
}
- public ProtocolException(final String s, final Throwable t) {
+ public ProtocolException(final HumanReadableTextKey key, final String s, final Throwable t) {
super(s, t);
+ this.key = key;
+ }
+
+ /**
+ * Gets the message key.
+ *
+ * @return the key, possibly null
+ */
+ public final HumanReadableTextKey getKey() {
+ return key;
}
}
Modified: james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/base/AbstractImapCommandParser.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/base/AbstractImapCommandParser.java?rev=773499&r1=773498&r2=773499&view=diff
==============================================================================
--- james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/base/AbstractImapCommandParser.java (original)
+++ james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/base/AbstractImapCommandParser.java Mon May 11 08:45:24 2009
@@ -194,7 +194,7 @@
if ("NIL".equals(value)) {
return null;
} else {
- throw new ProtocolException(
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS,
"Invalid nstring value: valid values are '\"...\"', '{12} CRLF *CHAR8', and 'NIL'.");
}
}
@@ -260,7 +260,7 @@
throws ProtocolException {
final char next = request.consume();
if (next != '-') {
- throw new ProtocolException("Expected dash but was " + next);
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Expected dash but was " + next);
}
}
@@ -274,7 +274,7 @@
if (next == '"') {
dateString = consumeQuoted(request);
} else {
- throw new ProtocolException("DateTime values must be quoted.");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "DateTime values must be quoted.");
}
return DecoderUtils.decodeDateTime(dateString);
@@ -295,7 +295,7 @@
atom.append(next);
request.consume();
} else {
- throw new ProtocolException("Invalid character: '" + next + "'");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Invalid character: '" + next + "'");
}
next = request.nextChar();
}
@@ -374,13 +374,13 @@
return result;
} catch (IllegalStateException e) {
- throw new ProtocolException("Bad character encoding", e);
+ throw new ProtocolException(HumanReadableTextKey.BAD_IO_ENCODING, "Bad character encoding", e);
} catch (MalformedInputException e) {
- throw new ProtocolException("Bad character encoding", e);
+ throw new ProtocolException(HumanReadableTextKey.BAD_IO_ENCODING, "Bad character encoding", e);
} catch (UnmappableCharacterException e) {
- throw new ProtocolException("Bad character encoding", e);
+ throw new ProtocolException(HumanReadableTextKey.BAD_IO_ENCODING, "Bad character encoding", e);
} catch (CharacterCodingException e) {
- throw new ProtocolException("Bad character encoding", e);
+ throw new ProtocolException(HumanReadableTextKey.BAD_IO_ENCODING, "Bad character encoding", e);
}
}
@@ -408,8 +408,8 @@
throws ProtocolException {
char consumed = request.consume();
if (consumed != expected) {
- throw new ProtocolException("Expected:'" + expected + "' found:'"
- + consumed + "'");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS,
+ "Expected:'" + expected + "' found:'" + consumed + "'");
}
}
@@ -510,7 +510,7 @@
case '\t':
return currentTotal;
default:
- throw new ProtocolException("Expected a digit but was " + next);
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Expected a digit but was " + next);
}
}
@@ -524,7 +524,7 @@
throws ProtocolException {
long number = number(request);
if (number == 0) {
- throw new ProtocolException("Zero value not permitted.");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Zero value not permitted.");
}
return number;
}
@@ -594,7 +594,7 @@
return new IdRange(lowVal, highVal);
}
} catch (NumberFormatException e) {
- throw new ProtocolException("Invalid message set.", e);
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Invalid message set.", e);
}
}
@@ -688,7 +688,7 @@
request.consume();
next = request.nextChar();
if (!isQuotedSpecial(next)) {
- throw new ProtocolException(
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS,
"Invalid escaped character in quote: '"
+ next + "'");
}
@@ -704,7 +704,7 @@
return result;
} catch (IllegalStateException e) {
- throw new ProtocolException("Bad character encoding", e);
+ throw new ProtocolException(HumanReadableTextKey.BAD_IO_ENCODING, "Bad character encoding", e);
}
}
@@ -720,7 +720,7 @@
upsizeCharBuffer();
flush();
} else if (coderResult.isError()) {
- throw new ProtocolException("Bad character encoding");
+ throw new ProtocolException(HumanReadableTextKey.BAD_IO_ENCODING, "Bad character encoding");
}
}
@@ -745,7 +745,7 @@
upsizeCharBuffer();
return decodeMoreBytesToCharacterBuffer(endOfInput);
} else if (coderResult.isError()) {
- throw new ProtocolException("Bad character encoding");
+ throw new ProtocolException(HumanReadableTextKey.BAD_IO_ENCODING, "Bad character encoding");
} else if (coderResult.isUnderflow()) {
buffer.clear();
}
Modified: james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java?rev=773499&r1=773498&r2=773499&view=diff
==============================================================================
--- james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java (original)
+++ james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java Mon May 11 08:45:24 2009
@@ -25,6 +25,7 @@
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.HumanReadableTextKey;
import org.apache.james.imap.api.message.BodyFetchElement;
import org.apache.james.imap.api.message.FetchData;
import org.apache.james.imap.api.message.IdRange;
@@ -103,7 +104,7 @@
} else if ("RFC822.TEXT".equalsIgnoreCase(name)) {
fetch.add(BodyFetchElement.createRFC822Text(), false);
} else {
- throw new ProtocolException("Invalid fetch attribute: " + name);
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Invalid fetch attribute: " + name);
}
} else {
consumeChar(reader, '[');
@@ -143,8 +144,8 @@
} else if ("BODY.PEEK".equalsIgnoreCase(name)) {
isPeek = true;
} else {
- throw new ProtocolException("Invalid fetch attibute: " + name
- + "[]");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS,
+ "Invalid fetch attibute: " + name + "[]");
}
return isPeek;
}
@@ -188,7 +189,7 @@
sectionType = BodyFetchElement.TEXT;
break;
default:
- throw new ProtocolException("Section type is unsupported.");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Section type is unsupported.");
}
return sectionType;
}
Modified: james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/SearchCommandParser.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/SearchCommandParser.java?rev=773499&r1=773498&r2=773499&view=diff
==============================================================================
--- james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/SearchCommandParser.java (original)
+++ james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/SearchCommandParser.java Mon May 11 08:45:24 2009
@@ -81,31 +81,31 @@
case 'D':
return d(request);
case 'E':
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
case 'F':
return f(request, charset);
case 'G':
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
case 'H':
return header(request, charset);
case 'I':
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
case 'J':
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
case 'K':
return keyword(request);
case 'L':
return larger(request);
case 'M':
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
case 'N':
return n(request, charset);
case 'O':
return o(request, charset);
case 'P':
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
case 'Q':
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
case 'R':
return recent(request);
case 'S':
@@ -115,7 +115,7 @@
case 'U':
return u(request);
default:
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
}
@@ -167,7 +167,7 @@
case 'H':
return charset(request, isFirstToken);
default:
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
@@ -182,7 +182,7 @@
nextIsT(request);
nextIsSpace(request);
if (!isFirstToken) {
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
final String value = astring(request);
final Charset charset = Charset.forName(value);
@@ -199,7 +199,7 @@
case 'N':
return un(request);
default:
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
@@ -218,7 +218,7 @@
case 'S':
return unseen(request);
default:
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
@@ -231,7 +231,7 @@
case 'R':
return undraft(request);
default:
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
@@ -244,7 +244,7 @@
case 'O':
return to(request, charset);
default:
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
@@ -261,7 +261,7 @@
case 'U':
return subject(request, charset);
default:
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
@@ -274,7 +274,7 @@
case 'N':
return sen(request);
default:
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
@@ -285,7 +285,7 @@
case 'T':
return sent(request);
default:
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
@@ -300,7 +300,7 @@
case 'S':
return sentSince(request);
default:
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
@@ -315,7 +315,7 @@
case 'R':
return or(request, charset);
default:
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
@@ -328,7 +328,7 @@
case 'O':
return not(request, charset);
default:
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
@@ -341,7 +341,7 @@
case 'R':
return from(request, charset);
default:
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
@@ -353,7 +353,7 @@
case 'R':
return draft(request);
default:
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
@@ -603,7 +603,7 @@
case 'O':
return body(request, charset);
default:
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
@@ -758,7 +758,7 @@
case 'N':
return answered(request);
default:
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
@@ -787,7 +787,7 @@
throws ProtocolException {
final char next = request.consume();
if (next != ' ') {
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
@@ -890,7 +890,7 @@
final char lower) throws ProtocolException {
final char next = request.consume();
if (next != upper && next != lower) {
- throw new ProtocolException("Unknown search key");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
Modified: james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/StatusCommandParser.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/StatusCommandParser.java?rev=773499&r1=773498&r2=773499&view=diff
==============================================================================
--- james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/StatusCommandParser.java (original)
+++ james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/StatusCommandParser.java Mon May 11 08:45:24 2009
@@ -23,6 +23,7 @@
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.HumanReadableTextKey;
import org.apache.james.imap.api.message.StatusDataItems;
import org.apache.james.imap.decode.ImapRequestLineReader;
import org.apache.james.imap.decode.ProtocolException;
@@ -67,8 +68,8 @@
} else if (nextWord.equals(ImapConstants.STATUS_UNSEEN)) {
items.setUnseen(true);
} else {
- throw new ProtocolException("Unknown status item: '" + nextWord
- + "'");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS,
+ "Unknown status item: '" + nextWord + "'");
}
}
Modified: james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/StoreCommandParser.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/StoreCommandParser.java?rev=773499&r1=773498&r2=773499&view=diff
==============================================================================
--- james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/StoreCommandParser.java (original)
+++ james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/StoreCommandParser.java Mon May 11 08:45:24 2009
@@ -24,6 +24,7 @@
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.HumanReadableTextKey;
import org.apache.james.imap.api.message.IdRange;
import org.apache.james.imap.decode.ImapRequestLineReader;
import org.apache.james.imap.decode.ProtocolException;
@@ -58,8 +59,8 @@
} else if ("FLAGS.SILENT".equalsIgnoreCase(directive)) {
silent = true;
} else {
- throw new ProtocolException("Invalid Store Directive: '"
- + directive + "'");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS,
+ "Invalid Store Directive: '" + directive + "'");
}
final Flags flags = flagList(request);
Modified: james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/UidCommandParser.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/UidCommandParser.java?rev=773499&r1=773498&r2=773499&view=diff
==============================================================================
--- james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/UidCommandParser.java (original)
+++ james/imap/trunk/decode/src/main/java/org/apache/james/imap/decode/parser/UidCommandParser.java Mon May 11 08:45:24 2009
@@ -22,6 +22,7 @@
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.HumanReadableTextKey;
import org.apache.james.imap.decode.DelegatingImapCommandParser;
import org.apache.james.imap.decode.ImapCommandParser;
import org.apache.james.imap.decode.ImapCommandParserFactory;
@@ -64,8 +65,8 @@
// TODO: replace abstract class with interface
if (helperCommand == null
|| !(helperCommand instanceof AbstractUidCommandParser)) {
- throw new ProtocolException("Invalid UID command: '" + commandName
- + "'");
+ throw new ProtocolException(HumanReadableTextKey.ILLEGAL_ARGUMENTS,
+ "Invalid UID command: '" + commandName + "'");
}
final AbstractUidCommandParser uidEnabled = (AbstractUidCommandParser) helperCommand;
final ImapMessage result = uidEnabled.decode(request, tag, true, logger);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org