Package org.apache.james.protocols.api

Examples of org.apache.james.protocols.api.Response


     * (non-Javadoc)
     * @see org.apache.james.smtpserver.protocol.core.DataLineFilter#onLine(org.apache.james.smtpserver.protocol.SMTPSession, byte[], org.apache.james.api.protocol.LineHandler)
     */
    public Response onLine(SMTPSession session,  byte[] line, LineHandler<SMTPSession> next) {
        if (session.getState().containsKey(HEADERS_WRITTEN) == false) {
            Response response = addNewReceivedMailHeaders(session, next);

            session.getState().put(HEADERS_WRITTEN, true);
           
            if (response != null) {
                return response;
            }
        }
        Response resp =  next.onLine(session, line);
        return resp;
    }
View Full Code Here


        }

        headerLineBuffer.append(" ([").append(session.getRemoteIPAddress())
                .append("])").append("\r\n");
           
        Response response = next.onLine(session, headerLineBuffer.toString().getBytes(CHARSET));
        if (response != null) {
            return response;
        }
        headerLineBuffer.delete(0, headerLineBuffer.length());
View Full Code Here

    /*
     * (non-Javadoc)
     * @see org.apache.james.smtpserver.protocol.core.DataLineFilter#onLine(org.apache.james.smtpserver.protocol.SMTPSession, byte[], org.apache.james.api.protocol.LineHandler)
     */
    public Response onLine(SMTPSession session, byte[] line, LineHandler<SMTPSession> next) {
        Response response = null;
      Boolean failed = (Boolean) session.getState().get(MESG_FAILED);
        // If we already defined we failed and sent a reply we should simply
        // wait for a CRLF.CRLF to be sent by the client.
        if (failed != null && failed.booleanValue()) {
            // TODO
View Full Code Here

        Iterator<CommandHandler<Session>> handlers = commandHandlers.iterator();
       
        while (handlers.hasNext()) {
            final long start = System.currentTimeMillis();
            CommandHandler<Session> cHandler = handlers.next();
            Response response = cHandler.onCommand(session, request);
            if (response != null) {
                long executionTime = System.currentTimeMillis() - start;

                // now process the result handlers
                for (int a = 0; a < rHandlers.size(); a++) {
View Full Code Here

            // Stream terminated
            if (line.length == 3 && line[0] == 46) {
                out.flush();
                out.close();
               
                Response response = processExtensions(session, env);
                session.resetState();
                return response;
               
            // DotStuffing.
            } else if (line[0] == 46 && line[1] == 46) {
View Full Code Here

     * org.apache.james.smtpserver.protocol.core.AbstractHookableCmdHandler#
     * onCommand(org.apache.james.smtpserver.protocol.SMTPSession,
     * org.apache.james.api.protocol.Request)
     */
    public Response onCommand(SMTPSession session, Request request) {
        Response response = super.onCommand(session, request);
        // Check if the response was not ok
        if (response.getRetCode().equals(SMTPRetCode.MAIL_OK) == false) {
            // cleanup the session
            session.getState().remove(SMTPSession.SENDER);
        }

        return response;
View Full Code Here

            // copy the ChannelBuffer to a byte array to process the LineHandler
            line = new byte[buf.capacity()];
            buf.getBytes(0, line);
        }

        Response response = handler.onLine(session, line);
        if (response != null) {
            // TODO: This kind of sucks but I was able to come up with something more elegant here
            ((AbstractSession)session).getProtocolTransport().writeResponse(response, session);
        }
    }
View Full Code Here

        if (connectHandlers != null) {
            for (int i = 0; i < connectHandlers.size(); i++) {
                ConnectHandler cHandler = connectHandlers.get(i);
               
                long start = System.currentTimeMillis();
                Response response = connectHandlers.get(i).onConnect(session);
                long executionTime = System.currentTimeMillis() - start;
               
                for (int a = 0; a < resultHandlers.size(); a++) {
                    // Disable till PROTOCOLS-37 is implemented
                    if (response instanceof FutureResponse) {
View Full Code Here

                buf.getBytes(0, line);
            }
           
            LineHandler lHandler=  (LineHandler) lineHandlers.getLast();
            long start = System.currentTimeMillis();           
            Response response = lHandler.onLine(pSession,line);
            long executionTime = System.currentTimeMillis() - start;

            for (int i = 0; i < resultHandlers.size(); i++) {
                // Disable till PROTOCOLS-37 is implemented
                if (response instanceof FutureResponse) {
View Full Code Here

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
        Channel channel = ctx.getChannel();
        ProtocolSession session = (ProtocolSession) ctx.getAttachment();
        if (e.getCause() instanceof TooLongFrameException) {
            Response r = session.newLineTooLongResponse();
            ProtocolTransport transport = ((AbstractSession)session).getProtocolTransport();
            if (r != null)  {
                transport.writeResponse(r, session);
            }
        } else {
            if (channel.isConnected()) {
                ProtocolTransport transport = ((AbstractSession)session).getProtocolTransport();

                Response r = session.newFatalErrorResponse();
                if (r != null) {
                    transport.writeResponse(r, session);
                }
                transport.writeResponse(Response.DISCONNECT, session);
            }
View Full Code Here

TOP

Related Classes of org.apache.james.protocols.api.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.