Author: norman Date: Wed Aug 2 22:55:20 2006 New Revision: 428250 URL: http://svn.apache.org/viewvc?rev=428250&view=rev Log: Commit some changes to show the others the procress
Added: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/IOObject.java Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/Chain.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/CommandHandler.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/ConnectHandler.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/MessageHandler.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPHandler.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPResponse.java james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPSession.java Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/Chain.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/Chain.java?rev=428250&r1=428249&r2=428250&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/Chain.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/Chain.java Wed Aug 2 22:55:20 2006 @@ -25,7 +25,7 @@ * The Chain which contain the handlers for the current command or state * */ -public class Chain { +public class Chain implements IOObject{ private Iterator handlers; @@ -43,25 +43,24 @@ * * @param session The SMTPSession */ - public void doChain(SMTPSession session) { - - // should never happen - if (handlers == null) - return; + public SMTPResponse nextHandler(SMTPSession session) { if (handlers.hasNext()) { + Object handler = handlers.next(); if (handler instanceof ConnectHandler) { - ((ConnectHandler) handler).onConnect(session, this); + ((ConnectHandler) handler).onConnect(session); + return null; } else if (handler instanceof CommandHandler) { // reset the idle timeout session.getWatchdog().reset(); - ((CommandHandler) handler).onCommand(session, this); + ((CommandHandler) handler).onCommand(session); } else if (handler instanceof MessageHandler) { - ((MessageHandler) handler).onMessage(session, this); + ((MessageHandler) handler).onMessage(session); } } + return session.getSMTPResponse(); } } Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/CommandHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/CommandHandler.java?rev=428250&r1=428249&r2=428250&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/CommandHandler.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/CommandHandler.java Wed Aug 2 22:55:20 2006 @@ -35,7 +35,7 @@ /** * Handle the command **/ - void onCommand(SMTPSession session, Chain chain); + SMTPResponse onCommand(SMTPSession session); /** * Return a Collection of implemented commands Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/ConnectHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/ConnectHandler.java?rev=428250&r1=428249&r2=428250&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/ConnectHandler.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/ConnectHandler.java Wed Aug 2 22:55:20 2006 @@ -32,6 +32,6 @@ /* * Handle connection **/ - void onConnect(SMTPSession session, Chain chain); + void onConnect(SMTPSession session); } Added: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/IOObject.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/IOObject.java?rev=428250&view=auto ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/IOObject.java (added) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/IOObject.java Wed Aug 2 22:55:20 2006 @@ -0,0 +1,5 @@ +package org.apache.james.smtpserver; +public interface IOObject { + SMTPResponse nextHandler(SMTPSession session); +} + Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/MessageHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/MessageHandler.java?rev=428250&r1=428249&r2=428250&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/MessageHandler.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/MessageHandler.java Wed Aug 2 22:55:20 2006 @@ -31,6 +31,6 @@ /* * Handle Message **/ - void onMessage(SMTPSession session, Chain chain); + SMTPResponse onMessage(SMTPSession session); } Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPHandler.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPHandler.java?rev=428250&r1=428249&r2=428250&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPHandler.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPHandler.java Wed Aug 2 22:55:20 2006 @@ -17,8 +17,6 @@ * under the License. * ****************************************************************/ - - package org.apache.james.smtpserver; import org.apache.avalon.framework.container.ContainerUtil; @@ -47,23 +45,24 @@ * * @version CVS $Revision$ $Date$ */ -public class SMTPHandler - extends AbstractJamesHandler - implements SMTPSession { +public class SMTPHandler extends AbstractJamesHandler implements SMTPSession { /** * The constants to indicate the current processing mode of the session */ private final static byte COMMAND_MODE = 1; + private final static byte RESPONSE_MODE = 2; + private final static byte MESSAGE_RECEIVED_MODE = 3; + private final static byte MESSAGE_ABORT_MODE = 4; /** * SMTP Server identification string used in SMTP headers */ private final static String SOFTWARE_TYPE = "JAMES SMTP Server " - + Constants.SOFTWARE_VERSION; + + Constants.SOFTWARE_VERSION; /** * Static Random instance used to generate SMTP ids @@ -78,19 +77,18 @@ /** * The name of the currently parsed command */ - String curCommandName = null; + String curCommandName = null; /** * The value of the currently parsed command */ - String curCommandArgument = null; + String curCommandArgument = null; /** * The SMTPHandlerChain object set by SMTPServer */ SMTPHandlerChain handlerChain = null; - /** * The mode of the current session */ @@ -125,13 +123,12 @@ * Whether the remote Server must send HELO/EHLO */ private boolean heloEhloEnforcement; - /** * The SMTPGreeting */ private String smtpGreeting = null; - + /** * The id associated with this particular SMTP interaction. */ @@ -155,16 +152,22 @@ * The hash map holds states which should be used in the whole connection */ private HashMap connectionState = new HashMap(); - + /** * The per-handler response buffer used to marshal responses. */ private StringBuffer responseBuffer = new StringBuffer(256); - + private final static int DEFAULT_SMTP_CODE = 500; + private final static String DEFAULT_SMTP_RESPONSE = "Unexpected Error"; - - private SMTPResponse response = new SMTPResponse(DEFAULT_SMTP_CODE,DEFAULT_SMTP_RESPONSE); + + private SMTPResponse response = new SMTPResponse(DEFAULT_SMTP_CODE, + DEFAULT_SMTP_RESPONSE); + + private List ioObject = new ArrayList(2); + + private boolean blockSMTPResponse = false; /** * Set the configuration data for the handler @@ -172,77 +175,78 @@ * @param theData the per-service configuration data for this handler */ public void setConfigurationData(Object theData) { - if (theData instanceof SMTPHandlerConfigurationData) { - theConfigData = (SMTPHandlerConfigurationData) theData; - } else { - throw new IllegalArgumentException("Configuration object does not implement SMTPHandlerConfigurationData"); - } + if (theData instanceof SMTPHandlerConfigurationData) { + theConfigData = (SMTPHandlerConfigurationData) theData; + } else { + throw new IllegalArgumentException( + "Configuration object does not implement SMTPHandlerConfigurationData"); + } } - + /** * @see org.apache.james.core.AbstractJamesHandler#handleProtocol() */ protected void handleProtocol() throws IOException { - smtpID = random.nextInt(1024) + ""; - relayingAllowed = theConfigData.isRelayingAllowed(remoteIP); - authRequired = theConfigData.isAuthRequired(remoteIP); - heloEhloEnforcement = theConfigData.useHeloEhloEnforcement(); - sessionEnded = false; - smtpGreeting = theConfigData.getSMTPGreeting(); - resetState(); - resetConnectionState(); - - // if no greeting was configured use a default - if (smtpGreeting == null) { - // Initially greet the connector - // Format is: Sat, 24 Jan 1998 13:16:09 -0500 - - responseBuffer.append("220 ") - .append(theConfigData.getHelloName()) - .append(" SMTP Server (") - .append(SOFTWARE_TYPE) - .append(") ready ") - .append(rfc822DateFormat.format(new Date())); - } else { - responseBuffer.append("220 ") - .append(smtpGreeting); - } - String responseString = clearResponseBuffer(); - writeLoggedFlushedResponse(responseString); - - //the core in-protocol handling logic - //run all the connection handlers, if it fast fails, end the session - //parse the command command, look up for the list of command handlers - //Execute each of the command handlers. If any command handlers writes - //response then, End the subsequent command handler processing and - //start parsing new command. Once the message is received, run all - //the message handlers. The message handlers can either terminate - //message or terminate session - - //At the beginning - //mode = command_mode - //once the commandHandler writes response, the mode is changed to RESPONSE_MODE. - //This will cause to skip the subsequent command handlers configured for that command. - //For instance: - //There are 2 commandhandlers MailAddressChecker and MailCmdHandler for - //MAIL command. If MailAddressChecker validation of the MAIL FROM - //address is successful, the MailCmdHandlers will be executed. - //Incase it fails, it has to write response. Once we write response - //there is no need to execute the MailCmdHandler. - //Next, Once MAIL message is received the DataCmdHandler and any other - //equivalent commandHandler will call setMail method. this will change - //he mode to MAIL_RECEIVED_MODE. This mode will trigger the message - //handlers to be execute. Message handlers can abort message. In that case, - //message will not spooled. - - //Session started - RUN all connect handlers - List connectHandlers = handlerChain.getConnectHandlers(); - if(connectHandlers != null) { - new Chain(connectHandlers.iterator()).doChain(this); - } + smtpID = random.nextInt(1024) + ""; + relayingAllowed = theConfigData.isRelayingAllowed(remoteIP); + authRequired = theConfigData.isAuthRequired(remoteIP); + heloEhloEnforcement = theConfigData.useHeloEhloEnforcement(); + sessionEnded = false; + smtpGreeting = theConfigData.getSMTPGreeting(); + resetState(); + resetConnectionState(); + + // if no greeting was configured use a default + if (smtpGreeting == null) { + // Initially greet the connector + // Format is: Sat, 24 Jan 1998 13:16:09 -0500 + + responseBuffer.append("220 ").append(theConfigData.getHelloName()) + .append(" SMTP Server (").append(SOFTWARE_TYPE).append( + ") ready ").append( + rfc822DateFormat.format(new Date())); + } else { + responseBuffer.append("220 ").append(smtpGreeting); + } + String responseString = clearResponseBuffer(); + writeLoggedFlushedResponse(responseString); + + //the core in-protocol handling logic + //run all the connection handlers, if it fast fails, end the session + //parse the command command, look up for the list of command handlers + //Execute each of the command handlers. If any command handlers writes + //response then, End the subsequent command handler processing and + //start parsing new command. Once the message is received, run all + //the message handlers. The message handlers can either terminate + //message or terminate session + + //At the beginning + //mode = command_mode + //once the commandHandler writes response, the mode is changed to RESPONSE_MODE. + //This will cause to skip the subsequent command handlers configured for that command. + //For instance: + //There are 2 commandhandlers MailAddressChecker and MailCmdHandler for + //MAIL command. If MailAddressChecker validation of the MAIL FROM + //address is successful, the MailCmdHandlers will be executed. + //Incase it fails, it has to write response. Once we write response + //there is no need to execute the MailCmdHandler. + //Next, Once MAIL message is received the DataCmdHandler and any other + //equivalent commandHandler will call setMail method. this will change + //he mode to MAIL_RECEIVED_MODE. This mode will trigger the message + //handlers to be execute. Message handlers can abort message. In that case, + //message will not spooled. + + //Session started - RUN all connect handlers + List connectHandlers = handlerChain.getConnectHandlers(); + if (connectHandlers != null) { + + pushIOObject(new Chain(connectHandlers.iterator())); + process(); + popIOObject(); + } - theWatchdog.start(); - while (!sessionEnded) { + theWatchdog.start(); + while (!sessionEnded) { // Reset the current command values curCommandName = null; curCommandArgument = null; @@ -269,7 +273,9 @@ // end the session break; } else { - new Chain(commandHandlers.iterator()).doChain(this); + pushIOObject(new Chain(commandHandlers.iterator())); + process(); + popIOObject(); writeCompleteResponse(getSMTPResponse()); } @@ -280,8 +286,9 @@ List messageHandlers = handlerChain.getMessageHandlers(); if (messageHandlers != null) { - new Chain(messageHandlers.iterator()).doChain(this); - + pushIOObject(new Chain(messageHandlers.iterator())); + process(); + popIOObject(); writeCompleteResponse(getSMTPResponse()); } } @@ -314,33 +321,36 @@ * The Collection of responseStrings */ private void writeCompleteResponse(SMTPResponse responses) { - if (responses == null) return; - + if (responses == null) + return; + Collection resp = response.getSMTPResponse(); - + if (resp.size() > 0) { Iterator response = resp.iterator(); while (response.hasNext()) { String responseString = response.next().toString(); String finalResponse = null; - + if (response.hasNext()) { - finalResponse = responses.getSMTPCode() + "-" + responseString; + finalResponse = responses.getSMTPCode() + "-" + + responseString; } else { - finalResponse = responses.getSMTPCode() + " " + responseString; + finalResponse = responses.getSMTPCode() + " " + + responseString; } writeResponse(finalResponse); } } resetSMTPResponse(); } - + /** * Resets the handler data to a basic state. */ protected void resetHandler() { - this.response = null; + resetState(); resetConnectionState(); @@ -353,238 +363,242 @@ resetSMTPResponse(); } - /** - * Sets the SMTPHandlerChain - * - * @param handlerChain - * SMTPHandler object - */ + /** + * Sets the SMTPHandlerChain + * + * @param handlerChain + * SMTPHandler object + */ public void setHandlerChain(SMTPHandlerChain handlerChain) { - this.handlerChain = handlerChain; + this.handlerChain = handlerChain; } /** * @see org.apache.james.smtpserver.SMTPSession#writeResponse(String) */ public void writeResponse(String respString) { - writeLoggedFlushedResponse(respString); - - //TODO Explain this well - if(mode == COMMAND_MODE) { - mode = RESPONSE_MODE; - } + writeLoggedFlushedResponse(respString); + + //TODO Explain this well + if (mode == COMMAND_MODE) { + mode = RESPONSE_MODE; + } } /** * @see org.apache.james.smtpserver.SMTPSession#getCommandName() */ public String getCommandName() { - return curCommandName; + return curCommandName; } /** * @see org.apache.james.smtpserver.SMTPSession#getCommandArgument() */ public String getCommandArgument() { - return curCommandArgument; + return curCommandArgument; } /** * @see org.apache.james.smtpserver.SMTPSession#getMail() */ public Mail getMail() { - return mail; + return mail; } /** * @see org.apache.james.smtpserver.SMTPSession#setMail(Mail) */ public void setMail(Mail mail) { - this.mail = mail; - this.mode = MESSAGE_RECEIVED_MODE; + this.mail = mail; + this.mode = MESSAGE_RECEIVED_MODE; } /** * @see org.apache.james.smtpserver.SMTPSession#getRemoteHost() */ public String getRemoteHost() { - return remoteHost; + return remoteHost; } /** * @see org.apache.james.smtpserver.SMTPSession#getRemoteIPAddress() */ public String getRemoteIPAddress() { - return remoteIP; + return remoteIP; } /** * @see org.apache.james.smtpserver.SMTPSession#endSession() */ public void endSession() { - sessionEnded = true; + sessionEnded = true; } /** * @see org.apache.james.smtpserver.SMTPSession#isSessionEnded() */ public boolean isSessionEnded() { - return sessionEnded; + return sessionEnded; } /** * @see org.apache.james.smtpserver.SMTPSession#resetState() */ public void resetState() { - ArrayList recipients = (ArrayList)state.get(RCPT_LIST); - if (recipients != null) { - recipients.clear(); - } - state.clear(); + ArrayList recipients = (ArrayList) state.get(RCPT_LIST); + if (recipients != null) { + recipients.clear(); + } + state.clear(); } /** * @see org.apache.james.smtpserver.SMTPSession#getState() */ public Map getState() { - return state; + return state; } /** * @see org.apache.james.smtpserver.SMTPSession#getConfigurationData() */ public SMTPHandlerConfigurationData getConfigurationData() { - return theConfigData; + return theConfigData; } + /** * @see org.apache.james.smtpserver.SMTPSession#isRelayingAllowed() */ public boolean isRelayingAllowed() { - return relayingAllowed; + return relayingAllowed; } - + /** * @see org.apache.james.smtpserver.SMTPSession#setRelayingAllowed(boolean relayingAllowed) */ public void setRelayingAllowed(boolean relayingAllowed) { - this.relayingAllowed = relayingAllowed; + this.relayingAllowed = relayingAllowed; } /** * @see org.apache.james.smtpserver.SMTPSession#isAuthRequired() */ public boolean isAuthRequired() { - return authRequired; + return authRequired; } /** * @see org.apache.james.smtpserver.SMTPSession#useHeloEhloEnforcement() */ public boolean useHeloEhloEnforcement() { - return heloEhloEnforcement; + return heloEhloEnforcement; } + /** * @see org.apache.james.smtpserver.SMTPSession#getUser() */ public String getUser() { - return authenticatedUser; + return authenticatedUser; } /** * @see org.apache.james.smtpserver.SMTPSession#setUser() */ public void setUser(String userID) { - authenticatedUser = userID; + authenticatedUser = userID; } /** * @see org.apache.james.smtpserver.SMTPSession#getResponseBuffer() */ public StringBuffer getResponseBuffer() { - return responseBuffer; + return responseBuffer; } /** * @see org.apache.james.smtpserver.SMTPSession#clearResponseBuffer() */ public String clearResponseBuffer() { - String responseString = responseBuffer.toString(); - responseBuffer.delete(0,responseBuffer.length()); - return responseString; + String responseString = responseBuffer.toString(); + responseBuffer.delete(0, responseBuffer.length()); + return responseString; } - /** * @see org.apache.james.smtpserver.SMTPSession#readCommandLine() */ public final String readCommandLine() throws IOException { - for (;;) try { - String commandLine = inReader.readLine(); - if (commandLine != null) { - commandLine = commandLine.trim(); - } - return commandLine; - } catch (CRLFTerminatedReader.TerminationException te) { - writeLoggedFlushedResponse("501 Syntax error at character position " + te.position() + ". CR and LF must be CRLF paired. See RFC 2821 #2.7.1."); - } catch (CRLFTerminatedReader.LineLengthExceededException llee) { - writeLoggedFlushedResponse("500 Line length exceeded. See RFC 2821 #4.5.3.1."); - } + for (;;) + try { + String commandLine = inReader.readLine(); + if (commandLine != null) { + commandLine = commandLine.trim(); + } + return commandLine; + } catch (CRLFTerminatedReader.TerminationException te) { + writeLoggedFlushedResponse("501 Syntax error at character position " + + te.position() + + ". CR and LF must be CRLF paired. See RFC 2821 #2.7.1."); + } catch (CRLFTerminatedReader.LineLengthExceededException llee) { + writeLoggedFlushedResponse("500 Line length exceeded. See RFC 2821 #4.5.3.1."); + } } /** * @see org.apache.james.smtpserver.SMTPSession#getWatchdog() */ public Watchdog getWatchdog() { - return theWatchdog; + return theWatchdog; } /** * @see org.apache.james.smtpserver.SMTPSession#getInputStream() */ public InputStream getInputStream() { - return in; + return in; } /** * @see org.apache.james.smtpserver.SMTPSession#getSessionID() */ public String getSessionID() { - return smtpID; + return smtpID; } /** * @see org.apache.james.smtpserver.SMTPSession#abortMessage() */ public void abortMessage() { - mode = MESSAGE_ABORT_MODE; + mode = MESSAGE_ABORT_MODE; } - + /** * @see org.apache.james.smtpserver.SMTPSession#getRcptCount() */ public int getRcptCount() { - int count = 0; + int count = 0; - // check if the key exists - if (state.get(SMTPSession.RCPT_LIST) != null) { - count = ((Collection) state.get(SMTPSession.RCPT_LIST)).size(); - } + // check if the key exists + if (state.get(SMTPSession.RCPT_LIST) != null) { + count = ((Collection) state.get(SMTPSession.RCPT_LIST)).size(); + } - return count; + return count; } - + /** * @see org.apache.james.smtpserver.SMTPSession#resetConnectionState() */ public void resetConnectionState() { - connectionState.clear(); + connectionState.clear(); } - + /** * @see org.apache.james.smtpserver.SMTPSession#getConnectionState() */ public Map getConnectionState() { - return connectionState; + return connectionState; } /** @@ -593,20 +607,36 @@ public SMTPResponse getSMTPResponse() { return response; } - + /** * @see org.apache.james.smtpserver.SMTPSession#setSMTPResponse(SMTPResponse) */ - public void setSMTPResponse(SMTPResponse response){ + public void setSMTPResponse(SMTPResponse response) { this.response = response; } - + /** * Reset the SMTPResponse to the default state */ private void resetSMTPResponse() { getSMTPResponse().setSMTPCode(DEFAULT_SMTP_CODE); getSMTPResponse().setSMTPResponse(DEFAULT_SMTP_RESPONSE); + } + + public void pushIOObject(IOObject io) { + ioObject.add(0, io); + } + + public void popIOObject() { + ioObject.remove(0); + } + + public IOObject getIOObject() { + return (IOObject) ioObject.get(0); + } + + public SMTPResponse process() { + return getIOObject().nextHandler(this); } } Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPResponse.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPResponse.java?rev=428250&r1=428249&r2=428250&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPResponse.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPResponse.java Wed Aug 2 22:55:20 2006 @@ -40,12 +40,12 @@ * @throws InvalidArgumentException Get thrown if the given response is null */ public SMTPResponse(int code, String response) { - if (response == null) - throw new IllegalArgumentException("Invalid response String: " - + response); + if (response == null) + throw new IllegalArgumentException("Invalid response String: " + + response); - this.code = code; - resp.add(response); + this.code = code; + resp.add(response); } /** @@ -57,12 +57,12 @@ * @throws InvalidArgumentException Get thrown if the given response is null */ public void setSMTPResponse(String response) { - if (response == null) - throw new IllegalArgumentException("Invalid response String: " - + response); + if (response == null) + throw new IllegalArgumentException("Invalid response String: " + + response); - resp.clear(); - resp.add(response); + resp.clear(); + resp.add(response); } /** @@ -72,11 +72,11 @@ * @throws InvalidArgumentException Get thrown if the given response is null */ public void addSMTPResponse(String response) { - if (response == null) - throw new IllegalArgumentException("Invalid response String: " - + response); + if (response == null) + throw new IllegalArgumentException("Invalid response String: " + + response); - resp.add(response); + resp.add(response); } /** @@ -86,7 +86,7 @@ * The code */ public void setSMTPCode(int code) { - this.code = code; + this.code = code; } /** @@ -95,7 +95,7 @@ * @return code The SMTP code */ public int getSMTPCode() { - return code; + return code; } /** @@ -105,7 +105,7 @@ * client socked */ public Collection getSMTPResponse() { - return resp; + return resp; } /** @@ -115,19 +115,19 @@ * @throws IllegalArgumentException if the raw String is not valid */ public void setRawSMTPResponse(String response) { - String[] parts = response.split(" "); - if (parts.length > 1) { - setSMTPCode(Integer.parseInt(parts[0])); - setSMTPResponse(response.substring(parts[0].length() + 1)); - try { - - } catch (NumberFormatException e) { - throw new IllegalArgumentException("Invalid SMTPCode: " - + parts[0]); - } - } else { - throw new IllegalArgumentException("Invalid raw SMTPResponse: " - + response); - } + String[] parts = response.split(" "); + if (parts.length > 1) { + setSMTPCode(Integer.parseInt(parts[0])); + setSMTPResponse(response.substring(parts[0].length() + 1)); + try { + + } catch (NumberFormatException e) { + throw new IllegalArgumentException("Invalid SMTPCode: " + + parts[0]); + } + } else { + throw new IllegalArgumentException("Invalid raw SMTPResponse: " + + response); + } } } Modified: james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPSession.java URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPSession.java?rev=428250&r1=428249&r2=428250&view=diff ============================================================================== --- james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPSession.java (original) +++ james/server/sandbox/handlerapi2/src/java/org/apache/james/smtpserver/SMTPSession.java Wed Aug 2 22:55:20 2006 @@ -241,5 +241,13 @@ void setSMTPResponse(SMTPResponse response); void writeResponse(String resp); + + public void pushIOObject(IOObject io); + + public void popIOObject(); + + public IOObject getIOObject(); + + public SMTPResponse process(); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]