axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sami...@apache.org
Subject svn commit: r307009 - in /webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http: CommonsHTTPTransportSender.java HTTPTransportUtils.java
Date Fri, 07 Oct 2005 04:43:18 GMT
Author: saminda
Date: Thu Oct  6 21:43:11 2005
New Revision: 307009

URL: http://svn.apache.org/viewcvs?rev=307009&view=rev
Log:
Change tranport sender and its utilities to handle REST behaviour through properties 

Modified:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java?rev=307009&r1=307008&r2=307009&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
Thu Oct  6 21:43:11 2005
@@ -126,6 +126,12 @@
             }
 
             OMElement dataOut;
+            /**
+             * Figuringout the REST properties/parameters
+             */
+            msgContext.setDoingREST(HTTPTransportUtils.isDoingREST(msgContext));
+            msgContext.setRestThroughPOST(HTTPTransportUtils.isDoingRESTThoughPost(msgContext));
+            
             if (msgContext.isDoingREST()) {
                 dataOut = msgContext.getEnvelope().getBody().getFirstElement();
             } else {

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=307009&r1=307008&r2=307009&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 Oct  6 21:43:11 2005
@@ -147,22 +147,31 @@
                             > -1) {
                         soap11 = true;
                         //it is SOAP 1.1
-                        Object enable =
-                            msgContext.getProperty(
-                                Constants.Configuration.ENABLE_REST);
+
+//                            msgContext.getProperty(
+//                                Constants.Configuration.ENABLE_REST);
+                        /**
+                         * Configuration via Deployment
+                         */
+
+                        Parameter enable  = msgContext.getParameter(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());
+                                || soapActionHeader.length() == 0)
+                                && enable != null) {
+                            if (Constants.VALUE_TRUE
+                                    .equals(enable.getValue())) {
+                                //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(
@@ -448,5 +457,44 @@
         boolean doMTOM = enableMTOM && envelopeContainsOptimise;
         msgContext.setDoingMTOM(doMTOM);
         return doMTOM;
+    }
+
+    public static boolean isDoingREST(MessageContext msgContext) {
+        boolean enableREST = false;
+        if (msgContext.getParameter(Constants.Configuration.ENABLE_REST)
+            != null) {
+            enableREST =
+                Constants.VALUE_TRUE.equals(
+                    msgContext.getParameter(
+                        Constants.Configuration.ENABLE_REST).getValue());
+        } else if(msgContext.getProperty(Constants.Configuration.ENABLE_REST) != null) {
+            enableREST =
+                Constants.VALUE_TRUE.equals(
+                    msgContext.getProperty(
+                        Constants.Configuration.ENABLE_REST));
+        }
+        msgContext.setDoingREST(enableREST);
+        return enableREST;
+
+    }
+
+    public static boolean isDoingRESTThoughPost(MessageContext msgContext) {
+        boolean restThroughPost = true;
+
+        if (msgContext.getParameter(Constants.Configuration.ENABLE_REST_THROUGH_GET)
+            != null) {
+            restThroughPost =
+                Constants.VALUE_TRUE.equals(
+                    msgContext.getParameter(
+                        Constants.Configuration.ENABLE_REST_THROUGH_GET).getValue());
+        } else if(msgContext.getProperty(Constants.Configuration.ENABLE_REST_THROUGH_GET)
!= null) {
+            restThroughPost =
+                Constants.VALUE_TRUE.equals(
+                    msgContext.getProperty(
+                        Constants.Configuration.ENABLE_REST_THROUGH_GET));
+        }
+        msgContext.setRestThroughPOST(!restThroughPost);
+        return restThroughPost;
+
     }
 }



Mime
View raw message