You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2005/09/15 21:07:03 UTC

svn commit: r289289 [24/134] - in /webservices/axis2/trunk/java: ./ etc/ modules/addressing/ modules/addressing/src/META-INF/ modules/addressing/src/org/apache/axis2/handlers/addressing/ modules/addressing/test-resources/ modules/addressing/test/org/ap...

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java Thu Sep 15 11:52:11 2005
@@ -1,443 +1,443 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- * 
- * Runtime state of the engine
- */
-package org.apache.axis2.transport.http;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.attachments.MIMEHelper;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.engine.AxisEngine;
-import org.apache.axis2.om.*;
-import org.apache.axis2.om.impl.MTOMConstants;
-import org.apache.axis2.om.impl.llom.OMNamespaceImpl;
-import org.apache.axis2.om.impl.llom.builder.StAXBuilder;
-import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
-import org.apache.axis2.om.impl.llom.mtom.MTOMStAXSOAPModelBuilder;
-import org.apache.axis2.soap.SOAP11Constants;
-import org.apache.axis2.soap.SOAP12Constants;
-import org.apache.axis2.soap.SOAPEnvelope;
-import org.apache.axis2.soap.SOAPFactory;
-import org.apache.axis2.soap.impl.llom.SOAPProcessingException;
-import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
-import org.apache.axis2.soap.impl.llom.soap11.SOAP11Factory;
-import org.apache.axis2.soap.impl.llom.soap12.SOAP12Factory;
-import org.apache.axis2.util.Utils;
-
-import javax.xml.parsers.FactoryConfigurationError;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.*;
-import java.util.Iterator;
-import java.util.Map;
-
-public class HTTPTransportUtils {
-
-    public static void processHTTPPostRequest(
-        MessageContext msgContext,
-        InputStream in,
-        OutputStream out,
-        String contentType,
-        String soapActionHeader,
-        String requestURI,
-        ConfigurationContext configurationContext)
-        throws AxisFault {
-        boolean soap11 = false;
-        try {
-
-            //remove the starting and trailing " from the SOAP Action
-            if (soapActionHeader != null
-                && soapActionHeader.startsWith("\"")
-                && soapActionHeader.endsWith("\"")) {
-
-                soapActionHeader =
-                    soapActionHeader.substring(
-                        1,
-                        soapActionHeader.length() - 1);
-            }
-            //fill up the Message Contexts
-            msgContext.setWSAAction(soapActionHeader);
-            msgContext.setSoapAction(soapActionHeader);
-            msgContext.setTo(new EndpointReference(requestURI));
-            msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
-            msgContext.setServerSide(true);
-
-            SOAPEnvelope envelope = null;
-            StAXBuilder builder = null;
-            if (contentType != null) {
-                if (contentType
-                    .indexOf(HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED)
-                    > -1) {
-                    //It is MTOM
-                    builder = selectBuilderForMIME(msgContext, in, contentType);
-                    envelope = (SOAPEnvelope) builder.getDocumentElement();
-                } else {
-                    Reader reader = new InputStreamReader(in);
-
-                    XMLStreamReader xmlreader;
-                    //Figure out the char set encoding and create the reader
-
-                    //If charset is not specified
-                    if ( getCharSetEncoding(contentType) == null ) {
-                        xmlreader =
-                            XMLInputFactory
-                                .newInstance()
-                                .createXMLStreamReader(
-                                in,
-                                MessageContext.DEFAULT_CHAR_SET_ENCODING);
-                        //Set the encoding scheme in the message context
-                        msgContext.setProperty(
-                            MessageContext.CHARACTER_SET_ENCODING,
-                            MessageContext.DEFAULT_CHAR_SET_ENCODING);
-                    } else {
-                        //get the type of char encoding
-                        String charSetEnc = getCharSetEncoding(contentType);
-                        xmlreader =
-                            XMLInputFactory
-                                .newInstance()
-                                .createXMLStreamReader(
-                                in,
-                                charSetEnc);
-
-                        //Setting the value in msgCtx
-                        msgContext.setProperty(
-                            MessageContext.CHARACTER_SET_ENCODING,
-                            charSetEnc);
-
-                    }
-                    if (contentType
-                        .indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE)
-                        > -1) {
-                        soap11 = false;
-                        //it is SOAP 1.2
-                        builder =
-                            new StAXSOAPModelBuilder(
-                                xmlreader,
-                                SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
-                        envelope = (SOAPEnvelope) builder.getDocumentElement();
-                    } else if (
-                        contentType.indexOf(
-                            SOAP11Constants.SOAP_11_CONTENT_TYPE)
-                            > -1) {
-                        soap11 = true;
-                        //it is SOAP 1.1
-                        Object enable =
-                            msgContext.getProperty(
-                                Constants.Configuration.ENABLE_REST);
-                        if ((soapActionHeader == null
-                            || soapActionHeader.length() == 0)
-                            && Constants.VALUE_TRUE.equals(enable)) {
-                            //If the content Type is text/xml (BTW which is the SOAP 1.1 Content type ) and
-                            //the SOAP Action is absent it is rest !!
-                            msgContext.setDoingREST(true);
-
-                            SOAPFactory soapFactory = new SOAP11Factory();
-                            builder = new StAXOMBuilder(xmlreader);
-                            builder.setOmbuilderFactory(soapFactory);
-                            envelope = soapFactory.getDefaultEnvelope();
-                            envelope.getBody().addChild(
-                                builder.getDocumentElement());
-                        } else {
-                            builder =
-                                new StAXSOAPModelBuilder(
-                                    xmlreader,
-                                    SOAP11Constants
-                                        .SOAP_ENVELOPE_NAMESPACE_URI);
-                            envelope =
-                                (SOAPEnvelope) builder.getDocumentElement();
-                        }
-                    }
-
-                }
-
-            }
-
-            String charsetEncoding = builder.getDocument().getCharsetEncoding();
-            if(charsetEncoding != null && !"".equals(charsetEncoding) &&
-                    !((String)msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING))
-                            .equalsIgnoreCase(charsetEncoding)){
-                String faultCode;
-                if(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(envelope.getNamespace().getName())){
-                   faultCode = SOAP12Constants.FAULT_CODE_SENDER;
-                }else {
-                    faultCode = SOAP11Constants.FAULT_CODE_SENDER;
-                }
-                throw new AxisFault("Character Set Encoding from " +
-                        "transport information do not match with " +
-                        "character set encoding in the received SOAP message", faultCode);
-            }
-
-
-            msgContext.setEnvelope(envelope);
-            AxisEngine engine = new AxisEngine(configurationContext);
-            if (envelope.getBody().hasFault()) {
-                engine.receiveFault(msgContext);
-            } else {
-                engine.receive(msgContext);
-            }
-        } catch (SOAPProcessingException e) {
-            throw new AxisFault(e);
-
-        } catch (AxisFault e) {
-            throw new AxisFault(e);
-        } catch (OMException e) {
-            throw new AxisFault(e);
-        } catch (XMLStreamException e) {
-            throw new AxisFault(e);
-        } catch (FactoryConfigurationError e) {
-            throw new AxisFault(e);
-        } catch (UnsupportedEncodingException e) {
-        	throw new AxisFault(e);
-        } finally {
-            if (msgContext.getEnvelope() == null && !soap11) {
-                msgContext.setEnvelope(
-                    new SOAP12Factory().createSOAPEnvelope());
-            }
-
-        }
-    }
-
-    /**
-     * Extracts and returns the character set encoding from the
-     * Content-type header
-     * Example:
-     * Content-Type: text/xml; charset=utf-8
-     * @param contentType
-     */
-    private static String getCharSetEncoding(String contentType) {
-        int index = contentType.indexOf(HTTPConstants.CHAR_SET_ENCODING);
-        if(index == -1) { //Charset encoding not found in the contect-type header
-        	//Using the default UTF-8
-        	return MessageContext.DEFAULT_CHAR_SET_ENCODING;
-        }
-
-        //If there are spaces around the '=' sign
-        int indexOfEq = contentType.indexOf("=", index);
-        //There can be situations where "charset" is not the last parameter of the Content-Type header
-        int indexOfSemiColon = contentType.indexOf(";", indexOfEq);
-        String value;
-        if (indexOfSemiColon > 0) {
-            value = (contentType.substring(indexOfEq + 1, indexOfSemiColon));
-        } else {
-            value = (contentType.substring(indexOfEq + 1, contentType.length()))
-                    .trim();
-        }
-
-        //There might be "" around the value - if so remove them
-        value = value.replaceAll("\"", "");
-
-        if("null".equalsIgnoreCase(value)){
-            return null;
-        }
-
-        return value.trim();
-
-    }
-
-    public static boolean processHTTPGetRequest(
-        MessageContext msgContext,
-        InputStream in,
-        OutputStream out,
-        String contentType,
-        String soapAction,
-        String requestURI,
-        ConfigurationContext configurationContext,
-        Map requestParameters)
-        throws AxisFault {
-        if (soapAction != null
-            && soapAction.startsWith("\"")
-            && soapAction.endsWith("\"")) {
-            soapAction = soapAction.substring(1, soapAction.length() - 1);
-        }
-        msgContext.setWSAAction(soapAction);
-        msgContext.setSoapAction(soapAction);
-        msgContext.setTo(new EndpointReference(requestURI));
-        msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
-        msgContext.setServerSide(true);
-        SOAPEnvelope envelope =
-            HTTPTransportUtils.createEnvelopeFromGetRequest(
-                requestURI,
-                requestParameters);
-        if (envelope == null) {
-            return false;
-        } else {
-            msgContext.setDoingREST(true);
-            msgContext.setEnvelope(envelope);
-            AxisEngine engine = new AxisEngine(configurationContext);
-            engine.receive(msgContext);
-            return true;
-        }
-    }
-
-    public static final SOAPEnvelope createEnvelopeFromGetRequest(
-        String requestUrl,
-        Map map) {
-        String[] values =
-            Utils.parseRequestURLForServiceAndOperation(requestUrl);
-
-        if (values[1] != null && values[0] != null) {
-            String operation = values[1];
-            SOAPFactory soapFactory = new SOAP11Factory();
-            SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
-
-            OMNamespace omNs =
-                soapFactory.createOMNamespace(values[0], "services");
-            OMNamespace defualtNs = new OMNamespaceImpl("", null);
-
-            OMElement opElement = soapFactory.createOMElement(operation, omNs);
-
-            Iterator it = map.keySet().iterator();
-            while (it.hasNext()) {
-                String name = (String) it.next();
-                String value = (String) map.get(name);
-                OMElement omEle = soapFactory.createOMElement(name, defualtNs);
-                omEle.setText(value);
-                opElement.addChild(omEle);
-            }
-
-            envelope.getBody().addChild(opElement);
-            return envelope;
-        } else {
-            return null;
-        }
-    }
-
-    public static StAXBuilder selectBuilderForMIME(
-        MessageContext msgContext,
-        InputStream inStream,
-        String contentTypeString)
-        throws OMException,
-			XMLStreamException, FactoryConfigurationError,
-			UnsupportedEncodingException {
-        StAXBuilder builder = null;
-
-
-        Parameter parameter_cache_attachment = msgContext.getParameter(
-                Constants.Configuration.CACHE_ATTACHMENTS);
-         boolean fileCacheForAttachments ;
-        if(parameter_cache_attachment == null){
-            fileCacheForAttachments = false;
-        }  else {
-           fileCacheForAttachments =
-            (Constants
-                .VALUE_TRUE
-                .equals(
-                    parameter_cache_attachment.getValue()));
-        }
-        String attachmentRepoDir = null;
-        String attachmentSizeThreshold = null;
-        Parameter parameter;
-        if (fileCacheForAttachments) {
-            parameter = msgContext.getParameter(Constants.Configuration.ATTACHMENT_TEMP_DIR);
-            attachmentRepoDir = parameter==null?"":parameter.getValue().toString();
-
-            parameter = msgContext
-                    .getParameter(Constants.Configuration.FILE_SIZE_THRESHOLD);
-            attachmentSizeThreshold = parameter==null?"":parameter.getValue().toString();
-        }
-
-        MIMEHelper mimeHelper = new MIMEHelper(inStream, contentTypeString,
-                fileCacheForAttachments, attachmentRepoDir,attachmentSizeThreshold);
-
-        String charSetEncoding = getCharSetEncoding(mimeHelper.getSOAPPartContentType());
-        XMLStreamReader reader;
-        if(charSetEncoding == null || "null".equalsIgnoreCase(charSetEncoding)){
-             reader = XMLInputFactory.newInstance()
-                .createXMLStreamReader(
-                        new BufferedReader(new InputStreamReader(mimeHelper
-                                .getSOAPPartInputStream(),
-                                charSetEncoding)));
-            msgContext.setProperty(MessageContext.CHARACTER_SET_ENCODING, charSetEncoding);
-
-        }else {
-            reader = XMLInputFactory.newInstance()
-                .createXMLStreamReader(
-                        new BufferedReader(new InputStreamReader(mimeHelper
-                                .getSOAPPartInputStream())));
-            msgContext.setProperty(MessageContext.CHARACTER_SET_ENCODING, MessageContext.UTF_8);
-
-        }
-
-
-        /*
-		 * put a reference to Attachments in to the message context
-		 */
-        msgContext.setProperty(MTOMConstants.ATTACHMENTS, mimeHelper);
-        if (mimeHelper.getAttachmentSpecType().equals(MTOMConstants.MTOM_TYPE)) {
-            /*
-             * Creates the MTOM specific MTOMStAXSOAPModelBuilder
-             */
-            builder =
-                new MTOMStAXSOAPModelBuilder(
-                    reader,
-                    mimeHelper,
-                    null);
-        } else if (
-            mimeHelper.getAttachmentSpecType().equals(MTOMConstants.SWA_TYPE)) {
-            builder =
-                new StAXSOAPModelBuilder(
-                    reader,
-                    SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
-        }
-        return builder;
-    }
-
-    public static boolean checkEnvelopeForOptimise(SOAPEnvelope envelope) {
-        return isOptimised(envelope);
-    }
-
-    private static boolean isOptimised(OMElement element) {
-        Iterator childrenIter = element.getChildren();
-        boolean isOptimized = false;
-        while (childrenIter.hasNext() && !isOptimized) {
-            OMNode node = (OMNode) childrenIter.next();
-            if (OMNode.TEXT_NODE == node.getType()
-                && ((OMText) node).isOptimized()) {
-                isOptimized = true;
-            } else if (OMNode.ELEMENT_NODE == node.getType()) {
-                isOptimized = isOptimised((OMElement) node);
-            }
-        }
-        return isOptimized;
-    }
-
-    public static boolean doWriteMTOM(MessageContext msgContext) {
-        boolean enableMTOM = false;
-        if (msgContext.getParameter(Constants.Configuration.ENABLE_MTOM)
-            != null) {
-            enableMTOM =
-                Constants.VALUE_TRUE.equals(
-                    msgContext.getParameter(
-                        Constants.Configuration.ENABLE_MTOM).getValue());
-        } else if(msgContext.getProperty(Constants.Configuration.ENABLE_MTOM) != null) {
-            enableMTOM =
-                Constants.VALUE_TRUE.equals(
-                    msgContext.getProperty(
-                        Constants.Configuration.ENABLE_MTOM));
-        }
-        boolean envelopeContainsOptimise =
-            HTTPTransportUtils.checkEnvelopeForOptimise(
-                msgContext.getEnvelope());
-        boolean doMTOM = enableMTOM && envelopeContainsOptimise;
-        msgContext.setDoingMTOM(doMTOM);
-        return doMTOM;
-    }
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * 
+ * Runtime state of the engine
+ */
+package org.apache.axis2.transport.http;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.attachments.MIMEHelper;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.om.*;
+import org.apache.axis2.om.impl.MTOMConstants;
+import org.apache.axis2.om.impl.llom.OMNamespaceImpl;
+import org.apache.axis2.om.impl.llom.builder.StAXBuilder;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.axis2.om.impl.llom.mtom.MTOMStAXSOAPModelBuilder;
+import org.apache.axis2.soap.SOAP11Constants;
+import org.apache.axis2.soap.SOAP12Constants;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.SOAPFactory;
+import org.apache.axis2.soap.impl.llom.SOAPProcessingException;
+import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.soap.impl.llom.soap11.SOAP11Factory;
+import org.apache.axis2.soap.impl.llom.soap12.SOAP12Factory;
+import org.apache.axis2.util.Utils;
+
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.io.*;
+import java.util.Iterator;
+import java.util.Map;
+
+public class HTTPTransportUtils {
+
+    public static void processHTTPPostRequest(
+        MessageContext msgContext,
+        InputStream in,
+        OutputStream out,
+        String contentType,
+        String soapActionHeader,
+        String requestURI,
+        ConfigurationContext configurationContext)
+        throws AxisFault {
+        boolean soap11 = false;
+        try {
+
+            //remove the starting and trailing " from the SOAP Action
+            if (soapActionHeader != null
+                && soapActionHeader.startsWith("\"")
+                && soapActionHeader.endsWith("\"")) {
+
+                soapActionHeader =
+                    soapActionHeader.substring(
+                        1,
+                        soapActionHeader.length() - 1);
+            }
+            //fill up the Message Contexts
+            msgContext.setWSAAction(soapActionHeader);
+            msgContext.setSoapAction(soapActionHeader);
+            msgContext.setTo(new EndpointReference(requestURI));
+            msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
+            msgContext.setServerSide(true);
+
+            SOAPEnvelope envelope = null;
+            StAXBuilder builder = null;
+            if (contentType != null) {
+                if (contentType
+                    .indexOf(HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED)
+                    > -1) {
+                    //It is MTOM
+                    builder = selectBuilderForMIME(msgContext, in, contentType);
+                    envelope = (SOAPEnvelope) builder.getDocumentElement();
+                } else {
+                    Reader reader = new InputStreamReader(in);
+
+                    XMLStreamReader xmlreader;
+                    //Figure out the char set encoding and create the reader
+
+                    //If charset is not specified
+                    if ( getCharSetEncoding(contentType) == null ) {
+                        xmlreader =
+                            XMLInputFactory
+                                .newInstance()
+                                .createXMLStreamReader(
+                                in,
+                                MessageContext.DEFAULT_CHAR_SET_ENCODING);
+                        //Set the encoding scheme in the message context
+                        msgContext.setProperty(
+                            MessageContext.CHARACTER_SET_ENCODING,
+                            MessageContext.DEFAULT_CHAR_SET_ENCODING);
+                    } else {
+                        //get the type of char encoding
+                        String charSetEnc = getCharSetEncoding(contentType);
+                        xmlreader =
+                            XMLInputFactory
+                                .newInstance()
+                                .createXMLStreamReader(
+                                in,
+                                charSetEnc);
+
+                        //Setting the value in msgCtx
+                        msgContext.setProperty(
+                            MessageContext.CHARACTER_SET_ENCODING,
+                            charSetEnc);
+
+                    }
+                    if (contentType
+                        .indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE)
+                        > -1) {
+                        soap11 = false;
+                        //it is SOAP 1.2
+                        builder =
+                            new StAXSOAPModelBuilder(
+                                xmlreader,
+                                SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+                        envelope = (SOAPEnvelope) builder.getDocumentElement();
+                    } else if (
+                        contentType.indexOf(
+                            SOAP11Constants.SOAP_11_CONTENT_TYPE)
+                            > -1) {
+                        soap11 = true;
+                        //it is SOAP 1.1
+                        Object enable =
+                            msgContext.getProperty(
+                                Constants.Configuration.ENABLE_REST);
+                        if ((soapActionHeader == null
+                            || soapActionHeader.length() == 0)
+                            && Constants.VALUE_TRUE.equals(enable)) {
+                            //If the content Type is text/xml (BTW which is the SOAP 1.1 Content type ) and
+                            //the SOAP Action is absent it is rest !!
+                            msgContext.setDoingREST(true);
+
+                            SOAPFactory soapFactory = new SOAP11Factory();
+                            builder = new StAXOMBuilder(xmlreader);
+                            builder.setOmbuilderFactory(soapFactory);
+                            envelope = soapFactory.getDefaultEnvelope();
+                            envelope.getBody().addChild(
+                                builder.getDocumentElement());
+                        } else {
+                            builder =
+                                new StAXSOAPModelBuilder(
+                                    xmlreader,
+                                    SOAP11Constants
+                                        .SOAP_ENVELOPE_NAMESPACE_URI);
+                            envelope =
+                                (SOAPEnvelope) builder.getDocumentElement();
+                        }
+                    }
+
+                }
+
+            }
+
+            String charsetEncoding = builder.getDocument().getCharsetEncoding();
+            if(charsetEncoding != null && !"".equals(charsetEncoding) &&
+                    !((String)msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING))
+                            .equalsIgnoreCase(charsetEncoding)){
+                String faultCode;
+                if(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(envelope.getNamespace().getName())){
+                   faultCode = SOAP12Constants.FAULT_CODE_SENDER;
+                }else {
+                    faultCode = SOAP11Constants.FAULT_CODE_SENDER;
+                }
+                throw new AxisFault("Character Set Encoding from " +
+                        "transport information do not match with " +
+                        "character set encoding in the received SOAP message", faultCode);
+            }
+
+
+            msgContext.setEnvelope(envelope);
+            AxisEngine engine = new AxisEngine(configurationContext);
+            if (envelope.getBody().hasFault()) {
+                engine.receiveFault(msgContext);
+            } else {
+                engine.receive(msgContext);
+            }
+        } catch (SOAPProcessingException e) {
+            throw new AxisFault(e);
+
+        } catch (AxisFault e) {
+            throw new AxisFault(e);
+        } catch (OMException e) {
+            throw new AxisFault(e);
+        } catch (XMLStreamException e) {
+            throw new AxisFault(e);
+        } catch (FactoryConfigurationError e) {
+            throw new AxisFault(e);
+        } catch (UnsupportedEncodingException e) {
+        	throw new AxisFault(e);
+        } finally {
+            if (msgContext.getEnvelope() == null && !soap11) {
+                msgContext.setEnvelope(
+                    new SOAP12Factory().createSOAPEnvelope());
+            }
+
+        }
+    }
+
+    /**
+     * Extracts and returns the character set encoding from the
+     * Content-type header
+     * Example:
+     * Content-Type: text/xml; charset=utf-8
+     * @param contentType
+     */
+    private static String getCharSetEncoding(String contentType) {
+        int index = contentType.indexOf(HTTPConstants.CHAR_SET_ENCODING);
+        if(index == -1) { //Charset encoding not found in the contect-type header
+        	//Using the default UTF-8
+        	return MessageContext.DEFAULT_CHAR_SET_ENCODING;
+        }
+
+        //If there are spaces around the '=' sign
+        int indexOfEq = contentType.indexOf("=", index);
+        //There can be situations where "charset" is not the last parameter of the Content-Type header
+        int indexOfSemiColon = contentType.indexOf(";", indexOfEq);
+        String value;
+        if (indexOfSemiColon > 0) {
+            value = (contentType.substring(indexOfEq + 1, indexOfSemiColon));
+        } else {
+            value = (contentType.substring(indexOfEq + 1, contentType.length()))
+                    .trim();
+        }
+
+        //There might be "" around the value - if so remove them
+        value = value.replaceAll("\"", "");
+
+        if("null".equalsIgnoreCase(value)){
+            return null;
+        }
+
+        return value.trim();
+
+    }
+
+    public static boolean processHTTPGetRequest(
+        MessageContext msgContext,
+        InputStream in,
+        OutputStream out,
+        String contentType,
+        String soapAction,
+        String requestURI,
+        ConfigurationContext configurationContext,
+        Map requestParameters)
+        throws AxisFault {
+        if (soapAction != null
+            && soapAction.startsWith("\"")
+            && soapAction.endsWith("\"")) {
+            soapAction = soapAction.substring(1, soapAction.length() - 1);
+        }
+        msgContext.setWSAAction(soapAction);
+        msgContext.setSoapAction(soapAction);
+        msgContext.setTo(new EndpointReference(requestURI));
+        msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
+        msgContext.setServerSide(true);
+        SOAPEnvelope envelope =
+            HTTPTransportUtils.createEnvelopeFromGetRequest(
+                requestURI,
+                requestParameters);
+        if (envelope == null) {
+            return false;
+        } else {
+            msgContext.setDoingREST(true);
+            msgContext.setEnvelope(envelope);
+            AxisEngine engine = new AxisEngine(configurationContext);
+            engine.receive(msgContext);
+            return true;
+        }
+    }
+
+    public static final SOAPEnvelope createEnvelopeFromGetRequest(
+        String requestUrl,
+        Map map) {
+        String[] values =
+            Utils.parseRequestURLForServiceAndOperation(requestUrl);
+
+        if (values[1] != null && values[0] != null) {
+            String operation = values[1];
+            SOAPFactory soapFactory = new SOAP11Factory();
+            SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
+
+            OMNamespace omNs =
+                soapFactory.createOMNamespace(values[0], "services");
+            OMNamespace defualtNs = new OMNamespaceImpl("", null);
+
+            OMElement opElement = soapFactory.createOMElement(operation, omNs);
+
+            Iterator it = map.keySet().iterator();
+            while (it.hasNext()) {
+                String name = (String) it.next();
+                String value = (String) map.get(name);
+                OMElement omEle = soapFactory.createOMElement(name, defualtNs);
+                omEle.setText(value);
+                opElement.addChild(omEle);
+            }
+
+            envelope.getBody().addChild(opElement);
+            return envelope;
+        } else {
+            return null;
+        }
+    }
+
+    public static StAXBuilder selectBuilderForMIME(
+        MessageContext msgContext,
+        InputStream inStream,
+        String contentTypeString)
+        throws OMException,
+			XMLStreamException, FactoryConfigurationError,
+			UnsupportedEncodingException {
+        StAXBuilder builder = null;
+
+
+        Parameter parameter_cache_attachment = msgContext.getParameter(
+                Constants.Configuration.CACHE_ATTACHMENTS);
+         boolean fileCacheForAttachments ;
+        if(parameter_cache_attachment == null){
+            fileCacheForAttachments = false;
+        }  else {
+           fileCacheForAttachments =
+            (Constants
+                .VALUE_TRUE
+                .equals(
+                    parameter_cache_attachment.getValue()));
+        }
+        String attachmentRepoDir = null;
+        String attachmentSizeThreshold = null;
+        Parameter parameter;
+        if (fileCacheForAttachments) {
+            parameter = msgContext.getParameter(Constants.Configuration.ATTACHMENT_TEMP_DIR);
+            attachmentRepoDir = parameter==null?"":parameter.getValue().toString();
+
+            parameter = msgContext
+                    .getParameter(Constants.Configuration.FILE_SIZE_THRESHOLD);
+            attachmentSizeThreshold = parameter==null?"":parameter.getValue().toString();
+        }
+
+        MIMEHelper mimeHelper = new MIMEHelper(inStream, contentTypeString,
+                fileCacheForAttachments, attachmentRepoDir,attachmentSizeThreshold);
+
+        String charSetEncoding = getCharSetEncoding(mimeHelper.getSOAPPartContentType());
+        XMLStreamReader reader;
+        if(charSetEncoding == null || "null".equalsIgnoreCase(charSetEncoding)){
+             reader = XMLInputFactory.newInstance()
+                .createXMLStreamReader(
+                        new BufferedReader(new InputStreamReader(mimeHelper
+                                .getSOAPPartInputStream(),
+                                charSetEncoding)));
+            msgContext.setProperty(MessageContext.CHARACTER_SET_ENCODING, charSetEncoding);
+
+        }else {
+            reader = XMLInputFactory.newInstance()
+                .createXMLStreamReader(
+                        new BufferedReader(new InputStreamReader(mimeHelper
+                                .getSOAPPartInputStream())));
+            msgContext.setProperty(MessageContext.CHARACTER_SET_ENCODING, MessageContext.UTF_8);
+
+        }
+
+
+        /*
+		 * put a reference to Attachments in to the message context
+		 */
+        msgContext.setProperty(MTOMConstants.ATTACHMENTS, mimeHelper);
+        if (mimeHelper.getAttachmentSpecType().equals(MTOMConstants.MTOM_TYPE)) {
+            /*
+             * Creates the MTOM specific MTOMStAXSOAPModelBuilder
+             */
+            builder =
+                new MTOMStAXSOAPModelBuilder(
+                    reader,
+                    mimeHelper,
+                    null);
+        } else if (
+            mimeHelper.getAttachmentSpecType().equals(MTOMConstants.SWA_TYPE)) {
+            builder =
+                new StAXSOAPModelBuilder(
+                    reader,
+                    SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+        }
+        return builder;
+    }
+
+    public static boolean checkEnvelopeForOptimise(SOAPEnvelope envelope) {
+        return isOptimised(envelope);
+    }
+
+    private static boolean isOptimised(OMElement element) {
+        Iterator childrenIter = element.getChildren();
+        boolean isOptimized = false;
+        while (childrenIter.hasNext() && !isOptimized) {
+            OMNode node = (OMNode) childrenIter.next();
+            if (OMNode.TEXT_NODE == node.getType()
+                && ((OMText) node).isOptimized()) {
+                isOptimized = true;
+            } else if (OMNode.ELEMENT_NODE == node.getType()) {
+                isOptimized = isOptimised((OMElement) node);
+            }
+        }
+        return isOptimized;
+    }
+
+    public static boolean doWriteMTOM(MessageContext msgContext) {
+        boolean enableMTOM = false;
+        if (msgContext.getParameter(Constants.Configuration.ENABLE_MTOM)
+            != null) {
+            enableMTOM =
+                Constants.VALUE_TRUE.equals(
+                    msgContext.getParameter(
+                        Constants.Configuration.ENABLE_MTOM).getValue());
+        } else if(msgContext.getProperty(Constants.Configuration.ENABLE_MTOM) != null) {
+            enableMTOM =
+                Constants.VALUE_TRUE.equals(
+                    msgContext.getProperty(
+                        Constants.Configuration.ENABLE_MTOM));
+        }
+        boolean envelopeContainsOptimise =
+            HTTPTransportUtils.checkEnvelopeForOptimise(
+                msgContext.getEnvelope());
+        boolean doMTOM = enableMTOM && envelopeContainsOptimise;
+        msgContext.setDoingMTOM(doMTOM);
+        return doMTOM;
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/ServletBasedOutTransportInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPOutTransportInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPOutputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java Thu Sep 15 11:52:11 2005
@@ -1,222 +1,222 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.transport.http;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.transport.TransportListener;
-import org.apache.axis2.transport.http.server.SimpleHttpServer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-/**
- * This is a simple implementation of an HTTP server for processing
- * SOAP requests via Apache's xml-axis.  This is not intended for production
- * use.  Its intended uses are for demos, debugging, and performance
- * profiling.
- * Note this classes uses static objects to provide a thread pool, so you should
- * not use multiple instances of this class in the same JVM/classloader unless
- * you want bad things to happen at shutdown.
- */
-public class SimpleHTTPServer extends TransportListener {
-    /**
-     * Field log
-     */
-    protected Log log = LogFactory.getLog(SimpleHTTPServer.class.getName());
-
-    /**
-     * Field systemContext
-     */
-    protected ConfigurationContext configurationContext;
-
-    /**
-     * Embedded commons http client based server
-     */
-    SimpleHttpServer embedded = null;
-
-    int port = -1;
-
-    /**
-     * Constructor SimpleHTTPServer
-     */
-    public SimpleHTTPServer() {
-    }
-
-    /**
-     * Constructor SimpleHTTPServer
-     *
-     * @param systemContext
-     */
-    public SimpleHTTPServer(ConfigurationContext systemContext,
-                            int port) throws IOException {
-        this.configurationContext = systemContext;
-        this.port = port;
-    }
-
-    /**
-     * Constructor SimpleHTTPServer
-     *
-     * @param dir
-     * @throws AxisFault
-     */
-    public SimpleHTTPServer(String dir, int port) throws AxisFault {
-        try {
-            this.port = port;
-            ConfigurationContextFactory erfac = new ConfigurationContextFactory();
-            this.configurationContext = erfac.buildConfigurationContext(dir);
-            Thread.sleep(2000);
-        } catch (Exception e1) {
-            throw new AxisFault(e1);
-        }
-    }
-
-    /**
-     * Checks if this HTTP server instance is running.
-     *
-     * @return  true/false
-     */
-    public boolean isRunning() {
-        if(embedded == null) {
-            return false;
-        }
-        return embedded.isRunning();
-    }
-
-    /**
-     * stop the server if not already told to.
-     *
-     * @throws Throwable
-     */
-    protected void finalize() throws Throwable {
-        stop();
-        super.finalize();
-    }
-
-    /**
-     * Start this server as a NON-daemon.
-     */
-    public void start() throws AxisFault {
-        try {
-            embedded = new SimpleHttpServer(port);
-            embedded.setRequestHandler(new HTTPWorker(configurationContext));
-        } catch (IOException e) {
-            log.error(e);
-            throw new AxisFault(e);
-        }
-    }
-
-    /**
-     * Stop this server. Can be called safely if the system is already stopped,
-     * or if it was never started.
-     * This will interrupt any pending accept().
-     */
-    public void stop() {
-        log.info("stop called");
-        if(embedded != null) {
-            embedded.destroy();
-        }
-        log.info("Simple Axis Server Quits");
-    }
-
-    /**
-     * Method getSystemContext
-     *
-     * @return the system context
-     */
-    public ConfigurationContext getSystemContext() {
-        return configurationContext;
-    }
-
-    /**
-     * Method main
-     *
-     * @param args
-     * @throws Exception
-     */
-    public static void main(String[] args) throws Exception {
-        if (args.length != 2) {
-            System.out.println("SimpleHTTPServer repositoryLocation port");
-            System.exit(1);
-        }
-        SimpleHTTPServer receiver = new SimpleHTTPServer(args[0], Integer.parseInt(args[1]));
-        System.out.println("starting SimpleHTTPServer in port "
-                + args[1]
-                + " using the repository "
-                + new File(args[0]).getAbsolutePath());
-        try {
-            System.out.println(
-                    "[Axis2] Using the Repository " +
-                    new File(args[0]).getAbsolutePath());
-            System.out.println(
-                    "[Axis2] Starting the SimpleHTTPServer on port " + args[1]);
-            receiver.start();
-            System.out.println("[Axis2] SimpleHTTPServer started");
-            System.in.read();
-        } finally {
-            receiver.stop();
-        }
-    }
-
-    /**
-     * replyToEPR
-     *
-     * @param serviceName
-     * @return an EndpointReference
-     *
-     * @see org.apache.axis2.transport.TransportListener#replyToEPR(java.lang.String)
-     */
-    public EndpointReference replyToEPR(String serviceName) throws AxisFault {
-        String hostAddress = null;
-        try {
-            hostAddress = InetAddress.getLocalHost().getHostAddress();
-        } catch (UnknownHostException e) {
-            throw new AxisFault(e);
-        }
-        return new EndpointReference("http://"+ hostAddress + ":" + (embedded.getLocalPort()) +
-                "/axis2/services/" +
-                serviceName);
-    }
-
-    /**
-     * init method in TransportListener
-     *
-     * @param axisConf
-     * @param transprtIn
-     * @throws AxisFault
-     */
-    public void init(ConfigurationContext axisConf,
-                     TransportInDescription transprtIn)
-            throws AxisFault {
-        try {
-            this.configurationContext = axisConf;
-            Parameter param = transprtIn.getParameter(PARAM_PORT);
-            if (param != null) {
-                this.port = Integer.parseInt((String) param.getValue());
-            }
-        } catch (Exception e1) {
-            throw new AxisFault(e1);
-        }
-    }
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.transport.http;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.transport.TransportListener;
+import org.apache.axis2.transport.http.server.SimpleHttpServer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * This is a simple implementation of an HTTP server for processing
+ * SOAP requests via Apache's xml-axis.  This is not intended for production
+ * use.  Its intended uses are for demos, debugging, and performance
+ * profiling.
+ * Note this classes uses static objects to provide a thread pool, so you should
+ * not use multiple instances of this class in the same JVM/classloader unless
+ * you want bad things to happen at shutdown.
+ */
+public class SimpleHTTPServer extends TransportListener {
+    /**
+     * Field log
+     */
+    protected Log log = LogFactory.getLog(SimpleHTTPServer.class.getName());
+
+    /**
+     * Field systemContext
+     */
+    protected ConfigurationContext configurationContext;
+
+    /**
+     * Embedded commons http client based server
+     */
+    SimpleHttpServer embedded = null;
+
+    int port = -1;
+
+    /**
+     * Constructor SimpleHTTPServer
+     */
+    public SimpleHTTPServer() {
+    }
+
+    /**
+     * Constructor SimpleHTTPServer
+     *
+     * @param systemContext
+     */
+    public SimpleHTTPServer(ConfigurationContext systemContext,
+                            int port) throws IOException {
+        this.configurationContext = systemContext;
+        this.port = port;
+    }
+
+    /**
+     * Constructor SimpleHTTPServer
+     *
+     * @param dir
+     * @throws AxisFault
+     */
+    public SimpleHTTPServer(String dir, int port) throws AxisFault {
+        try {
+            this.port = port;
+            ConfigurationContextFactory erfac = new ConfigurationContextFactory();
+            this.configurationContext = erfac.buildConfigurationContext(dir);
+            Thread.sleep(2000);
+        } catch (Exception e1) {
+            throw new AxisFault(e1);
+        }
+    }
+
+    /**
+     * Checks if this HTTP server instance is running.
+     *
+     * @return  true/false
+     */
+    public boolean isRunning() {
+        if(embedded == null) {
+            return false;
+        }
+        return embedded.isRunning();
+    }
+
+    /**
+     * stop the server if not already told to.
+     *
+     * @throws Throwable
+     */
+    protected void finalize() throws Throwable {
+        stop();
+        super.finalize();
+    }
+
+    /**
+     * Start this server as a NON-daemon.
+     */
+    public void start() throws AxisFault {
+        try {
+            embedded = new SimpleHttpServer(port);
+            embedded.setRequestHandler(new HTTPWorker(configurationContext));
+        } catch (IOException e) {
+            log.error(e);
+            throw new AxisFault(e);
+        }
+    }
+
+    /**
+     * Stop this server. Can be called safely if the system is already stopped,
+     * or if it was never started.
+     * This will interrupt any pending accept().
+     */
+    public void stop() {
+        log.info("stop called");
+        if(embedded != null) {
+            embedded.destroy();
+        }
+        log.info("Simple Axis Server Quits");
+    }
+
+    /**
+     * Method getSystemContext
+     *
+     * @return the system context
+     */
+    public ConfigurationContext getSystemContext() {
+        return configurationContext;
+    }
+
+    /**
+     * Method main
+     *
+     * @param args
+     * @throws Exception
+     */
+    public static void main(String[] args) throws Exception {
+        if (args.length != 2) {
+            System.out.println("SimpleHTTPServer repositoryLocation port");
+            System.exit(1);
+        }
+        SimpleHTTPServer receiver = new SimpleHTTPServer(args[0], Integer.parseInt(args[1]));
+        System.out.println("starting SimpleHTTPServer in port "
+                + args[1]
+                + " using the repository "
+                + new File(args[0]).getAbsolutePath());
+        try {
+            System.out.println(
+                    "[Axis2] Using the Repository " +
+                    new File(args[0]).getAbsolutePath());
+            System.out.println(
+                    "[Axis2] Starting the SimpleHTTPServer on port " + args[1]);
+            receiver.start();
+            System.out.println("[Axis2] SimpleHTTPServer started");
+            System.in.read();
+        } finally {
+            receiver.stop();
+        }
+    }
+
+    /**
+     * replyToEPR
+     *
+     * @param serviceName
+     * @return an EndpointReference
+     *
+     * @see org.apache.axis2.transport.TransportListener#replyToEPR(java.lang.String)
+     */
+    public EndpointReference replyToEPR(String serviceName) throws AxisFault {
+        String hostAddress = null;
+        try {
+            hostAddress = InetAddress.getLocalHost().getHostAddress();
+        } catch (UnknownHostException e) {
+            throw new AxisFault(e);
+        }
+        return new EndpointReference("http://"+ hostAddress + ":" + (embedded.getLocalPort()) +
+                "/axis2/services/" +
+                serviceName);
+    }
+
+    /**
+     * init method in TransportListener
+     *
+     * @param axisConf
+     * @param transprtIn
+     * @throws AxisFault
+     */
+    public void init(ConfigurationContext axisConf,
+                     TransportInDescription transprtIn)
+            throws AxisFault {
+        try {
+            this.configurationContext = axisConf;
+            Parameter param = transprtIn.getParameter(PARAM_PORT);
+            if (param != null) {
+                this.port = Integer.parseInt((String) param.getValue());
+            }
+        } catch (Exception e1) {
+            throw new AxisFault(e1);
+        }
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/AdminAppException.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/AdminAppException.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/AdminAppException.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/AdminAppException.java Thu Sep 15 11:52:11 2005
@@ -1,36 +1,36 @@
-package org.apache.axis2.transport.http.server;
-
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * 
- */
-public class AdminAppException extends Exception{
-
-    public AdminAppException() {
-    }
-
-    public AdminAppException(String message) {
-        super(message);
-    }
-
-    public AdminAppException(Throwable cause) {
-        super(cause);
-    }
-
-    public AdminAppException(String message, Throwable cause) {
-        super(message, cause);
-    }
-}
+package org.apache.axis2.transport.http.server;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * 
+ */
+public class AdminAppException extends Exception{
+
+    public AdminAppException() {
+    }
+
+    public AdminAppException(String message) {
+        super(message);
+    }
+
+    public AdminAppException(Throwable cause) {
+        super(cause);
+    }
+
+    public AdminAppException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/AdminAppException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/local/LocalTransportReceiver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/local/LocalTransportSender.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/EMailSender.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailTransportSender.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailWorker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/SimpleMailListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailAddress.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailSorter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailSrvConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/POP3Server.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/POP3Worker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPServer.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPServer.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPServer.java Thu Sep 15 11:52:11 2005
@@ -1,93 +1,93 @@
-package org.apache.axis2.transport.mail.server;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.net.Socket;
-
-/**
- * @author Chamil Thanthrimudalige
- * @author Chamikara Jayalath
- */
-
-public class SMTPServer extends Thread {
-    private Storage st;
-
-    private ConfigurationContext configurationContext;
-    private Log log = LogFactory.getLog(getClass());
-
-    private int port;
-
-    private boolean actAsMailet = false;
-    private ServerSocket ss;
-    private boolean running = false;
-
-    public SMTPServer(
-        Storage st,
-        ConfigurationContext configurationContext,
-        int port) {
-        this.st = st;
-        this.configurationContext = configurationContext;
-        this.port = port;
-        actAsMailet = true;
-    }
-
-    public SMTPServer(Storage st, int port) {
-        this.st = st;
-        this.port = port;
-        actAsMailet = false;
-    }
-
-    public void run() {
-        runServer();
-    }
-
-    public void runServer() {
-
-        try {
-            synchronized (this) {
-                running = true;
-                ss = new ServerSocket(port);
-                log.info("SMTP Server started on port " + port);
-            }
-        } catch (IOException ex) {
-            log.info(ex.getMessage());
-//            ex.printStackTrace();
-        }
-
-        while (running) {
-            try {
-                //wait for a client
-                Socket socket = ss.accept();
-                SMTPWorker thread = null;
-                if (actAsMailet)
-                    thread = new SMTPWorker(socket, st, configurationContext);
-                else {
-                    thread = new SMTPWorker(socket, st);
-                }
-                thread.start();
-
-            } catch (IOException ex) {
-                if (running) {
-                    log.info(ex.getMessage());
-//                    ex.printStackTrace();
-                }
-            }
-        }
-    }
-
-    public void stopServer() throws AxisFault {
-        try {
-            synchronized (this) {
-                running = false;
-                ss.close();
-            }
-        } catch (IOException e) {
-            throw new AxisFault(e);
-        }
-    }
-}
+package org.apache.axis2.transport.mail.server;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+/**
+ * @author Chamil Thanthrimudalige
+ * @author Chamikara Jayalath
+ */
+
+public class SMTPServer extends Thread {
+    private Storage st;
+
+    private ConfigurationContext configurationContext;
+    private Log log = LogFactory.getLog(getClass());
+
+    private int port;
+
+    private boolean actAsMailet = false;
+    private ServerSocket ss;
+    private boolean running = false;
+
+    public SMTPServer(
+        Storage st,
+        ConfigurationContext configurationContext,
+        int port) {
+        this.st = st;
+        this.configurationContext = configurationContext;
+        this.port = port;
+        actAsMailet = true;
+    }
+
+    public SMTPServer(Storage st, int port) {
+        this.st = st;
+        this.port = port;
+        actAsMailet = false;
+    }
+
+    public void run() {
+        runServer();
+    }
+
+    public void runServer() {
+
+        try {
+            synchronized (this) {
+                running = true;
+                ss = new ServerSocket(port);
+                log.info("SMTP Server started on port " + port);
+            }
+        } catch (IOException ex) {
+            log.info(ex.getMessage());
+//            ex.printStackTrace();
+        }
+
+        while (running) {
+            try {
+                //wait for a client
+                Socket socket = ss.accept();
+                SMTPWorker thread = null;
+                if (actAsMailet)
+                    thread = new SMTPWorker(socket, st, configurationContext);
+                else {
+                    thread = new SMTPWorker(socket, st);
+                }
+                thread.start();
+
+            } catch (IOException ex) {
+                if (running) {
+                    log.info(ex.getMessage());
+//                    ex.printStackTrace();
+                }
+            }
+        }
+    }
+
+    public void stopServer() throws AxisFault {
+        try {
+            synchronized (this) {
+                running = false;
+                ss.close();
+            }
+        } catch (IOException e) {
+            throw new AxisFault(e);
+        }
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPWorker.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPWorker.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPWorker.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPWorker.java Thu Sep 15 11:52:11 2005
@@ -1,259 +1,259 @@
-package org.apache.axis2.transport.mail.server;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.mail.*;
-import javax.mail.internet.MimeMessage;
-import java.io.*;
-import java.net.Socket;
-import java.util.ArrayList;
-import java.util.Properties;
-
-/**
- * @author Chamil Thanthrimudalige
- * @author Chamikara Jayalath
- */
-
-public class SMTPWorker extends Thread {
-
-    private BufferedReader reader = null;
-
-    private BufferedWriter writer = null;
-
-    private boolean actAsMailet = false;
-
-    private ArrayList receivers = new ArrayList();
-
-    private Storage st = null;
-
-    boolean runThread = true;
-
-    private MimeMessage mail = null;
-
-    private ConfigurationContext configurationContext = null;
-
-    private String temp = "";
-
-    private boolean dataWriting = false;
-
-    private boolean transmitionEnd = false;
-
-    private boolean bodyData = false;
-    private Log log = LogFactory.getLog(getClass());
-
-    public SMTPWorker(Socket socket, Storage st,
-            ConfigurationContext configurationContext) {
-        doWork(socket, st, configurationContext);
-    }
-
-    public SMTPWorker(Socket socket, Storage st) {
-        doWork(socket, st, null);
-    }
-
-    private void doWork(Socket socket, Storage st,
-            ConfigurationContext configurationContext) {
-        try {
-            this.st = st;
-            if (configurationContext == null) {
-                actAsMailet = false;
-            } else {
-                this.configurationContext = configurationContext;
-                actAsMailet = true;
-            }
-            //get the streams from the socket and save in instance variables.
-            reader = new BufferedReader(new InputStreamReader(socket
-                    .getInputStream()));
-            writer = new BufferedWriter(new OutputStreamWriter(socket
-                    .getOutputStream()));
-        } catch (IOException ex) {
-            log.info(ex.getMessage());
-//            ex.printStackTrace();
-        }
-    }
-
-    //running the thread
-    public void run() {
-        try {
-            //do initial transmission.
-            initializeClient();
-
-            //analyze all the inputs from client and work accordingly.
-            while (runThread) {
-                String input = null;
-
-                //get client input
-                input = reader.readLine();
-
-                String retString = processInput(input);
-
-                if (MailSrvConstants.COMMAND_EXIT.equals(retString)) {
-                    exitWorker();
-                } else {
-                    if (retString != null) {
-                        send(retString); //Send the reply
-                    }
-                    if (mail != null && transmitionEnd) {
-                        exitWorker();
-                    }
-                }
-            }
-            for (int idx = 0; idx < receivers.size(); idx++) {
-                try {
-                    MailSorter mSort = null;
-                    if (actAsMailet) {
-                        mSort = new MailSorter(this.st,
-                                this.configurationContext);
-                    } else {
-                        mSort = new MailSorter(this.st, null);
-                    }
-                    mSort.sort((String) receivers.get(idx), new MimeMessage(
-                            mail));
-                } catch (MessagingException e1) {
-                    log.info(e1.getMessage());
-                    //e1.printStackTrace();
-                }
-            }
-            //
-
-        } catch (IOException e) {
-            log.info("ERROR: CLIENT CLOSED THE SOCKET");
-        }
-    }
-
-    private void send(String s) throws IOException {
-        writer.write(s);
-        writer.newLine();
-        writer.flush();
-    }
-
-    private String processInput(String input) {
-        byte[] CR_LF = new byte[] { 0x0D, 0x0A };
-        if (input == null)
-            return MailSrvConstants.COMMAND_UNKNOWN;
-        if (mail != null && transmitionEnd)
-            return MailSrvConstants.COMMAND_TRANSMISSION_END;
-
-        if (input.startsWith("MAIL")) {
-            mail = new MimeMessage(Session.getInstance(new Properties(),
-                    new Authenticator() {
-                        protected PasswordAuthentication getPasswordAuthentication() {
-                            return null;
-                        }
-                    }));
-
-            int start = input.indexOf("<") + 1;
-            int end;
-
-            if (start <= 0) {
-                start = input.indexOf("FROM:") + 5;
-                end = input.length();
-            } else {
-                end = input.indexOf(">");
-            }
-
-            String from = input.substring(start, end);
-
-            if (from != null && !from.trim().equals("")) {
-                //TODO this is an ugly hack to get the from address in. There
-                // should be a better way to do this.
-                MailAddress mailFrom[] = new MailAddress[1];
-                mailFrom[0] = new MailAddress(from);
-                try {
-                    mail.addFrom(mailFrom);
-                } catch (MessagingException e) {
-                    log.info(e.getMessage());
-                    // TODO Auto-generated catch block
-                }
-            }
-
-            return MailSrvConstants.MAIL_OK;
-
-        }
-        if (input.startsWith("HELO")) {
-            return MailSrvConstants.HELO_REPLY;
-
-        } else if (input.startsWith("RCPT")) {
-
-            String domain = MailSrvConstants.SERVER_DOMAIN;
-            //System.out.println("RCPT:" + input);
-            //temp += input + "\n"; TODO Check this
-            int start = input.indexOf("<") + 1;
-            int end;
-
-            if (start <= 0) {
-                start = input.indexOf("TO:") + 3;
-                /*
-                 * if(!input.endsWith(domain)){ System.out.println("ERROR: wrong
-                 * donmain name"); return MailSrvConstants.RCPT_ERROR; }
-                 */
-            } else {
-                /*
-                 * if(!input.endsWith(domain + ">")){ System.out.println("ERROR:
-                 * wrong donmain name"); return MailSrvConstants.RCPT_ERROR; }
-                 */
-            }
-
-            end = input.indexOf(">");
-            String toStr = input.substring(start, end);
-
-            try {
-                mail.addRecipient(Message.RecipientType.TO, new MailAddress(
-                        toStr));
-                receivers.add(toStr);
-            } catch (MessagingException e) {
-                log.info(e.getMessage());
-                // TODO Auto-generated catch block
-            }
-            return MailSrvConstants.RCPT_OK;
-
-        } else if (input.equalsIgnoreCase("DATA")) {
-            dataWriting = true;
-            return MailSrvConstants.DATA_START_SUCCESS;
-
-        } else if (input.equalsIgnoreCase("QUIT")) {
-            dataWriting = true;
-            transmitionEnd = true;
-            return MailSrvConstants.COMMAND_TRANSMISSION_END;
-
-        } else if (input.equals(".")) {
-            dataWriting = false;
-            return MailSrvConstants.DATA_END_SUCCESS;
-        } else if (input.equals("") && !bodyData) {
-            bodyData = true;
-            return null;
-        } else if (mail != null && dataWriting) {
-            try {
-                if (bodyData) {
-                    temp += input;
-                    mail.setContent(temp, "text/plain");
-                } else {
-                    mail.addHeaderLine(input);
-                }
-            } catch (MessagingException e) {
-                log.info(e.getMessage());
-                // TODO Auto-generated catch block
-            }
-            return null;
-
-        } else {
-            return MailSrvConstants.COMMAND_UNKNOWN;
-        }
-
-    }
-
-    //transmission is over. setting to exit
-    private void exitWorker() throws IOException {
-        reader.close();
-        writer.close();
-        runThread = false;
-    }
-
-    //initializing the client by sending the initial message.
-    private void initializeClient() throws IOException {
-        if (writer != null) {
-            send("220 SMTP Server IS UP");
-        }
-    }
-}
+package org.apache.axis2.transport.mail.server;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.mail.*;
+import javax.mail.internet.MimeMessage;
+import java.io.*;
+import java.net.Socket;
+import java.util.ArrayList;
+import java.util.Properties;
+
+/**
+ * @author Chamil Thanthrimudalige
+ * @author Chamikara Jayalath
+ */
+
+public class SMTPWorker extends Thread {
+
+    private BufferedReader reader = null;
+
+    private BufferedWriter writer = null;
+
+    private boolean actAsMailet = false;
+
+    private ArrayList receivers = new ArrayList();
+
+    private Storage st = null;
+
+    boolean runThread = true;
+
+    private MimeMessage mail = null;
+
+    private ConfigurationContext configurationContext = null;
+
+    private String temp = "";
+
+    private boolean dataWriting = false;
+
+    private boolean transmitionEnd = false;
+
+    private boolean bodyData = false;
+    private Log log = LogFactory.getLog(getClass());
+
+    public SMTPWorker(Socket socket, Storage st,
+            ConfigurationContext configurationContext) {
+        doWork(socket, st, configurationContext);
+    }
+
+    public SMTPWorker(Socket socket, Storage st) {
+        doWork(socket, st, null);
+    }
+
+    private void doWork(Socket socket, Storage st,
+            ConfigurationContext configurationContext) {
+        try {
+            this.st = st;
+            if (configurationContext == null) {
+                actAsMailet = false;
+            } else {
+                this.configurationContext = configurationContext;
+                actAsMailet = true;
+            }
+            //get the streams from the socket and save in instance variables.
+            reader = new BufferedReader(new InputStreamReader(socket
+                    .getInputStream()));
+            writer = new BufferedWriter(new OutputStreamWriter(socket
+                    .getOutputStream()));
+        } catch (IOException ex) {
+            log.info(ex.getMessage());
+//            ex.printStackTrace();
+        }
+    }
+
+    //running the thread
+    public void run() {
+        try {
+            //do initial transmission.
+            initializeClient();
+
+            //analyze all the inputs from client and work accordingly.
+            while (runThread) {
+                String input = null;
+
+                //get client input
+                input = reader.readLine();
+
+                String retString = processInput(input);
+
+                if (MailSrvConstants.COMMAND_EXIT.equals(retString)) {
+                    exitWorker();
+                } else {
+                    if (retString != null) {
+                        send(retString); //Send the reply
+                    }
+                    if (mail != null && transmitionEnd) {
+                        exitWorker();
+                    }
+                }
+            }
+            for (int idx = 0; idx < receivers.size(); idx++) {
+                try {
+                    MailSorter mSort = null;
+                    if (actAsMailet) {
+                        mSort = new MailSorter(this.st,
+                                this.configurationContext);
+                    } else {
+                        mSort = new MailSorter(this.st, null);
+                    }
+                    mSort.sort((String) receivers.get(idx), new MimeMessage(
+                            mail));
+                } catch (MessagingException e1) {
+                    log.info(e1.getMessage());
+                    //e1.printStackTrace();
+                }
+            }
+            //
+
+        } catch (IOException e) {
+            log.info("ERROR: CLIENT CLOSED THE SOCKET");
+        }
+    }
+
+    private void send(String s) throws IOException {
+        writer.write(s);
+        writer.newLine();
+        writer.flush();
+    }
+
+    private String processInput(String input) {
+        byte[] CR_LF = new byte[] { 0x0D, 0x0A };
+        if (input == null)
+            return MailSrvConstants.COMMAND_UNKNOWN;
+        if (mail != null && transmitionEnd)
+            return MailSrvConstants.COMMAND_TRANSMISSION_END;
+
+        if (input.startsWith("MAIL")) {
+            mail = new MimeMessage(Session.getInstance(new Properties(),
+                    new Authenticator() {
+                        protected PasswordAuthentication getPasswordAuthentication() {
+                            return null;
+                        }
+                    }));
+
+            int start = input.indexOf("<") + 1;
+            int end;
+
+            if (start <= 0) {
+                start = input.indexOf("FROM:") + 5;
+                end = input.length();
+            } else {
+                end = input.indexOf(">");
+            }
+
+            String from = input.substring(start, end);
+
+            if (from != null && !from.trim().equals("")) {
+                //TODO this is an ugly hack to get the from address in. There
+                // should be a better way to do this.
+                MailAddress mailFrom[] = new MailAddress[1];
+                mailFrom[0] = new MailAddress(from);
+                try {
+                    mail.addFrom(mailFrom);
+                } catch (MessagingException e) {
+                    log.info(e.getMessage());
+                    // TODO Auto-generated catch block
+                }
+            }
+
+            return MailSrvConstants.MAIL_OK;
+
+        }
+        if (input.startsWith("HELO")) {
+            return MailSrvConstants.HELO_REPLY;
+
+        } else if (input.startsWith("RCPT")) {
+
+            String domain = MailSrvConstants.SERVER_DOMAIN;
+            //System.out.println("RCPT:" + input);
+            //temp += input + "\n"; TODO Check this
+            int start = input.indexOf("<") + 1;
+            int end;
+
+            if (start <= 0) {
+                start = input.indexOf("TO:") + 3;
+                /*
+                 * if(!input.endsWith(domain)){ System.out.println("ERROR: wrong
+                 * donmain name"); return MailSrvConstants.RCPT_ERROR; }
+                 */
+            } else {
+                /*
+                 * if(!input.endsWith(domain + ">")){ System.out.println("ERROR:
+                 * wrong donmain name"); return MailSrvConstants.RCPT_ERROR; }
+                 */
+            }
+
+            end = input.indexOf(">");
+            String toStr = input.substring(start, end);
+
+            try {
+                mail.addRecipient(Message.RecipientType.TO, new MailAddress(
+                        toStr));
+                receivers.add(toStr);
+            } catch (MessagingException e) {
+                log.info(e.getMessage());
+                // TODO Auto-generated catch block
+            }
+            return MailSrvConstants.RCPT_OK;
+
+        } else if (input.equalsIgnoreCase("DATA")) {
+            dataWriting = true;
+            return MailSrvConstants.DATA_START_SUCCESS;
+
+        } else if (input.equalsIgnoreCase("QUIT")) {
+            dataWriting = true;
+            transmitionEnd = true;
+            return MailSrvConstants.COMMAND_TRANSMISSION_END;
+
+        } else if (input.equals(".")) {
+            dataWriting = false;
+            return MailSrvConstants.DATA_END_SUCCESS;
+        } else if (input.equals("") && !bodyData) {
+            bodyData = true;
+            return null;
+        } else if (mail != null && dataWriting) {
+            try {
+                if (bodyData) {
+                    temp += input;
+                    mail.setContent(temp, "text/plain");
+                } else {
+                    mail.addHeaderLine(input);
+                }
+            } catch (MessagingException e) {
+                log.info(e.getMessage());
+                // TODO Auto-generated catch block
+            }
+            return null;
+
+        } else {
+            return MailSrvConstants.COMMAND_UNKNOWN;
+        }
+
+    }
+
+    //transmission is over. setting to exit
+    private void exitWorker() throws IOException {
+        reader.close();
+        writer.close();
+        runThread = false;
+    }
+
+    //initializing the client by sending the initial message.
+    private void initializeClient() throws IOException {
+        if (writer != null) {
+            send("220 SMTP Server IS UP");
+        }
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPWorker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/Storage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/tcp/TCPServer.java
------------------------------------------------------------------------------
    svn:eol-style = native