You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2016/02/02 21:40:01 UTC
svn commit: r1728205 - in /webservices/axiom/trunk:
aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/
aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/
implementations/fom-impl/src/main/java/org/apache/...
Author: veithen
Date: Tue Feb 2 20:40:00 2016
New Revision: 1728205
URL: http://svn.apache.org/viewvc?rev=1728205&view=rev
Log:
Improve encapsulation of StAXOMBuilder.
Modified:
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/SOAP11BuilderHelper.java
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/SOAP12BuilderHelper.java
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/SOAPBuilderHelper.java
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/StAXSOAPModelBuilder.java
webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java?rev=1728205&r1=1728204&r2=1728205&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java Tue Feb 2 20:40:00 2016
@@ -147,7 +147,7 @@ public class StAXOMBuilder implements Bu
* root element is defined as 1. Note that if caching is disabled, then this depth may be
* different from the actual depth reached by the underlying parser.
*/
- protected int elementLevel = 0;
+ private int elementLevel = 0;
/**
* Stores exceptions thrown by the parser. Used to avoid accessing the parser
@@ -793,7 +793,9 @@ public class StAXOMBuilder implements Bu
* @throws OMException
*/
private OMNode createOMElement() throws OMException {
- AxiomElement node = omfactory.createAxiomElement(determineElementType(target, parser.getLocalName()), parser.getLocalName(), target, this);
+ AxiomElement node = omfactory.createAxiomElement(
+ determineElementType(target, elementLevel, parser.getNamespaceURI(), parser.getLocalName()),
+ parser.getLocalName(), target, this);
postProcessElement(node);
populateOMElement(node);
return node;
@@ -809,7 +811,8 @@ public class StAXOMBuilder implements Bu
* the local name for the element
* @return the type of element to create; must not be <code>null</code>
*/
- protected Class<? extends AxiomElement> determineElementType(OMContainer parent, String elementName) {
+ protected Class<? extends AxiomElement> determineElementType(OMContainer parent,
+ int elementLevel, String namespaceURI, String localName) {
return AxiomElement.class;
}
Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/SOAP11BuilderHelper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/SOAP11BuilderHelper.java?rev=1728205&r1=1728204&r2=1728205&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/SOAP11BuilderHelper.java (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/SOAP11BuilderHelper.java Tue Feb 2 20:40:00 2016
@@ -29,17 +29,13 @@ import org.apache.axiom.soap.impl.intf.A
import org.apache.axiom.soap.impl.intf.AxiomSOAP11FaultRole;
import org.w3c.dom.Element;
-import javax.xml.stream.XMLStreamReader;
-
public class SOAP11BuilderHelper extends SOAPBuilderHelper implements SOAP11Constants {
private boolean faultcodePresent = false;
private boolean faultstringPresent = false;
- public Class<? extends AxiomElement> handleEvent(XMLStreamReader parser,
- OMElement parent,
- int elementLevel) throws SOAPProcessingException {
+ public Class<? extends AxiomElement> handleEvent(OMElement parent, int elementLevel,
+ String namespaceURI, String localName) throws SOAPProcessingException {
Class<? extends AxiomElement> elementType = null;
- String localName = parser.getLocalName();
if (elementLevel == 4) {
Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/SOAP12BuilderHelper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/SOAP12BuilderHelper.java?rev=1728205&r1=1728204&r2=1728205&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/SOAP12BuilderHelper.java (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/SOAP12BuilderHelper.java Tue Feb 2 20:40:00 2016
@@ -33,7 +33,6 @@ import org.apache.axiom.soap.impl.intf.A
import org.apache.axiom.soap.impl.intf.AxiomSOAP12FaultText;
import org.apache.axiom.soap.impl.intf.AxiomSOAP12FaultValue;
-import javax.xml.stream.XMLStreamReader;
import java.util.Vector;
public class SOAP12BuilderHelper extends SOAPBuilderHelper {
@@ -52,14 +51,12 @@ public class SOAP12BuilderHelper extends
private boolean processingDetailElements = false;
private Vector<String> detailElementNames;
- public Class<? extends AxiomElement> handleEvent(XMLStreamReader parser,
- OMElement parent,
- int elementLevel) throws SOAPProcessingException {
+ public Class<? extends AxiomElement> handleEvent(OMElement parent, int elementLevel,
+ String namespaceURI, String localName) throws SOAPProcessingException {
Class<? extends AxiomElement> elementType = null;
if (elementLevel == 4) {
- if (parser.getLocalName().equals(
- SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME)) {
+ if (localName.equals(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME)) {
if (codePresent) {
throw new OMBuilderException(
"Multiple Code element encountered");
@@ -68,8 +65,7 @@ public class SOAP12BuilderHelper extends
codePresent = true;
codeprocessing = true;
}
- } else if (parser.getLocalName().equals(
- SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME)) {
+ } else if (localName.equals(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME)) {
if (!codeprocessing && !subCodeProcessing) {
if (codePresent) {
if (reasonPresent) {
@@ -82,8 +78,7 @@ public class SOAP12BuilderHelper extends
}
} else {
throw new OMBuilderException(
- "Wrong element order encountred at " +
- parser.getLocalName());
+ "Wrong element order encountred at " + localName);
}
} else {
if (codeprocessing) {
@@ -95,8 +90,7 @@ public class SOAP12BuilderHelper extends
}
}
- } else if (parser.getLocalName().equals(
- SOAP12Constants.SOAP_FAULT_NODE_LOCAL_NAME)) {
+ } else if (localName.equals(SOAP12Constants.SOAP_FAULT_NODE_LOCAL_NAME)) {
if (!reasonProcessing) {
if (reasonPresent && !rolePresent && !detailPresent) {
if (nodePresent) {
@@ -108,15 +102,13 @@ public class SOAP12BuilderHelper extends
}
} else {
throw new OMBuilderException(
- "wrong element order encountered at " +
- parser.getLocalName());
+ "wrong element order encountered at " + localName);
}
} else {
throw new OMBuilderException(
"Reason element Should have a text");
}
- } else if (parser.getLocalName().equals(
- SOAP12Constants.SOAP_FAULT_ROLE_LOCAL_NAME)) {
+ } else if (localName.equals(SOAP12Constants.SOAP_FAULT_ROLE_LOCAL_NAME)) {
if (!reasonProcessing) {
if (reasonPresent && !detailPresent) {
if (rolePresent) {
@@ -128,15 +120,13 @@ public class SOAP12BuilderHelper extends
}
} else {
throw new OMBuilderException(
- "Wrong element order encountered at " +
- parser.getLocalName());
+ "Wrong element order encountered at " + localName);
}
} else {
throw new OMBuilderException(
"Reason element should have a text");
}
- } else if (parser.getLocalName().equals(
- SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME)) {
+ } else if (localName.equals(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME)) {
if (!reasonProcessing) {
if (reasonPresent) {
if (detailPresent) {
@@ -148,8 +138,7 @@ public class SOAP12BuilderHelper extends
}
} else {
throw new OMBuilderException(
- "wrong element order encountered at " +
- parser.getLocalName());
+ "wrong element order encountered at " + localName);
}
} else {
throw new OMBuilderException(
@@ -157,15 +146,13 @@ public class SOAP12BuilderHelper extends
}
} else {
throw new OMBuilderException(
- parser.getLocalName() +
- " unsupported element in SOAPFault element");
+ localName + " unsupported element in SOAPFault element");
}
} else if (elementLevel == 5) {
if (parent.getLocalName().equals(
SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME)) {
- if (parser.getLocalName().equals(
- SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME)) {
+ if (localName.equals(SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME)) {
if (!valuePresent) {
elementType = AxiomSOAP12FaultValue.class;
valuePresent = true;
@@ -175,8 +162,7 @@ public class SOAP12BuilderHelper extends
"Multiple value Encountered in code element");
}
- } else if (parser.getLocalName().equals(
- SOAP12Constants.SOAP_FAULT_SUB_CODE_LOCAL_NAME)) {
+ } else if (localName.equals(SOAP12Constants.SOAP_FAULT_SUB_CODE_LOCAL_NAME)) {
if (!subcodePresent) {
if (valuePresent) {
elementType = AxiomSOAP12FaultSubCode.class;
@@ -193,27 +179,24 @@ public class SOAP12BuilderHelper extends
}
} else {
throw new OMBuilderException(
- parser.getLocalName() +
- " is not supported inside the code element");
+ localName + " is not supported inside the code element");
}
} else if (parent.getLocalName().equals(
SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME)) {
- if (parser.getLocalName().equals(
- SOAP12Constants.SOAP_FAULT_TEXT_LOCAL_NAME)) {
+ if (localName.equals(SOAP12Constants.SOAP_FAULT_TEXT_LOCAL_NAME)) {
elementType = AxiomSOAP12FaultText.class;
reasonProcessing = false;
} else {
throw new OMBuilderException(
- parser.getLocalName() +
- " is not supported inside the reason");
+ localName + " is not supported inside the reason");
}
} else if (parent.getLocalName().equals(
SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME)) {
elementType = AxiomElement.class;
processingDetailElements = true;
detailElementNames = new Vector<String>();
- detailElementNames.add(parser.getLocalName());
+ detailElementNames.add(localName);
} else {
throw new OMBuilderException(
@@ -225,8 +208,7 @@ public class SOAP12BuilderHelper extends
} else if (elementLevel > 5) {
if (parent.getLocalName().equals(
SOAP12Constants.SOAP_FAULT_SUB_CODE_LOCAL_NAME)) {
- if (parser.getLocalName().equals(
- SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME)) {
+ if (localName.equals(SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME)) {
if (subcodeValuePresent) {
throw new OMBuilderException(
"multiple subCode value encountered");
@@ -236,8 +218,7 @@ public class SOAP12BuilderHelper extends
subSubcodePresent = false;
subCodeProcessing = false;
}
- } else if (parser.getLocalName().equals(
- SOAP12Constants.SOAP_FAULT_SUB_CODE_LOCAL_NAME)) {
+ } else if (localName.equals(SOAP12Constants.SOAP_FAULT_SUB_CODE_LOCAL_NAME)) {
if (subcodeValuePresent) {
if (!subSubcodePresent) {
elementType = AxiomSOAP12FaultSubCode.class;
@@ -254,8 +235,7 @@ public class SOAP12BuilderHelper extends
}
} else {
throw new OMBuilderException(
- parser.getLocalName() +
- " is not supported inside the subCode element");
+ localName + " is not supported inside the subCode element");
}
} else if (processingDetailElements) {
int detailElementLevel = 0;
@@ -270,7 +250,7 @@ public class SOAP12BuilderHelper extends
if (localNameExist) {
detailElementNames.setSize(detailElementLevel);
elementType = AxiomElement.class;
- detailElementNames.add(parser.getLocalName());
+ detailElementNames.add(localName);
}
} else {
Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/SOAPBuilderHelper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/SOAPBuilderHelper.java?rev=1728205&r1=1728204&r2=1728205&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/SOAPBuilderHelper.java (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/SOAPBuilderHelper.java Tue Feb 2 20:40:00 2016
@@ -23,10 +23,7 @@ import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.impl.intf.AxiomElement;
import org.apache.axiom.soap.SOAPProcessingException;
-import javax.xml.stream.XMLStreamReader;
-
public abstract class SOAPBuilderHelper {
- public abstract Class<? extends AxiomElement> handleEvent(XMLStreamReader parser,
- OMElement element,
- int elementLevel) throws SOAPProcessingException;
+ public abstract Class<? extends AxiomElement> handleEvent(OMElement element, int elementLevel,
+ String namespaceURI, String localName) throws SOAPProcessingException;
}
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=1728205&r1=1728204&r2=1728205&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 20:40:00 2016
@@ -83,20 +83,20 @@ public class StAXSOAPModelBuilder extend
}
@Override
- protected Class<? extends AxiomElement> determineElementType(OMContainer parent, String elementName) {
+ protected Class<? extends AxiomElement> determineElementType(OMContainer parent,
+ int elementLevel, String namespaceURI, String localName) {
Class<? extends AxiomElement> elementType;
if (elementLevel == 1) {
// Now I've found a SOAP Envelope, now create SOAPEnvelope here.
- if (!elementName.equals(SOAPConstants.SOAPENVELOPE_LOCAL_NAME)) {
+ if (!localName.equals(SOAPConstants.SOAPENVELOPE_LOCAL_NAME)) {
throw new SOAPProcessingException("First Element must contain the local name, "
- + SOAPConstants.SOAPENVELOPE_LOCAL_NAME + " , but found " + elementName,
+ + SOAPConstants.SOAPENVELOPE_LOCAL_NAME + " , but found " + localName,
SOAPConstants.FAULT_CODE_SENDER);
}
// determine SOAP version and from that determine a proper factory here.
- String namespaceURI = this.parser.getNamespaceURI();
if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
soapFactory = (SOAPFactoryEx)metaFactory.getSOAP12Factory();
log.debug("Starting to process SOAP 1.2 message");
@@ -111,11 +111,9 @@ public class StAXSOAPModelBuilder extend
elementType = soapFactory.getSOAPHelper().getEnvelopeClass();
} else if (elementLevel == 2) {
- String elementNS = parser.getNamespaceURI();
-
- if (soapFactory.getSoapVersionURI().equals(elementNS)) {
+ if (soapFactory.getSoapVersionURI().equals(namespaceURI)) {
// this is either a header or a body
- if (elementName.equals(SOAPConstants.HEADER_LOCAL_NAME)) {
+ if (localName.equals(SOAPConstants.HEADER_LOCAL_NAME)) {
if (headerPresent) {
throw new SOAPProcessingException("Multiple headers encountered!",
getSenderFaultCode());
@@ -126,7 +124,7 @@ public class StAXSOAPModelBuilder extend
}
headerPresent = true;
elementType = soapFactory.getSOAPHelper().getHeaderClass();
- } else if (elementName.equals(SOAPConstants.BODY_LOCAL_NAME)) {
+ } else if (localName.equals(SOAPConstants.BODY_LOCAL_NAME)) {
if (bodyPresent) {
throw new SOAPProcessingException("Multiple body elements encountered",
getSenderFaultCode());
@@ -134,14 +132,14 @@ public class StAXSOAPModelBuilder extend
bodyPresent = true;
elementType = soapFactory.getSOAPHelper().getBodyClass();
} else {
- throw new SOAPProcessingException(elementName + " is not supported here.",
+ throw new SOAPProcessingException(localName + " is not supported here.",
getSenderFaultCode());
}
} else if (soapFactory.getSOAPVersion() == SOAP11Version.getSingleton() && bodyPresent) {
elementType = AxiomElement.class;
} else {
throw new SOAPProcessingException("Disallowed element found inside Envelope : {"
- + elementNS + "}" + elementName);
+ + namespaceURI + "}" + localName);
}
} else if ((elementLevel == 3)
&&
@@ -156,8 +154,8 @@ public class StAXSOAPModelBuilder extend
}
} else if ((elementLevel == 3) &&
((OMElement)parent).getLocalName().equals(SOAPConstants.BODY_LOCAL_NAME) &&
- elementName.equals(SOAPConstants.BODY_FAULT_LOCAL_NAME) &&
- soapFactory.getSoapVersionURI().equals(parser.getNamespaceURI())) {
+ localName.equals(SOAPConstants.BODY_FAULT_LOCAL_NAME) &&
+ soapFactory.getSoapVersionURI().equals(namespaceURI)) {
// this is a SOAP fault
elementType = soapFactory.getSOAPHelper().getFaultClass();
processingFault = true;
@@ -168,7 +166,7 @@ public class StAXSOAPModelBuilder extend
}
} else if (elementLevel > 3 && processingFault) {
- elementType = builderHelper.handleEvent(parser, (OMElement)parent, elementLevel);
+ elementType = builderHelper.handleEvent((OMElement)parent, elementLevel, namespaceURI, localName);
} else {
// this is neither of above. Just create an element
elementType = AxiomElement.class;
Modified: webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java?rev=1728205&r1=1728204&r2=1728205&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java (original)
+++ webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java Tue Feb 2 20:40:00 2016
@@ -93,7 +93,7 @@ public class FOMBuilder extends StAXOMBu
@Override
protected Class<? extends AxiomElement> determineElementType(OMContainer parent,
- String elementName) {
+ int elementLevel, String namespaceURI, String localName) {
return fomfactory.determineElementType(parser.getName(), parent);
}