axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r761044 - in /webservices/axis2/trunk/java/modules/kernel: src/org/apache/axis2/transport/TransportUtils.java src/org/apache/axis2/transport/http/util/QueryStringParser.java test/org/apache/axis2/transport/http/util/QueryStringParserTest.java
Date Wed, 01 Apr 2009 20:23:49 GMT
Author: gawor
Date: Wed Apr  1 20:23:49 2009
New Revision: 761044

URL: http://svn.apache.org/viewvc?rev=761044&view=rev
Log:
Step 1 in moving http and local transport modules to Axis2. Moved some utility classes and
methods from Transport project to Axis2

Added:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/QueryStringParser.java
  (contents, props changed)
      - copied, changed from r761016, webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/QueryStringParser.java
    webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/transport/http/util/QueryStringParserTest.java
  (contents, props changed)
      - copied, changed from r761016, webservices/commons/trunk/modules/transport/modules/base/src/test/java/org/apache/axis2/transport/base/QueryStringParserTest.java
Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java?rev=761044&r1=761043&r2=761044&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
Wed Apr  1 20:23:49 2009
@@ -38,6 +38,7 @@
 import org.apache.axis2.builder.Builder;
 import org.apache.axis2.builder.BuilderUtil;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.deployment.DeploymentConstants;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.i18n.Messages;
@@ -597,4 +598,139 @@
                throw AxisFault.makeFault(t);
            }
        }
+
+    /**
+     * <p>
+     * Checks whether MTOM needs to be enabled for the message represented by
+     * the msgContext. We check value assigned to the "enableMTOM" property
+     * either using the config files (axis2.xml, services.xml) or
+     * programatically. Programatic configuration is given priority. If the
+     * given value is "optional", MTOM will be enabled only if the incoming
+     * message was an MTOM message.
+     * </p>
+     *
+     * @param msgContext the active MessageContext
+     * @return true if SwA needs to be enabled
+     */
+    public static boolean doWriteMTOM(MessageContext msgContext) {
+        boolean enableMTOM;
+        Object enableMTOMObject = null;
+        // First check the whether MTOM is enabled by the configuration
+        // (Eg:Axis2.xml, services.xml)
+        Parameter parameter = msgContext.getParameter(Constants.Configuration.ENABLE_MTOM);
+        if (parameter != null) {
+            enableMTOMObject = parameter.getValue();
+        }
+        // Check whether the configuration is overridden programatically..
+        // Priority given to programatically setting of the value
+        Object property = msgContext.getProperty(Constants.Configuration.ENABLE_MTOM);
+        if (property != null) {
+            enableMTOMObject = property;
+        }
+        enableMTOM = JavaUtils.isTrueExplicitly(enableMTOMObject);
+        // Handle the optional value for enableMTOM
+        // If the value for 'enableMTOM' is given as optional and if the request
+        // message was a MTOM message we sent out MTOM
+        if (!enableMTOM && msgContext.isDoingMTOM() && (enableMTOMObject
instanceof String)) {
+            if (((String) enableMTOMObject).equalsIgnoreCase(Constants.VALUE_OPTIONAL)) {
+                //In server side, we check whether request was MTOM
+                if (msgContext.isServerSide()) {
+                    if (msgContext.isDoingMTOM()) {
+                        enableMTOM = true;
+                    } 
+                    // in the client side, we enable MTOM if it is optional    
+                } else {
+                    enableMTOM = true;
+                }
+            }
+        }
+        return enableMTOM;
+    }
+
+    /**
+     * <p>
+     * Checks whether SOAP With Attachments (SwA) needs to be enabled for the
+     * message represented by the msgContext. We check value assigned to the
+     * "enableSwA" property either using the config files (axis2.xml,
+     * services.xml) or programatically. Programatic configuration is given
+     * priority. If the given value is "optional", SwA will be enabled only if
+     * the incoming message was SwA type.
+     * </p>
+     *
+     * @param msgContext the active MessageContext
+     * @return true if SwA needs to be enabled
+     */
+    public static boolean doWriteSwA(MessageContext msgContext) {
+        boolean enableSwA;
+        Object enableSwAObject = null;
+        // First check the whether SwA is enabled by the configuration
+        // (Eg:Axis2.xml, services.xml)
+        Parameter parameter = msgContext.getParameter(Constants.Configuration.ENABLE_SWA);
+        if (parameter != null) {
+            enableSwAObject = parameter.getValue();
+        }
+        // Check whether the configuration is overridden programatically..
+        // Priority given to programatically setting of the value
+        Object property = msgContext.getProperty(Constants.Configuration.ENABLE_SWA);
+        if (property != null) {
+            enableSwAObject = property;
+        }
+        enableSwA = JavaUtils.isTrueExplicitly(enableSwAObject);
+        // Handle the optional value for enableSwA
+        // If the value for 'enableSwA' is given as optional and if the request
+        // message was a SwA message we sent out SwA
+        if (!enableSwA && msgContext.isDoingSwA() && (enableSwAObject instanceof
String)) {
+            if (((String) enableSwAObject).equalsIgnoreCase(Constants.VALUE_OPTIONAL)) {
+                enableSwA = true;
+            }
+        }
+        return enableSwA;
+    }
+
+    public static boolean isDoingREST(MessageContext msgContext) {
+        boolean enableREST = false;
+
+        // check whether isDoingRest is already true in the message context
+        if (msgContext.isDoingREST()) {
+            return true;
+        }
+        
+        Object enableRESTProperty = msgContext.getProperty(Constants.Configuration.ENABLE_REST);
+        if (enableRESTProperty != null) {
+            enableREST = JavaUtils.isTrueExplicitly(enableRESTProperty);
+        }
+
+        msgContext.setDoingREST(enableREST);
+
+        return enableREST;
+    }
+
+    /**
+     * Utility method to query CharSetEncoding. First look in the
+     * MessageContext. If it's not there look in the OpContext. Use the defualt,
+     * if it's not given in either contexts.
+     *
+     * @param msgContext the active MessageContext
+     * @return String the CharSetEncoding
+     */
+    public static String getCharSetEncoding(MessageContext msgContext) {
+        String charSetEnc = (String) msgContext
+            .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
+
+        if (charSetEnc == null) {
+            OperationContext opctx = msgContext.getOperationContext();
+            if (opctx != null) {
+                charSetEnc = (String) opctx
+                    .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
+            }
+            /**
+             * If the char set enc is still not found use the default
+             */
+            if (charSetEnc == null) {
+                charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
+            }
+        }
+        return charSetEnc;
+    }
+
 }

Copied: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/QueryStringParser.java
(from r761016, webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/QueryStringParser.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/QueryStringParser.java?p2=webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/QueryStringParser.java&p1=webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/QueryStringParser.java&r1=761016&r2=761044&rev=761044&view=diff
==============================================================================
--- webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/QueryStringParser.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/QueryStringParser.java
Wed Apr  1 20:23:49 2009
@@ -17,17 +17,14 @@
  *  under the License.
  */
 
-package org.apache.axis2.transport.base;
+package org.apache.axis2.transport.http.util;
 
 import java.io.UnsupportedEncodingException;
 import java.util.Collection;
 
-import org.apache.axis2.transport.http.util.URIEncoderDecoder;
-
 /**
  * Parser for URL query strings.
  */
-// TODO: maybe this class should go to Axis2 and be reused in XFormURLEncodedBuilder
 public class QueryStringParser {
     private final String queryString;
     

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

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/QueryStringParser.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/transport/http/util/QueryStringParserTest.java
(from r761016, webservices/commons/trunk/modules/transport/modules/base/src/test/java/org/apache/axis2/transport/base/QueryStringParserTest.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/transport/http/util/QueryStringParserTest.java?p2=webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/transport/http/util/QueryStringParserTest.java&p1=webservices/commons/trunk/modules/transport/modules/base/src/test/java/org/apache/axis2/transport/base/QueryStringParserTest.java&r1=761016&r2=761044&rev=761044&view=diff
==============================================================================
--- webservices/commons/trunk/modules/transport/modules/base/src/test/java/org/apache/axis2/transport/base/QueryStringParserTest.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/transport/http/util/QueryStringParserTest.java
Wed Apr  1 20:23:49 2009
@@ -17,7 +17,7 @@
  *  under the License.
  */
 
-package org.apache.axis2.transport.base;
+package org.apache.axis2.transport.http.util;
 
 import junit.framework.TestCase;
 

Propchange: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/transport/http/util/QueryStringParserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/transport/http/util/QueryStringParserTest.java
------------------------------------------------------------------------------
    svn:mergeinfo = 



Mime
View raw message