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 2006/07/28 14:24:23 UTC
svn commit: r426488 - in /webservices/axis2/trunk/java/modules:
common/src/org/apache/axis2/util/ core/src/org/apache/axis2/
core/src/org/apache/axis2/transport/http/
core/src/org/apache/axis2/transport/http/util/
core/src/org/apache/axis2/util/
Author: dims
Date: Fri Jul 28 05:24:22 2006
New Revision: 426488
URL: http://svn.apache.org/viewvc?rev=426488&view=rev
Log:
- Remove duplicate HTTPConstants class
- Allow the user to set a Boolean.TRUE in addition to "true"
Removed:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/HTTPConstants.java
Modified:
webservices/axis2/trunk/java/modules/common/src/org/apache/axis2/util/JavaUtils.java
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/HTTPConstants.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/util/RESTUtil.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/SchemaUtil.java
Modified: webservices/axis2/trunk/java/modules/common/src/org/apache/axis2/util/JavaUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/common/src/org/apache/axis2/util/JavaUtils.java?rev=426488&r1=426487&r2=426488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/common/src/org/apache/axis2/util/JavaUtils.java (original)
+++ webservices/axis2/trunk/java/modules/common/src/org/apache/axis2/util/JavaUtils.java Fri Jul 28 05:24:22 2006
@@ -179,4 +179,132 @@
return name;
} // capitalizeFirstChar
+
+ /**
+ * Tests the String 'value':
+ * return 'false' if its 'false', '0', or 'no' - else 'true'
+ *
+ * Follow in 'C' tradition of boolean values:
+ * false is specific (0), everything else is true;
+ */
+ public static final boolean isTrue(String value) {
+ return !isFalseExplicitly(value);
+ }
+
+ /**
+ * Tests the String 'value':
+ * return 'true' if its 'true', '1', or 'yes' - else 'false'
+ */
+ public static final boolean isTrueExplicitly(String value) {
+ return value != null &&
+ (value.equalsIgnoreCase("true") ||
+ value.equals("1") ||
+ value.equalsIgnoreCase("yes"));
+ }
+
+ /**
+ * Tests the Object 'value':
+ * if its null, return default.
+ * if its a Boolean, return booleanValue()
+ * if its an Integer, return 'false' if its '0' else 'true'
+ * if its a String, return isTrueExplicitly((String)value).
+ * All other types return 'true'
+ */
+ public static final boolean isTrueExplicitly(Object value, boolean defaultVal) {
+ if ( value == null ) return defaultVal;
+ if ( value instanceof Boolean ) {
+ return ((Boolean)value).booleanValue();
+ }
+ if ( value instanceof Integer ) {
+ return ((Integer)value).intValue() != 0;
+ }
+ if ( value instanceof String ) {
+ return isTrueExplicitly( (String)value );
+ }
+ return true;
+ }
+
+ public static final boolean isTrueExplicitly(Object value) {
+ return isTrueExplicitly(value, false);
+ }
+
+ /**
+ * Tests the Object 'value':
+ * if its null, return default.
+ * if its a Boolean, return booleanValue()
+ * if its an Integer, return 'false' if its '0' else 'true'
+ * if its a String, return 'false' if its 'false', 'no', or '0' - else 'true'
+ * All other types return 'true'
+ */
+ public static final boolean isTrue(Object value, boolean defaultVal) {
+ return !isFalseExplicitly(value, !defaultVal);
+ }
+
+ public static final boolean isTrue(Object value) {
+ return isTrue(value, false);
+ }
+
+ /**
+ * Tests the String 'value':
+ * return 'true' if its 'false', '0', or 'no' - else 'false'
+ *
+ * Follow in 'C' tradition of boolean values:
+ * false is specific (0), everything else is true;
+ */
+ public static final boolean isFalse(String value) {
+ return isFalseExplicitly(value);
+ }
+
+ /**
+ * Tests the String 'value':
+ * return 'true' if its null, 'false', '0', or 'no' - else 'false'
+ */
+ public static final boolean isFalseExplicitly(String value) {
+ return value == null ||
+ value.equalsIgnoreCase("false") ||
+ value.equals("0") ||
+ value.equalsIgnoreCase("no");
+ }
+
+ /**
+ * Tests the Object 'value':
+ * if its null, return default.
+ * if its a Boolean, return !booleanValue()
+ * if its an Integer, return 'true' if its '0' else 'false'
+ * if its a String, return isFalseExplicitly((String)value).
+ * All other types return 'false'
+ */
+ public static final boolean isFalseExplicitly(Object value, boolean defaultVal) {
+ if ( value == null ) return defaultVal;
+ if ( value instanceof Boolean ) {
+ return !((Boolean)value).booleanValue();
+ }
+ if ( value instanceof Integer ) {
+ return ((Integer)value).intValue() == 0;
+ }
+ if ( value instanceof String ) {
+ return isFalseExplicitly( (String)value );
+ }
+ return false;
+ }
+
+ public static final boolean isFalseExplicitly(Object value) {
+ return isFalseExplicitly(value, true);
+ }
+
+ /**
+ * Tests the Object 'value':
+ * if its null, return default.
+ * if its a Boolean, return booleanValue()
+ * if its an Integer, return 'false' if its '0' else 'true'
+ * if its a String, return 'false' if its 'false', 'no', or '0' - else 'true'
+ * All other types return 'true'
+ */
+ public static final boolean isFalse(Object value, boolean defaultVal) {
+ return isFalseExplicitly(value, defaultVal);
+ }
+
+ public static final boolean isFalse(Object value) {
+ return isFalse(value, true);
+ }
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java?rev=426488&r1=426487&r2=426488&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 Fri Jul 28 05:24:22 2006
@@ -21,6 +21,7 @@
import org.apache.axiom.om.OMOutputFormat;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
+import org.apache.axis2.util.JavaUtils;
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.ConfigurationContext;
@@ -283,7 +284,7 @@
sender = new RESTSender();
}
if (msgContext.getProperty(HTTPConstants.CHUNKED) != null) {
- chunked = Constants.VALUE_TRUE.equals(msgContext.getProperty(
+ chunked = JavaUtils.isTrueExplicitly(msgContext.getProperty(
HTTPConstants.CHUNKED));
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java?rev=426488&r1=426487&r2=426488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java Fri Jul 28 05:24:22 2006
@@ -451,6 +451,9 @@
public static final String HTTP_PROTOCOL_VERSION = "__HTTP_PROTOCOL_VERSION__";
//to set and get the property from service context
public static final String COOKIE_STRING = "Cookie";
+ public static final String HTTP_METHOD_GET = "GET";
+ public static final String HTTP_METHOD_POST = "POST";
+ public static final String CONTENT_TYPE = "ContentType";
/**
* Method getBytes.
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java?rev=426488&r1=426487&r2=426488&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 Fri Jul 28 05:24:22 2006
@@ -41,6 +41,7 @@
import org.apache.axis2.engine.AxisEngine;
import org.apache.axis2.transport.TransportUtils;
import org.apache.axis2.util.Utils;
+import org.apache.axis2.util.JavaUtils;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.stream.XMLStreamException;
@@ -103,12 +104,12 @@
boolean enableMTOM = false;
if (msgContext.getParameter(Constants.Configuration.ENABLE_MTOM) != null) {
- enableMTOM = Constants.VALUE_TRUE.equals(
+ enableMTOM = JavaUtils.isTrueExplicitly(
msgContext.getParameter(Constants.Configuration.ENABLE_MTOM).getValue());
}
if (msgContext.getProperty(Constants.Configuration.ENABLE_MTOM) != null) {
- enableMTOM = Constants.VALUE_TRUE.equals(
+ enableMTOM = JavaUtils.isTrueExplicitly(
msgContext.getProperty(Constants.Configuration.ENABLE_MTOM));
}
return enableMTOM;
@@ -317,9 +318,9 @@
Parameter parameter = msgContext.getParameter(Constants.Configuration.ENABLE_REST);
if (parameter != null) {
- enableREST = Constants.VALUE_TRUE.equals(parameter.getValue());
+ enableREST = JavaUtils.isTrueExplicitly(parameter.getValue());
} else if (msgContext.getProperty(Constants.Configuration.ENABLE_REST) != null) {
- enableREST = Constants.VALUE_TRUE.equals(
+ enableREST = JavaUtils.isTrueExplicitly(
msgContext.getProperty(Constants.Configuration.ENABLE_REST));
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/util/RESTUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/util/RESTUtil.java?rev=426488&r1=426487&r2=426488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/util/RESTUtil.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/util/RESTUtil.java Fri Jul 28 05:24:22 2006
@@ -23,7 +23,6 @@
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.HTTPConstants;
import org.apache.axis2.Constants;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
@@ -66,11 +65,11 @@
if ("".equals(contentType) || contentType == null) {
throw new AxisFault("ContentType should be given to proceed," +
" according to WSDL 2.0 HTTP binding rules");
- } else if (contentType.indexOf(HTTPConstants.MEDIA_TYPE_TEXT_XML) > -1 ||
- contentType.indexOf(HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED) > -1) {
+ } else if (contentType.indexOf(org.apache.axis2.transport.http.HTTPConstants.MEDIA_TYPE_TEXT_XML) > -1 ||
+ contentType.indexOf(org.apache.axis2.transport.http.HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED) > -1) {
soapEnvelope = handleNonURLEncodedContentTypes(msgContext, request,
OMAbstractFactory.getSOAP11Factory());
- } else if (contentType.indexOf(HTTPConstants.MEDIA_TYPE_X_WWW_FORM) > -1) {
+ } else if (contentType.indexOf(org.apache.axis2.transport.http.HTTPConstants.MEDIA_TYPE_X_WWW_FORM) > -1) {
// 2. Else, Dispatch and find out the operation and the service.
// Dispatching can only be done using the RequestURI, as others can not be run in the REST case
dispatchAndVerify(msgContext);
@@ -87,15 +86,15 @@
xmlSchemaElement,
OMAbstractFactory.getSOAP11Factory());
} else {
- throw new AxisFault("Content type should be one of /n " + HTTPConstants.MEDIA_TYPE_TEXT_XML +
- "/n " + HTTPConstants.MEDIA_TYPE_X_WWW_FORM +
- "/n " + HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED);
+ throw new AxisFault("Content type should be one of /n " + org.apache.axis2.transport.http.HTTPConstants.MEDIA_TYPE_TEXT_XML +
+ "/n " + org.apache.axis2.transport.http.HTTPConstants.MEDIA_TYPE_X_WWW_FORM +
+ "/n " + org.apache.axis2.transport.http.HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED);
}
msgContext.setEnvelope(soapEnvelope);
- msgContext.setProperty(HTTPConstants.HTTP_METHOD, HTTPConstants.HTTP_METHOD_POST);
- msgContext.setProperty(HTTPConstants.CONTENT_TYPE, contentType);
+ msgContext.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_METHOD, org.apache.axis2.transport.http.HTTPConstants.HTTP_METHOD_POST);
+ msgContext.setProperty(org.apache.axis2.transport.http.HTTPConstants.CONTENT_TYPE, contentType);
msgContext.setDoingREST(true);
msgContext.setProperty(MessageContext.TRANSPORT_OUT, response.getOutputStream());
@@ -133,7 +132,7 @@
xmlSchemaElement,
OMAbstractFactory.getSOAP11Factory());
msgContext.setEnvelope(soapEnvelope);
- msgContext.setProperty(HTTPConstants.HTTP_METHOD, HTTPConstants.HTTP_METHOD_GET);
+ msgContext.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_METHOD, org.apache.axis2.transport.http.HTTPConstants.HTTP_METHOD_GET);
msgContext.setDoingREST(true);
msgContext.setProperty(MessageContext.TRANSPORT_OUT, response.getOutputStream());
@@ -176,7 +175,7 @@
// irrespective of the schema, if the media type is text/xml, all the information
// should be in the body.
// I'm assuming here that the user is sending this data according to the schema.
- if (checkContentType(HTTPConstants.MEDIA_TYPE_TEXT_XML, contentType)) {
+ if (checkContentType(org.apache.axis2.transport.http.HTTPConstants.MEDIA_TYPE_TEXT_XML, contentType)) {
// If charset is not specified
XMLStreamReader xmlreader;
@@ -203,7 +202,7 @@
body.addChild(documentElement);
// if the media type is multipart/related, get help from Axis2 :)
- } else if (checkContentType(HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED, contentType)) {
+ } else if (checkContentType(org.apache.axis2.transport.http.HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED, contentType)) {
body.addChild(TransportUtils.selectBuilderForMIME(msgCtxt,
inputStream,
contentType).getDocumentElement());
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/SchemaUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/SchemaUtil.java?rev=426488&r1=426487&r2=426488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/SchemaUtil.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/SchemaUtil.java Fri Jul 28 05:24:22 2006
@@ -20,7 +20,6 @@
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.HTTPConstants;
import org.apache.axis2.context.MessageContext;
import org.apache.ws.commons.schema.XmlSchemaComplexType;
import org.apache.ws.commons.schema.XmlSchemaElement;
@@ -86,8 +85,8 @@
}
OMElement bodyFirstChild = soapFactory.createOMElement(bodyFirstChildQName, body);
- if (HTTPConstants.HTTP_METHOD_POST.equals(request.getMethod())
- || (HTTPConstants.HTTP_METHOD_GET.equals(request.getMethod()))) {
+ if (org.apache.axis2.transport.http.HTTPConstants.HTTP_METHOD_POST.equals(request.getMethod())
+ || (org.apache.axis2.transport.http.HTTPConstants.HTTP_METHOD_GET.equals(request.getMethod()))) {
XmlSchemaType schemaType = xmlSchemaElement.getSchemaType();
if (schemaType instanceof XmlSchemaComplexType) {
XmlSchemaComplexType complexType = ((XmlSchemaComplexType) schemaType);
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org