ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1728025 - in /webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom: om/impl/common/factory/AbstractOMMetaFactory.java soap/impl/common/builder/StAXSOAPModelBuilder.java
Date Tue, 02 Feb 2016 00:00:39 GMT
Author: veithen
Date: Tue Feb  2 00:00:39 2016
New Revision: 1728025

URL: http://svn.apache.org/viewvc?rev=1728025&view=rev
Log:
Some code simplifications.

Modified:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/StAXSOAPModelBuilder.java

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.java?rev=1728025&r1=1728024&r2=1728025&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.java
Tue Feb  2 00:00:39 2016
@@ -39,9 +39,11 @@ import org.apache.axiom.om.impl.builder.
 import org.apache.axiom.om.impl.common.builder.StAXOMBuilder;
 import org.apache.axiom.om.util.StAXParserConfiguration;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPMessage;
 import org.apache.axiom.soap.SOAPModelBuilder;
+import org.apache.axiom.soap.SOAPProcessingException;
 import org.apache.axiom.soap.impl.builder.OMMetaFactoryEx;
 import org.apache.axiom.soap.impl.common.builder.StAXSOAPModelBuilder;
 import org.apache.axiom.soap.impl.intf.AxiomSOAPMessage;
@@ -245,13 +247,17 @@ public abstract class AbstractOMMetaFact
     public SOAPModelBuilder createSOAPModelBuilder(StAXParserConfiguration configuration,
             SOAPFactory soapFactory, InputSource rootPart, MimePartProvider mimePartProvider)
{
         SourceInfo sourceInfo = createXMLStreamReader(configuration, rootPart, false);
-        return new StAXSOAPModelBuilder(
+        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(
+                soapFactory.getMetaFactory(),
                 new XOPDecodingStreamReader(sourceInfo.getReader(), mimePartProvider),
                 true,
-                soapFactory,
-                soapFactory.getSoapVersionURI(),
                 mimePartProvider instanceof Detachable ? (Detachable)mimePartProvider : null,
                 sourceInfo.getCloseable());
+        if (builder.getSOAPMessage().getOMFactory() != soapFactory) {
+            throw new SOAPProcessingException("Invalid SOAP namespace URI. " +
+                    "Expected " + soapFactory.getSoapVersionURI(), SOAP12Constants.FAULT_CODE_SENDER);
+        }
+        return builder;
     }
     
     public abstract AxiomSOAPMessage createSOAPMessage();

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/StAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/StAXSOAPModelBuilder.java?rev=1728025&r1=1728024&r2=1728025&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/StAXSOAPModelBuilder.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/StAXSOAPModelBuilder.java
Tue Feb  2 00:00:39 2016
@@ -26,7 +26,6 @@ import org.apache.axiom.om.OMDocument;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMMetaFactory;
-import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.impl.builder.CustomBuilder;
 import org.apache.axiom.om.impl.builder.Detachable;
@@ -81,36 +80,6 @@ public class StAXSOAPModelBuilder extend
         this.metaFactory = metaFactory;
     }
     
-    public StAXSOAPModelBuilder(XMLStreamReader parser, boolean autoClose, SOAPFactory factory,
String soapVersion,
-            Detachable detachable, Closeable closeable) {
-        super(factory, parser, autoClose, detachable, closeable);
-        soapFactory = (SOAPFactoryEx)factory;
-        identifySOAPVersion(soapVersion);
-    }
-    
-    /** @param soapVersionURIFromTransport  */
-    protected void identifySOAPVersion(String soapVersionURIFromTransport) {
-
-        SOAPEnvelope soapEnvelope = getSOAPEnvelope();
-        if (soapEnvelope == null) {
-            throw new SOAPProcessingException("SOAP Message does not contain an Envelope",
-                                              SOAPConstants.FAULT_CODE_VERSION_MISMATCH);
-        }
-
-        OMNamespace envelopeNamespace = soapEnvelope.getNamespace();
-
-        if (soapVersionURIFromTransport != null) {
-            String namespaceName = envelopeNamespace.getNamespaceURI();
-            if (!(soapVersionURIFromTransport.equals(namespaceName))) {
-                throw new SOAPProcessingException(
-                        "Transport level information does not match with SOAP" +
-                                " Message namespace URI", envelopeNamespace.getPrefix() +
":" +
-                        SOAPConstants.FAULT_CODE_VERSION_MISMATCH);
-            }
-        }
-
-    }
-
     public SOAPEnvelope getSOAPEnvelope() throws OMException {
         return (SOAPEnvelope)getDocumentElement();
     }
@@ -158,21 +127,16 @@ public class StAXSOAPModelBuilder extend
 
             // determine SOAP version and from that determine a proper factory here.
             String namespaceURI = this.parser.getNamespaceURI();
-            if (soapFactory == null) {
-                if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
-                    soapFactory = (SOAPFactoryEx)metaFactory.getSOAP12Factory();
-                    log.debug("Starting to process SOAP 1.2 message");
-                } else if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI))
{
-                    soapFactory = (SOAPFactoryEx)metaFactory.getSOAP11Factory();
-                    log.debug("Starting to process SOAP 1.1 message");
-                } else {
-                    throw new SOAPProcessingException(
-                            "Only SOAP 1.1 or SOAP 1.2 messages are supported in the" +
-                                    " system", SOAPConstants.FAULT_CODE_VERSION_MISMATCH);
-                }
-            } else if (!soapFactory.getSoapVersionURI().equals(namespaceURI)) {
-                throw new SOAPProcessingException("Invalid SOAP namespace URI. " +
-                        "Expected " + soapFactory.getSoapVersionURI(), SOAP12Constants.FAULT_CODE_SENDER);
+            if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
+                soapFactory = (SOAPFactoryEx)metaFactory.getSOAP12Factory();
+                log.debug("Starting to process SOAP 1.2 message");
+            } else if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI))
{
+                soapFactory = (SOAPFactoryEx)metaFactory.getSOAP11Factory();
+                log.debug("Starting to process SOAP 1.1 message");
+            } else {
+                throw new SOAPProcessingException(
+                        "Only SOAP 1.1 or SOAP 1.2 messages are supported in the" +
+                                " system", SOAPConstants.FAULT_CODE_VERSION_MISMATCH);
             }
 
             elementType = soapFactory.getSOAPHelper().getEnvelopeClass();



Mime
View raw message