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 2007/07/05 05:09:21 UTC
svn commit: r553365 - in
/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2:
description/AxisBindingMessage.java description/AxisEndpoint.java
transport/http/util/URLTemplatingUtil.java util/PolicyUtil.java
util/WSDL20Util.java
Author: dims
Date: Wed Jul 4 20:09:19 2007
New Revision: 553365
URL: http://svn.apache.org/viewvc?view=rev&rev=553365
Log:
Contingency planning. reduce woden references to just 3 classes. No change in logic of any kind. just move code and cleanup imports
Added:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDL20Util.java
Modified:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/URLTemplatingUtil.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java?view=diff&rev=553365&r1=553364&r2=553365
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java Wed Jul 4 20:09:19 2007
@@ -18,22 +18,20 @@
*/
package org.apache.axis2.description;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.util.WSDLSerializationUtil;
import org.apache.axis2.util.PolicyUtil;
+import org.apache.axis2.util.WSDL20Util;
+import org.apache.axis2.util.WSDLSerializationUtil;
import org.apache.axis2.wsdl.WSDLConstants;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.woden.wsdl20.extensions.soap.SOAPFaultCode;
-import org.apache.woden.wsdl20.extensions.soap.SOAPFaultSubcodes;
import org.apache.neethi.Policy;
-import javax.xml.namespace.QName;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
-import java.util.ArrayList;
public class AxisBindingMessage extends AxisDescription {
@@ -148,22 +146,8 @@
WSDL2Constants.ATTRIBUTE_REF, null, tns.getPrefix() + ":"
+ this.name));
- // Fault specific properties
- SOAPFaultCode faultCode = (SOAPFaultCode) this.options
- .get(WSDL2Constants.ATTR_WSOAP_CODE);
- if (faultCode != null && faultCode.getQName() != null) {
- bindingMessageElement.addAttribute(omFactory.createOMAttribute(
- WSDL2Constants.ATTRIBUTE_CODE, wsoap, faultCode.getQName().getLocalPart()));
- }
- SOAPFaultSubcodes soapFaultSubcodes = (SOAPFaultSubcodes) this.options
- .get(WSDL2Constants.ATTR_WSOAP_SUBCODES);
- QName faultCodes [];
- if (soapFaultSubcodes != null && (faultCodes = soapFaultSubcodes.getQNames()) != null) {
- for (int i=0 ; i < faultCodes.length; i++) {
- bindingMessageElement.addAttribute(omFactory.createOMAttribute(
- WSDL2Constants.ATTRIBUTE_SUBCODES, wsoap, faultCodes[0].getLocalPart()));
- }
- }
+ WSDL20Util.extractWSDL20SoapFaultInfo(options, bindingMessageElement, omFactory, wsoap);
+
Integer code = (Integer) this.options.get(WSDL2Constants.ATTR_WHTTP_CODE);
if (code != null) {
bindingMessageElement.addAttribute(omFactory.createOMAttribute(
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java?view=diff&rev=553365&r1=553364&r2=553365
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java Wed Jul 4 20:09:19 2007
@@ -18,13 +18,12 @@
*/
package org.apache.axis2.description;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.util.WSDLSerializationUtil;
+import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.woden.wsdl20.extensions.http.HTTPAuthenticationScheme;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.util.WSDLSerializationUtil;
import java.util.HashMap;
import java.util.Map;
@@ -127,7 +126,7 @@
endpointElement.addAttribute(omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_NAME, null, name));
endpointElement.addAttribute(omFactory.createOMAttribute(WSDL2Constants.BINDING_LOCAL_NAME, null, tns.getPrefix() + ":" + getBinding().getName().getLocalPart()));
endpointElement.addAttribute(omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_ADDRESS, null, epr));
- HTTPAuthenticationScheme authenticationScheme = (HTTPAuthenticationScheme) this.options.get(WSDL2Constants.ATTR_WHTTP_AUTHENTICATION_TYPE);
+ Object authenticationScheme = this.options.get(WSDL2Constants.ATTR_WHTTP_AUTHENTICATION_TYPE);
if (authenticationScheme != null) {
endpointElement.addAttribute(omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_AUTHENTICATION_TYPE, whttp, authenticationScheme.toString()));
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/URLTemplatingUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/URLTemplatingUtil.java?view=diff&rev=553365&r1=553364&r2=553365
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/URLTemplatingUtil.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/URLTemplatingUtil.java Wed Jul 4 20:09:19 2007
@@ -20,20 +20,16 @@
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.WSDL20DefaultValueHolder;
import org.apache.axis2.description.WSDL2Constants;
-import org.apache.axis2.util.JavaUtils;
-import org.apache.woden.wsdl20.extensions.http.HTTPLocation;
-import org.apache.woden.wsdl20.extensions.http.HTTPLocationTemplate;
+import org.apache.axis2.util.WSDL20Util;
-import javax.xml.namespace.QName;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
-import java.net.URL;
import java.net.URI;
import java.net.URISyntaxException;
+import java.net.URL;
import java.util.Iterator;
@@ -45,63 +41,6 @@
public class URLTemplatingUtil {
/**
- * This method is used to resolve httplocation property. It changes the URL as stipulated by
- * the httplocation property.
- *
- * @param messageContext - The MessageContext of the request
- * @param rawURLString - The raw URL containing httplocation templates
- * @param detach - Boolean value specifying whether the element should be detached from the
- * envelop. When serializing data as application/x-form-urlencoded what goes in the body is the
- * remainder and therefore we should detach the element from the envelop.
- * @return - String with templated values replaced
- * @throws AxisFault - Thrown in case an exception occurs
- */
- private static String applyURITemplating(MessageContext messageContext, String rawURLString,
- boolean detach) throws AxisFault {
-
- OMElement firstElement;
- if (detach) {
- firstElement = messageContext.getEnvelope().getBody().getFirstElement();
- } else {
- firstElement =
- messageContext.getEnvelope().getBody().getFirstElement().cloneOMElement();
- }
- String queryParameterSeparator = (String) messageContext.getProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR);
- if (queryParameterSeparator == null) {
- queryParameterSeparator = WSDL20DefaultValueHolder.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR_DEFAULT;
- }
- HTTPLocation httpLocation = new HTTPLocation(rawURLString);
- HTTPLocationTemplate[] templates = httpLocation.getTemplates();
-
- for (int i = 0; i < templates.length; i++) {
- HTTPLocationTemplate template = templates[i];
- String localName = template.getName();
- String elementValue = getOMElementValue(localName, firstElement);
- if (template.isEncoded()) {
- try {
-
- if (template.isQuery()) {
- template.setValue(URIEncoderDecoder.quoteIllegal(
- elementValue,
- WSDL2Constants.LEGAL_CHARACTERS_IN_QUERY.replaceAll(queryParameterSeparator, "")));
- } else {
- template.setValue(URIEncoderDecoder.quoteIllegal(
- elementValue,
- WSDL2Constants.LEGAL_CHARACTERS_IN_PATH));
- }
- } catch (UnsupportedEncodingException e) {
- throw new AxisFault("Unable to encode Query String");
- }
-
- } else {
- template.setValue(elementValue);
- }
- }
-
- return httpLocation.getFormattedLocation();
- }
-
- /**
* Appends Query parameters to the URL
*
* @param messageContext - The MessageContext of the request
@@ -161,39 +100,6 @@
}
/**
- * This method is used to retrive elements from the soap envelop
- *
- * @param elementName - The name of the required element
- * @param parentElement - The parent element that the required element should be retrived from
- * @return - The value of the element as a string
- */
- private static String getOMElementValue(String elementName, OMElement parentElement) {
-
- OMElement httpURLParam = null;
- Iterator children = parentElement.getChildElements();
-
- while (children.hasNext()) {
- OMElement child = (OMElement) children.next();
- QName qName = child.getQName();
- if (elementName.equals(qName.getLocalPart())) {
- httpURLParam = child;
- break;
- }
- }
-
- if (httpURLParam != null) {
- httpURLParam.detach();
-
- if (parentElement.getFirstOMChild() == null) {
- parentElement.detach();
- }
- return httpURLParam.getText();
- }
- return "";
-
- }
-
- /**
* Returns the templated URL given the original URL
*
* @param targetURL - The original URL
@@ -217,7 +123,7 @@
if (separator > -1) {
replacedQuery = URIEncoderDecoder.quoteIllegal(
- URLTemplatingUtil.applyURITemplating(messageContext, httpLocation, detach),
+ WSDL20Util.applyURITemplating(messageContext, httpLocation, detach),
WSDL2Constants.LEGAL_CHARACTERS_IN_URL);
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java?view=diff&rev=553365&r1=553364&r2=553365
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java Wed Jul 4 20:09:19 2007
@@ -19,16 +19,6 @@
package org.apache.axis2.util;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
import org.apache.axiom.om.OMElement;
import org.apache.axis2.description.AxisDescription;
import org.apache.axis2.description.AxisMessage;
@@ -40,9 +30,20 @@
import org.apache.neethi.PolicyComponent;
import org.apache.neethi.PolicyEngine;
import org.apache.neethi.PolicyReference;
-import org.apache.neethi.PolicyRegistry;
-import org.apache.woden.internal.util.dom.DOM2Writer;
-import org.w3c.dom.Element;
+
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.List;
public class PolicyUtil {
@@ -131,29 +132,31 @@
}
}
- public static PolicyComponent getPolicyComponent(Element element) {
-
- String xmlString;
- ByteArrayInputStream bais;
-
+ public static PolicyComponent getPolicyComponent(org.w3c.dom.Element element) {
if (Constants.URI_POLICY_NS.equals(element.getNamespaceURI())) {
if (Constants.ELEM_POLICY.equals(element.getLocalName())) {
- xmlString = DOM2Writer.nodeToString(element);
- bais = new ByteArrayInputStream(xmlString.getBytes());
-
- return PolicyEngine.getPolicy(bais);
+ return PolicyEngine.getPolicy(nodeToStream(element));
} else if (Constants.ELEM_POLICY_REF.equals(element.getLocalName())) {
- xmlString = DOM2Writer.nodeToString(element);
- bais = new ByteArrayInputStream(xmlString.getBytes());
-
- return PolicyEngine.getPolicyReferene(bais);
+ return PolicyEngine.getPolicyReferene(nodeToStream(element));
}
}
throw new IllegalArgumentException(
"Agrument is neither a <wsp:Policy> nor a <wsp:PolicyReference> element");
+ }
+
+ private static InputStream nodeToStream(org.w3c.dom.Element element) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ Transformer tf;
+ try {
+ tf = TransformerFactory.newInstance().newTransformer();
+ tf.transform(new DOMSource(element), new StreamResult(baos));
+ return new ByteArrayInputStream(baos.toByteArray());
+ } catch (Exception e) {
+ throw new RuntimeException("Unable to process policy");
+ }
}
public static String policyComponentToString(PolicyComponent policyComponent)
Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDL20Util.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDL20Util.java?view=auto&rev=553365
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDL20Util.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDL20Util.java Wed Jul 4 20:09:19 2007
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.util;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.WSDL20DefaultValueHolder;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.transport.http.util.URIEncoderDecoder;
+import org.apache.woden.wsdl20.extensions.http.HTTPLocation;
+import org.apache.woden.wsdl20.extensions.http.HTTPLocationTemplate;
+import org.apache.woden.wsdl20.extensions.soap.SOAPFaultCode;
+import org.apache.woden.wsdl20.extensions.soap.SOAPFaultSubcodes;
+
+import javax.xml.namespace.QName;
+import java.io.UnsupportedEncodingException;
+import java.util.Iterator;
+import java.util.Map;
+
+public class WSDL20Util {
+ public static void extractWSDL20SoapFaultInfo(Map options, OMElement bindingMessageElement, OMFactory omFactory, OMNamespace wsoap) {
+ // Fault specific properties
+ SOAPFaultCode faultCode = (SOAPFaultCode) options
+ .get(WSDL2Constants.ATTR_WSOAP_CODE);
+ if (faultCode != null && faultCode.getQName() != null) {
+ bindingMessageElement.addAttribute(omFactory.createOMAttribute(
+ WSDL2Constants.ATTRIBUTE_CODE, wsoap, faultCode.getQName().getLocalPart()));
+ }
+ SOAPFaultSubcodes soapFaultSubcodes = (SOAPFaultSubcodes) options
+ .get(WSDL2Constants.ATTR_WSOAP_SUBCODES);
+ QName faultCodes[];
+ if (soapFaultSubcodes != null && (faultCodes = soapFaultSubcodes.getQNames()) != null) {
+ for (int i = 0; i < faultCodes.length; i++) {
+ bindingMessageElement.addAttribute(omFactory.createOMAttribute(
+ WSDL2Constants.ATTRIBUTE_SUBCODES, wsoap, faultCodes[0].getLocalPart()));
+ }
+ }
+ }
+
+ /**
+ * This method is used to resolve httplocation property. It changes the URL as stipulated by
+ * the httplocation property.
+ *
+ * @param messageContext - The MessageContext of the request
+ * @param rawURLString - The raw URL containing httplocation templates
+ * @param detach - Boolean value specifying whether the element should be detached from the
+ * envelop. When serializing data as application/x-form-urlencoded what goes in the body is the
+ * remainder and therefore we should detach the element from the envelop.
+ * @return - String with templated values replaced
+ * @throws org.apache.axis2.AxisFault - Thrown in case an exception occurs
+ */
+ public static String applyURITemplating(MessageContext messageContext, String rawURLString,
+ boolean detach) throws AxisFault {
+
+ OMElement firstElement;
+ if (detach) {
+ firstElement = messageContext.getEnvelope().getBody().getFirstElement();
+ } else {
+ firstElement =
+ messageContext.getEnvelope().getBody().getFirstElement().cloneOMElement();
+ }
+ String queryParameterSeparator = (String) messageContext.getProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR);
+ if (queryParameterSeparator == null) {
+ queryParameterSeparator = WSDL20DefaultValueHolder.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR_DEFAULT;
+ }
+ HTTPLocation httpLocation = new HTTPLocation(rawURLString);
+ HTTPLocationTemplate[] templates = httpLocation.getTemplates();
+
+ for (int i = 0; i < templates.length; i++) {
+ HTTPLocationTemplate template = templates[i];
+ String localName = template.getName();
+ String elementValue = getOMElementValue(localName, firstElement);
+ if (template.isEncoded()) {
+ try {
+
+ if (template.isQuery()) {
+ template.setValue(URIEncoderDecoder.quoteIllegal(
+ elementValue,
+ WSDL2Constants.LEGAL_CHARACTERS_IN_QUERY.replaceAll(queryParameterSeparator, "")));
+ } else {
+ template.setValue(URIEncoderDecoder.quoteIllegal(
+ elementValue,
+ WSDL2Constants.LEGAL_CHARACTERS_IN_PATH));
+ }
+ } catch (UnsupportedEncodingException e) {
+ throw new AxisFault("Unable to encode Query String");
+ }
+
+ } else {
+ template.setValue(elementValue);
+ }
+ }
+
+ return httpLocation.getFormattedLocation();
+ }
+
+ /**
+ * This method is used to retrive elements from the soap envelop
+ *
+ * @param elementName - The name of the required element
+ * @param parentElement - The parent element that the required element should be retrived from
+ * @return - The value of the element as a string
+ */
+ private static String getOMElementValue(String elementName, OMElement parentElement) {
+
+ OMElement httpURLParam = null;
+ Iterator children = parentElement.getChildElements();
+
+ while (children.hasNext()) {
+ OMElement child = (OMElement) children.next();
+ QName qName = child.getQName();
+ if (elementName.equals(qName.getLocalPart())) {
+ httpURLParam = child;
+ break;
+ }
+ }
+
+ if (httpURLParam != null) {
+ httpURLParam.detach();
+
+ if (parentElement.getFirstOMChild() == null) {
+ parentElement.detach();
+ }
+ return httpURLParam.getText();
+ }
+ return "";
+
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org