You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by th...@apache.org on 2006/10/15 20:46:38 UTC
svn commit: r464247 - in
/webservices/axis2/branches/java/1_1/modules/kernel/src/org/apache/axis2/transport:
TransportUtils.java http/HTTPTransportUtils.java
Author: thilina
Date: Sun Oct 15 11:46:37 2006
New Revision: 464247
URL: http://svn.apache.org/viewvc?view=rev&rev=464247
Log:
Refactored transportUtils...
Made "Multipart/Related" check case insensitive in httpTransportUtils
Modified:
webservices/axis2/branches/java/1_1/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
webservices/axis2/branches/java/1_1/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
Modified: webservices/axis2/branches/java/1_1/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java?view=diff&rev=464247&r1=464246&r2=464247
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java (original)
+++ webservices/axis2/branches/java/1_1/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java Sun Oct 15 11:46:37 2006
@@ -167,8 +167,8 @@
}
public static StAXBuilder selectBuilderForMIME(MessageContext msgContext,
- InputStream inStream, String contentTypeString,boolean isSOAP) throws OMException,
- XMLStreamException, FactoryConfigurationError {
+ InputStream inStream, String contentTypeString, boolean isSOAP)
+ throws OMException, XMLStreamException, FactoryConfigurationError {
StAXBuilder builder = null;
Object cacheAttachmentProperty = msgContext
@@ -189,7 +189,7 @@
: null;
}
fileCacheForAttachments = (Constants.VALUE_TRUE
- .equals(cacheAttachmentString));
+ .equals(cacheAttachmentString));
String attachmentRepoDir = null;
String attachmentSizeThreshold = null;
@@ -221,81 +221,90 @@
}
}
- Attachments attachments = new Attachments(inStream, contentTypeString,
- fileCacheForAttachments, attachmentRepoDir,
- attachmentSizeThreshold);
- String charSetEncoding =
- getCharSetEncoding(attachments.getSOAPPartContentType());
- XMLStreamReader streamReader;
-
- if ((charSetEncoding == null) || "null".equalsIgnoreCase(charSetEncoding)) {
- charSetEncoding = MessageContext.UTF_8;
- }
-
- try {
- streamReader = StAXUtils.createXMLStreamReader(
- getReader(attachments.getSOAPPartInputStream(), charSetEncoding));
- } catch (IOException e) {
- throw new XMLStreamException(e);
- }
-
- msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEncoding);
-
- /*
- * Put a reference to Attachments Map in to the message context
- * For backword compatibility with Axis2 1.0
- */
- msgContext.setProperty(MTOMConstants.ATTACHMENTS, attachments);
-
- /*
- * Setting the Attachments map to new SwA API
- */
- msgContext.setAttachmentMap(attachments);
-
- String soapEnvelopeNamespaceURI=null;
- if (contentTypeString.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) > -1) {
- soapEnvelopeNamespaceURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
- }
- else if (contentTypeString.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) > -1) {
- soapEnvelopeNamespaceURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
- }
-
- if (isSOAP)
- {
- if (attachments.getAttachmentSpecType().equals(MTOMConstants.MTOM_TYPE)& null!=soapEnvelopeNamespaceURI) {
-
- /*
- * Creates the MTOM specific MTOMStAXSOAPModelBuilder
- */
- builder = new MTOMStAXSOAPModelBuilder(streamReader, attachments, soapEnvelopeNamespaceURI);
-
- } else if (attachments.getAttachmentSpecType().equals(MTOMConstants.SWA_TYPE)& null!=soapEnvelopeNamespaceURI) {
- builder = new StAXSOAPModelBuilder(streamReader,
- soapEnvelopeNamespaceURI);
- }
- }
- // To handle REST XOP case
- else
- {
- if (attachments.getAttachmentSpecType().equals(MTOMConstants.MTOM_TYPE)) {
- XOPAwareStAXOMBuilder stAXOMBuilder = new XOPAwareStAXOMBuilder(streamReader,attachments);
- builder= stAXOMBuilder;
-
- } else if (attachments.getAttachmentSpecType().equals(MTOMConstants.SWA_TYPE)) {
- builder = new StAXOMBuilder(streamReader);
- }
- }
+ Attachments attachments = new Attachments(inStream, contentTypeString,
+ fileCacheForAttachments, attachmentRepoDir,
+ attachmentSizeThreshold);
+ String charSetEncoding = getCharSetEncoding(attachments
+ .getSOAPPartContentType());
+ XMLStreamReader streamReader;
+
+ if ((charSetEncoding == null)
+ || "null".equalsIgnoreCase(charSetEncoding)) {
+ charSetEncoding = MessageContext.UTF_8;
+ }
+
+ try {
+ streamReader = StAXUtils.createXMLStreamReader(getReader(
+ attachments.getSOAPPartInputStream(), charSetEncoding));
+ } catch (IOException e) {
+ throw new XMLStreamException(e);
+ }
+
+ msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
+ charSetEncoding);
+
+ /*
+ * Put a reference to Attachments Map in to the message context For
+ * backword compatibility with Axis2 1.0
+ */
+ msgContext.setProperty(MTOMConstants.ATTACHMENTS, attachments);
+
+ /*
+ * Setting the Attachments map to new SwA API
+ */
+ msgContext.setAttachmentMap(attachments);
+
+ String soapEnvelopeNamespaceURI = null;
+ if (contentTypeString.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) > -1) {
+ soapEnvelopeNamespaceURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+ } else if (contentTypeString
+ .indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) > -1) {
+ soapEnvelopeNamespaceURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+ }
+
+ if (isSOAP) {
+ if (attachments.getAttachmentSpecType().equals(
+ MTOMConstants.MTOM_TYPE)
+ & null != soapEnvelopeNamespaceURI) {
+
+ /*
+ * Creates the MTOM specific MTOMStAXSOAPModelBuilder
+ */
+ builder = new MTOMStAXSOAPModelBuilder(streamReader,
+ attachments, soapEnvelopeNamespaceURI);
+
+ } else if (attachments.getAttachmentSpecType().equals(
+ MTOMConstants.SWA_TYPE)
+ & null != soapEnvelopeNamespaceURI) {
+ builder = new StAXSOAPModelBuilder(streamReader,
+ soapEnvelopeNamespaceURI);
+ }
+ }
+ // To handle REST XOP case
+ else {
+ if (attachments.getAttachmentSpecType().equals(
+ MTOMConstants.MTOM_TYPE)) {
+ XOPAwareStAXOMBuilder stAXOMBuilder = new XOPAwareStAXOMBuilder(
+ streamReader, attachments);
+ builder = stAXOMBuilder;
+
+ } else if (attachments.getAttachmentSpecType().equals(
+ MTOMConstants.SWA_TYPE)) {
+ builder = new StAXOMBuilder(streamReader);
+ }
+ }
- return builder;
- }
+ return builder;
+ }
/**
- * Use the BOM Mark to identify the encoding to be used. Fall back to default encoding specified
- *
- * @param is
- * @param charSetEncoding
- * @throws java.io.IOException
- */
+ * Use the BOM Mark to identify the encoding to be used. Fall back to
+ * default encoding specified
+ *
+ * @param is
+ * @param charSetEncoding
+ * @throws java.io.IOException
+ */
private static Reader getReader(InputStream is, String charSetEncoding) throws IOException {
PushbackInputStream is2 = new PushbackInputStream(is, BOM_SIZE);
String encoding;
Modified: webservices/axis2/branches/java/1_1/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java?view=diff&rev=464247&r1=464246&r2=464247
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java (original)
+++ webservices/axis2/branches/java/1_1/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java Sun Oct 15 11:46:37 2006
@@ -52,15 +52,11 @@
public class HTTPTransportUtils {
- public static SOAPEnvelope
- createEnvelopeFromGetRequest(String requestUrl,
- Map map,
- ConfigurationContext configCtx) throws AxisFault {
+ public static SOAPEnvelope createEnvelopeFromGetRequest(String requestUrl,
+ Map map,ConfigurationContext configCtx) throws AxisFault {
String[] values =
Utils.parseRequestURLForServiceAndOperation(requestUrl,
- configCtx.
- getServiceContextPath());
-
+ configCtx.getServiceContextPath());
if (values == null) {
return new SOAP11Factory().getDefaultEnvelope();
}
@@ -192,7 +188,7 @@
StAXBuilder builder = null;
if (contentType != null) {
- if (contentType.indexOf(HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED) > -1) {
+ if (contentType.toLowerCase().indexOf(HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED) > -1) {
// It is MIME (MTOM or SwA)
builder = TransportUtils.selectBuilderForMIME(msgContext, in, contentType,true);
envelope = (SOAPEnvelope) builder.getDocumentElement();
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org