src/share/jaxws_classes/com/sun/xml/internal/ws/addressing/EndpointReferenceUtil.java

Fri, 14 Feb 2014 11:13:45 +0100

author
mkos
date
Fri, 14 Feb 2014 11:13:45 +0100
changeset 515
6cd506508147
parent 368
0989ad8c0860
child 637
9c07ef4934dd
permissions
-rw-r--r--

8026188: Enhance envelope factory
Summary: Avoiding caching data initialized via TCCL in static context; fix also reviewed by Alexander Fomin
Reviewed-by: ahgross, mgrebac, skoivu

ohair@286 1 /*
alanb@368 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
ohair@286 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@286 4 *
ohair@286 5 * This code is free software; you can redistribute it and/or modify it
ohair@286 6 * under the terms of the GNU General Public License version 2 only, as
ohair@286 7 * published by the Free Software Foundation. Oracle designates this
ohair@286 8 * particular file as subject to the "Classpath" exception as provided
ohair@286 9 * by Oracle in the LICENSE file that accompanied this code.
ohair@286 10 *
ohair@286 11 * This code is distributed in the hope that it will be useful, but WITHOUT
ohair@286 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@286 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@286 14 * version 2 for more details (a copy is included in the LICENSE file that
ohair@286 15 * accompanied this code).
ohair@286 16 *
ohair@286 17 * You should have received a copy of the GNU General Public License version
ohair@286 18 * 2 along with this work; if not, write to the Free Software Foundation,
ohair@286 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@286 20 *
ohair@286 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@286 22 * or visit www.oracle.com if you need additional information or have any
ohair@286 23 * questions.
ohair@286 24 */
ohair@286 25
ohair@286 26 package com.sun.xml.internal.ws.addressing;
ohair@286 27
ohair@286 28 import com.sun.istack.internal.Nullable;
ohair@286 29 import com.sun.istack.internal.NotNull;
ohair@286 30 import com.sun.xml.internal.stream.buffer.XMLStreamBufferSource;
ohair@286 31 import com.sun.xml.internal.stream.buffer.stax.StreamWriterBufferCreator;
ohair@286 32 import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
ohair@286 33 import com.sun.xml.internal.ws.developer.MemberSubmissionEndpointReference;
ohair@286 34 import com.sun.xml.internal.ws.util.DOMUtil;
ohair@286 35 import com.sun.xml.internal.ws.util.xml.XmlUtil;
ohair@286 36 import com.sun.xml.internal.ws.wsdl.parser.WSDLConstants;
ohair@286 37 import com.sun.xml.internal.ws.addressing.v200408.MemberSubmissionAddressingConstants;
ohair@286 38 import org.w3c.dom.*;
ohair@286 39
ohair@286 40 import javax.xml.namespace.QName;
ohair@286 41 import javax.xml.stream.XMLStreamException;
ohair@286 42 import javax.xml.transform.dom.DOMResult;
ohair@286 43 import javax.xml.ws.EndpointReference;
ohair@286 44 import javax.xml.ws.WebServiceException;
ohair@286 45 import javax.xml.ws.wsaddressing.W3CEndpointReference;
ohair@286 46 import java.util.ArrayList;
ohair@286 47 import java.util.HashMap;
ohair@286 48 import java.util.Map;
ohair@286 49
ohair@286 50 /**
ohair@286 51 * @author Rama Pulavarthi
ohair@286 52 */
ohair@286 53
ohair@286 54 public class EndpointReferenceUtil {
ohair@286 55 /**
ohair@286 56 * Gives the EPR based on the clazz. It may need to perform tranformation from
ohair@286 57 * W3C EPR to MS EPR or vise-versa.
ohair@286 58 */
ohair@286 59 public static <T extends EndpointReference> T transform(Class<T> clazz, @NotNull EndpointReference epr) {
ohair@286 60 assert epr != null;
ohair@286 61 if (clazz.isAssignableFrom(W3CEndpointReference.class)) {
ohair@286 62 if (epr instanceof W3CEndpointReference) {
ohair@286 63 return (T) epr;
ohair@286 64 } else if (epr instanceof MemberSubmissionEndpointReference) {
ohair@286 65 return (T) toW3CEpr((MemberSubmissionEndpointReference) epr);
ohair@286 66 }
ohair@286 67 } else if (clazz.isAssignableFrom(MemberSubmissionEndpointReference.class)) {
ohair@286 68 if (epr instanceof W3CEndpointReference) {
ohair@286 69 return (T) toMSEpr((W3CEndpointReference) epr);
ohair@286 70 } else if (epr instanceof MemberSubmissionEndpointReference) {
ohair@286 71 return (T) epr;
ohair@286 72 }
ohair@286 73 }
ohair@286 74
ohair@286 75 //This must be an EPR that we dont know
ohair@286 76 throw new WebServiceException("Unknwon EndpointReference: " + epr.getClass());
ohair@286 77 }
ohair@286 78
ohair@286 79 //TODO: bit of redundency on writes of w3c epr, should modularize it
ohair@286 80 private static W3CEndpointReference toW3CEpr(MemberSubmissionEndpointReference msEpr) {
ohair@286 81 StreamWriterBufferCreator writer = new StreamWriterBufferCreator();
ohair@286 82 w3cMetadataWritten = false;
ohair@286 83 try {
ohair@286 84 writer.writeStartDocument();
ohair@286 85 writer.writeStartElement(AddressingVersion.W3C.getPrefix(),
ohair@286 86 "EndpointReference", AddressingVersion.W3C.nsUri);
ohair@286 87 writer.writeNamespace(AddressingVersion.W3C.getPrefix(),
ohair@286 88 AddressingVersion.W3C.nsUri);
ohair@286 89 //write wsa:Address
ohair@286 90 writer.writeStartElement(AddressingVersion.W3C.getPrefix(),
ohair@286 91 AddressingVersion.W3C.eprType.address
ohair@286 92 , AddressingVersion.W3C.nsUri);
ohair@286 93 writer.writeCharacters(msEpr.addr.uri);
ohair@286 94 writer.writeEndElement();
ohair@286 95 //TODO: write extension attributes on wsa:Address
ohair@286 96 if ((msEpr.referenceProperties != null && msEpr.referenceProperties.elements.size() > 0) ||
ohair@286 97 (msEpr.referenceParameters != null && msEpr.referenceParameters.elements.size() > 0)) {
ohair@286 98
ohair@286 99 writer.writeStartElement(AddressingVersion.W3C.getPrefix(), "ReferenceParameters", AddressingVersion.W3C.nsUri);
ohair@286 100
ohair@286 101 //write ReferenceProperties
ohair@286 102 if (msEpr.referenceProperties != null) {
ohair@286 103 for (Element e : msEpr.referenceProperties.elements) {
ohair@286 104 DOMUtil.serializeNode(e, writer);
ohair@286 105 }
ohair@286 106 }
ohair@286 107 //write referenceParameters
ohair@286 108 if (msEpr.referenceParameters != null) {
ohair@286 109 for (Element e : msEpr.referenceParameters.elements) {
ohair@286 110 DOMUtil.serializeNode(e, writer);
ohair@286 111 }
ohair@286 112 }
ohair@286 113 writer.writeEndElement();
ohair@286 114 }
ohair@286 115 // Supress writing ServiceName and EndpointName in W3CEPR,
ohair@286 116 // Until the ns for those metadata elements is resolved.
ohair@286 117 /*
ohair@286 118 //Write Interface info
ohair@286 119 if (msEpr.portTypeName != null) {
ohair@286 120 writeW3CMetadata(writer);
ohair@286 121 writer.writeStartElement(AddressingVersion.W3C.getWsdlPrefix(),
ohair@286 122 AddressingVersion.W3C.eprType.portTypeName ,
ohair@286 123 AddressingVersion.W3C.wsdlNsUri);
ohair@286 124 writer.writeNamespace(AddressingVersion.W3C.getWsdlPrefix(),
ohair@286 125 AddressingVersion.W3C.wsdlNsUri);
ohair@286 126 String portTypePrefix = fixNull(msEpr.portTypeName.name.getPrefix());
ohair@286 127 writer.writeNamespace(portTypePrefix, msEpr.portTypeName.name.getNamespaceURI());
ohair@286 128 if (portTypePrefix.equals(""))
ohair@286 129 writer.writeCharacters(msEpr.portTypeName.name.getLocalPart());
ohair@286 130 else
ohair@286 131 writer.writeCharacters(portTypePrefix + ":" + msEpr.portTypeName.name.getLocalPart());
ohair@286 132 writer.writeEndElement();
ohair@286 133 }
ohair@286 134 if (msEpr.serviceName != null) {
ohair@286 135 writeW3CMetadata(writer);
ohair@286 136 //Write service and Port info
ohair@286 137 writer.writeStartElement(AddressingVersion.W3C.getWsdlPrefix(),
ohair@286 138 AddressingVersion.W3C.eprType.serviceName ,
ohair@286 139 AddressingVersion.W3C.wsdlNsUri);
ohair@286 140 writer.writeNamespace(AddressingVersion.W3C.getWsdlPrefix(),
ohair@286 141 AddressingVersion.W3C.wsdlNsUri);
ohair@286 142
ohair@286 143 String servicePrefix = fixNull(msEpr.serviceName.name.getPrefix());
ohair@286 144 if (msEpr.serviceName.portName != null)
ohair@286 145 writer.writeAttribute(AddressingVersion.W3C.eprType.portName,
ohair@286 146 msEpr.serviceName.portName);
ohair@286 147
ohair@286 148 writer.writeNamespace(servicePrefix, msEpr.serviceName.name.getNamespaceURI());
ohair@286 149 if (servicePrefix.length() > 0)
ohair@286 150 writer.writeCharacters(servicePrefix + ":" + msEpr.serviceName.name.getLocalPart());
ohair@286 151 else
ohair@286 152 writer.writeCharacters(msEpr.serviceName.name.getLocalPart());
ohair@286 153 writer.writeEndElement();
ohair@286 154 }
ohair@286 155 */
ohair@286 156 //TODO: revisit this
ohair@286 157 Element wsdlElement = null;
ohair@286 158 //Check for wsdl in extension elements
ohair@286 159 if ((msEpr.elements != null) && (msEpr.elements.size() > 0)) {
ohair@286 160 for (Element e : msEpr.elements) {
ohair@286 161 if(e.getNamespaceURI().equals(MemberSubmissionAddressingConstants.MEX_METADATA.getNamespaceURI()) &&
ohair@286 162 e.getLocalName().equals(MemberSubmissionAddressingConstants.MEX_METADATA.getLocalPart())) {
ohair@286 163 NodeList nl = e.getElementsByTagNameNS(WSDLConstants.NS_WSDL,
ohair@286 164 WSDLConstants.QNAME_DEFINITIONS.getLocalPart());
alanb@368 165 if(nl != null) {
ohair@286 166 wsdlElement = (Element) nl.item(0);
alanb@368 167 }
ohair@286 168 }
ohair@286 169 }
ohair@286 170 }
ohair@286 171 //write WSDL
ohair@286 172 if (wsdlElement != null) {
ohair@286 173 DOMUtil.serializeNode(wsdlElement, writer);
ohair@286 174 }
ohair@286 175
alanb@368 176 if (w3cMetadataWritten) {
ohair@286 177 writer.writeEndElement();
alanb@368 178 }
ohair@286 179 //TODO revisit this
ohair@286 180 //write extension elements
ohair@286 181 if ((msEpr.elements != null) && (msEpr.elements.size() > 0)) {
ohair@286 182 for (Element e : msEpr.elements) {
ohair@286 183 if (e.getNamespaceURI().equals(WSDLConstants.NS_WSDL) &&
ohair@286 184 e.getLocalName().equals(WSDLConstants.QNAME_DEFINITIONS.getLocalPart())) {
ohair@286 185 // Don't write it as this is written already in Metadata
ohair@286 186 }
ohair@286 187 DOMUtil.serializeNode(e, writer);
ohair@286 188 }
ohair@286 189 }
ohair@286 190
ohair@286 191 //TODO:write extension attributes
ohair@286 192
ohair@286 193 //</EndpointReference>
ohair@286 194 writer.writeEndElement();
ohair@286 195 writer.writeEndDocument();
ohair@286 196 writer.flush();
ohair@286 197 } catch (XMLStreamException e) {
ohair@286 198 throw new WebServiceException(e);
ohair@286 199 }
ohair@286 200 return new W3CEndpointReference(new XMLStreamBufferSource(writer.getXMLStreamBuffer()));
ohair@286 201 }
ohair@286 202
ohair@286 203 private static boolean w3cMetadataWritten = false;
ohair@286 204
alanb@368 205 // private static void writeW3CMetadata(StreamWriterBufferCreator writer) throws XMLStreamException {
alanb@368 206 // if (!w3cMetadataWritten) {
alanb@368 207 // writer.writeStartElement(AddressingVersion.W3C.getPrefix(), AddressingVersion.W3C.eprType.wsdlMetadata.getLocalPart(), AddressingVersion.W3C.nsUri);
alanb@368 208 // w3cMetadataWritten = true;
alanb@368 209 // }
alanb@368 210 // }
alanb@368 211 //
ohair@286 212 private static MemberSubmissionEndpointReference toMSEpr(W3CEndpointReference w3cEpr) {
ohair@286 213 DOMResult result = new DOMResult();
ohair@286 214 w3cEpr.writeTo(result);
ohair@286 215 Node eprNode = result.getNode();
ohair@286 216 Element e = DOMUtil.getFirstElementChild(eprNode);
alanb@368 217 if (e == null) {
ohair@286 218 return null;
alanb@368 219 }
ohair@286 220
ohair@286 221 MemberSubmissionEndpointReference msEpr = new MemberSubmissionEndpointReference();
ohair@286 222
ohair@286 223 NodeList nodes = e.getChildNodes();
ohair@286 224 for (int i = 0; i < nodes.getLength(); i++) {
ohair@286 225 if (nodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
ohair@286 226 Element child = (Element) nodes.item(i);
ohair@286 227 if (child.getNamespaceURI().equals(AddressingVersion.W3C.nsUri) &&
ohair@286 228 child.getLocalName().equals(AddressingVersion.W3C.eprType.address)) {
alanb@368 229 if (msEpr.addr == null) {
ohair@286 230 msEpr.addr = new MemberSubmissionEndpointReference.Address();
alanb@368 231 }
ohair@286 232 msEpr.addr.uri = XmlUtil.getTextForNode(child);
ohair@286 233
ohair@286 234 } else if (child.getNamespaceURI().equals(AddressingVersion.W3C.nsUri) &&
ohair@286 235 child.getLocalName().equals("ReferenceParameters")) {
ohair@286 236 NodeList refParams = child.getChildNodes();
ohair@286 237 for (int j = 0; j < refParams.getLength(); j++) {
ohair@286 238 if (refParams.item(j).getNodeType() == Node.ELEMENT_NODE) {
ohair@286 239 if (msEpr.referenceParameters == null) {
ohair@286 240 msEpr.referenceParameters = new MemberSubmissionEndpointReference.Elements();
ohair@286 241 msEpr.referenceParameters.elements = new ArrayList<Element>();
ohair@286 242 }
ohair@286 243 msEpr.referenceParameters.elements.add((Element) refParams.item(j));
ohair@286 244 }
ohair@286 245 }
ohair@286 246 } else if (child.getNamespaceURI().equals(AddressingVersion.W3C.nsUri) &&
ohair@286 247 child.getLocalName().equals(AddressingVersion.W3C.eprType.wsdlMetadata.getLocalPart())) {
ohair@286 248 NodeList metadata = child.getChildNodes();
ohair@286 249 String wsdlLocation = child.getAttributeNS(W3CAddressingMetadataConstants.WSAM_WSDLI_ATTRIBUTE_NAMESPACE,
ohair@286 250 W3CAddressingMetadataConstants.WSAM_WSDLI_ATTRIBUTE_LOCALNAME);
ohair@286 251 Element wsdlDefinitions = null;
ohair@286 252 for (int j = 0; j < metadata.getLength(); j++) {
ohair@286 253 Node node = metadata.item(j);
alanb@368 254 if (node.getNodeType() != Node.ELEMENT_NODE) {
ohair@286 255 continue;
alanb@368 256 }
ohair@286 257
ohair@286 258 Element elm = (Element) node;
ohair@286 259 if ((elm.getNamespaceURI().equals(AddressingVersion.W3C.wsdlNsUri) ||
ohair@286 260 elm.getNamespaceURI().equals(W3CAddressingMetadataConstants.WSAM_NAMESPACE_NAME)) &&
ohair@286 261 elm.getLocalName().equals(AddressingVersion.W3C.eprType.serviceName)) {
ohair@286 262 msEpr.serviceName = new MemberSubmissionEndpointReference.ServiceNameType();
ohair@286 263 msEpr.serviceName.portName = elm.getAttribute(AddressingVersion.W3C.eprType.portName);
ohair@286 264
ohair@286 265 String service = elm.getTextContent();
ohair@286 266 String prefix = XmlUtil.getPrefix(service);
ohair@286 267 String name = XmlUtil.getLocalPart(service);
ohair@286 268
ohair@286 269 //if there is no service name then its not a valid EPR but lets continue as its optional anyway
alanb@368 270 if (name == null) {
ohair@286 271 continue;
alanb@368 272 }
ohair@286 273
ohair@286 274 if (prefix != null) {
ohair@286 275 String ns = elm.lookupNamespaceURI(prefix);
alanb@368 276 if (ns != null) {
ohair@286 277 msEpr.serviceName.name = new QName(ns, name, prefix);
alanb@368 278 }
ohair@286 279 } else {
ohair@286 280 msEpr.serviceName.name = new QName(null, name);
ohair@286 281 }
ohair@286 282 msEpr.serviceName.attributes = getAttributes(elm);
ohair@286 283 } else if ((elm.getNamespaceURI().equals(AddressingVersion.W3C.wsdlNsUri) ||
ohair@286 284 elm.getNamespaceURI().equals(W3CAddressingMetadataConstants.WSAM_NAMESPACE_NAME)) &&
ohair@286 285 elm.getLocalName().equals(AddressingVersion.W3C.eprType.portTypeName)) {
ohair@286 286 msEpr.portTypeName = new MemberSubmissionEndpointReference.AttributedQName();
ohair@286 287
ohair@286 288 String portType = elm.getTextContent();
ohair@286 289 String prefix = XmlUtil.getPrefix(portType);
ohair@286 290 String name = XmlUtil.getLocalPart(portType);
ohair@286 291
ohair@286 292 //if there is no portType name then its not a valid EPR but lets continue as its optional anyway
alanb@368 293 if (name == null) {
ohair@286 294 continue;
alanb@368 295 }
ohair@286 296
ohair@286 297 if (prefix != null) {
ohair@286 298 String ns = elm.lookupNamespaceURI(prefix);
alanb@368 299 if (ns != null) {
ohair@286 300 msEpr.portTypeName.name = new QName(ns, name, prefix);
alanb@368 301 }
ohair@286 302 } else {
ohair@286 303 msEpr.portTypeName.name = new QName(null, name);
ohair@286 304 }
ohair@286 305 msEpr.portTypeName.attributes = getAttributes(elm);
ohair@286 306 } else if(elm.getNamespaceURI().equals(WSDLConstants.NS_WSDL) &&
ohair@286 307 elm.getLocalName().equals(WSDLConstants.QNAME_DEFINITIONS.getLocalPart())) {
ohair@286 308 wsdlDefinitions = elm;
ohair@286 309 } else {
ohair@286 310 //TODO : Revisit this
ohair@286 311 //its extensions in META-DATA and should be copied to extensions in MS EPR
ohair@286 312 if (msEpr.elements == null) {
ohair@286 313 msEpr.elements = new ArrayList<Element>();
ohair@286 314 }
ohair@286 315 msEpr.elements.add(elm);
ohair@286 316 }
ohair@286 317 }
ohair@286 318
ohair@286 319
ohair@286 320 Document doc = DOMUtil.createDom();
ohair@286 321 Element mexEl = doc.createElementNS(MemberSubmissionAddressingConstants.MEX_METADATA.getNamespaceURI(),
ohair@286 322 MemberSubmissionAddressingConstants.MEX_METADATA.getPrefix() + ":"
ohair@286 323 + MemberSubmissionAddressingConstants.MEX_METADATA.getLocalPart());
ohair@286 324 Element metadataEl = doc.createElementNS(MemberSubmissionAddressingConstants.MEX_METADATA_SECTION.getNamespaceURI(),
ohair@286 325 MemberSubmissionAddressingConstants.MEX_METADATA_SECTION.getPrefix() + ":"
ohair@286 326 + MemberSubmissionAddressingConstants.MEX_METADATA_SECTION.getLocalPart());
ohair@286 327 metadataEl.setAttribute(MemberSubmissionAddressingConstants.MEX_METADATA_DIALECT_ATTRIBUTE,
ohair@286 328 MemberSubmissionAddressingConstants.MEX_METADATA_DIALECT_VALUE);
ohair@286 329 if (wsdlDefinitions == null && wsdlLocation != null && !wsdlLocation.equals("")) {
ohair@286 330 wsdlLocation = wsdlLocation.trim();
ohair@286 331 String wsdlTns = wsdlLocation.substring(0, wsdlLocation.indexOf(' '));
ohair@286 332 wsdlLocation = wsdlLocation.substring(wsdlLocation.indexOf(' ') + 1);
ohair@286 333 Element wsdlEl = doc.createElementNS(WSDLConstants.NS_WSDL,
ohair@286 334 WSDLConstants.PREFIX_NS_WSDL + ":"
ohair@286 335 + WSDLConstants.QNAME_DEFINITIONS.getLocalPart());
ohair@286 336 Element wsdlImportEl = doc.createElementNS(WSDLConstants.NS_WSDL,
ohair@286 337 WSDLConstants.PREFIX_NS_WSDL + ":"
ohair@286 338 + WSDLConstants.QNAME_IMPORT.getLocalPart());
ohair@286 339 wsdlImportEl.setAttribute("namespace", wsdlTns);
ohair@286 340 wsdlImportEl.setAttribute("location", wsdlLocation);
ohair@286 341 wsdlEl.appendChild(wsdlImportEl);
ohair@286 342 metadataEl.appendChild(wsdlEl);
ohair@286 343 } else if(wsdlDefinitions != null){
ohair@286 344 metadataEl.appendChild(wsdlDefinitions);
ohair@286 345 }
ohair@286 346 mexEl.appendChild(metadataEl);
ohair@286 347
ohair@286 348 if (msEpr.elements == null) {
ohair@286 349 msEpr.elements = new ArrayList<Element>();
ohair@286 350 }
ohair@286 351 msEpr.elements.add(mexEl);
ohair@286 352
ohair@286 353
ohair@286 354 } else {
ohair@286 355 //its extensions
ohair@286 356 if (msEpr.elements == null) {
ohair@286 357 msEpr.elements = new ArrayList<Element>();
ohair@286 358 }
ohair@286 359 msEpr.elements.add((Element) child);
ohair@286 360
ohair@286 361 }
ohair@286 362 } else if (nodes.item(i).getNodeType() == Node.ATTRIBUTE_NODE) {
ohair@286 363 Node n = nodes.item(i);
ohair@286 364 if (msEpr.attributes == null) {
ohair@286 365 msEpr.attributes = new HashMap<QName, String>();
ohair@286 366 String prefix = fixNull(n.getPrefix());
ohair@286 367 String ns = fixNull(n.getNamespaceURI());
ohair@286 368 String localName = n.getLocalName();
ohair@286 369 msEpr.attributes.put(new QName(ns, localName, prefix), n.getNodeValue());
ohair@286 370 }
ohair@286 371 }
ohair@286 372 }
ohair@286 373
ohair@286 374 return msEpr;
ohair@286 375 }
ohair@286 376
ohair@286 377 private static Map<QName, String> getAttributes(Node node) {
ohair@286 378 Map<QName, String> attribs = null;
ohair@286 379
ohair@286 380 NamedNodeMap nm = node.getAttributes();
ohair@286 381 for (int i = 0; i < nm.getLength(); i++) {
alanb@368 382 if (attribs == null) {
ohair@286 383 attribs = new HashMap<QName, String>();
alanb@368 384 }
ohair@286 385 Node n = nm.item(i);
ohair@286 386 String prefix = fixNull(n.getPrefix());
ohair@286 387 String ns = fixNull(n.getNamespaceURI());
ohair@286 388 String localName = n.getLocalName();
alanb@368 389 if (prefix.equals("xmlns") || prefix.length() == 0 && localName.equals("xmlns")) {
ohair@286 390 continue;
alanb@368 391 }
ohair@286 392
ohair@286 393 //exclude some attributes
alanb@368 394 if (!localName.equals(AddressingVersion.W3C.eprType.portName)) {
ohair@286 395 attribs.put(new QName(ns, localName, prefix), n.getNodeValue());
alanb@368 396 }
ohair@286 397 }
ohair@286 398 return attribs;
ohair@286 399 }
ohair@286 400
ohair@286 401 private static
ohair@286 402 @NotNull
ohair@286 403 String fixNull(@Nullable String s) {
alanb@368 404 if (s == null) {
alanb@368 405 return "";
alanb@368 406 } else {
alanb@368 407 return s;
alanb@368 408 }
ohair@286 409 }
ohair@286 410
ohair@286 411 }

mercurial