src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ver1_2/Fault1_2Impl.java

Thu, 31 Aug 2017 15:18:52 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:18:52 +0800
changeset 637
9c07ef4934dd
parent 368
0989ad8c0860
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation. Oracle designates this
aoqi@0 8 * particular file as subject to the "Classpath" exception as provided
aoqi@0 9 * by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 *
aoqi@0 11 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 * accompanied this code).
aoqi@0 16 *
aoqi@0 17 * You should have received a copy of the GNU General Public License version
aoqi@0 18 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 *
aoqi@0 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 * or visit www.oracle.com if you need additional information or have any
aoqi@0 23 * questions.
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 /**
aoqi@0 27 *
aoqi@0 28 * @author SAAJ RI Development Team
aoqi@0 29 */
aoqi@0 30 package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
aoqi@0 31
aoqi@0 32 import java.util.*;
aoqi@0 33 import java.util.logging.Logger;
aoqi@0 34 import java.util.logging.Level;
aoqi@0 35
aoqi@0 36 import javax.xml.namespace.QName;
aoqi@0 37 import javax.xml.soap.*;
aoqi@0 38
aoqi@0 39 import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
aoqi@0 40 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
aoqi@0 41 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
aoqi@0 42 import com.sun.xml.internal.messaging.saaj.soap.impl.*;
aoqi@0 43 import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
aoqi@0 44 import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
aoqi@0 45
aoqi@0 46
aoqi@0 47 public class Fault1_2Impl extends FaultImpl {
aoqi@0 48
aoqi@0 49 protected static final Logger log =
aoqi@0 50 Logger.getLogger(
aoqi@0 51 LogDomainConstants.SOAP_VER1_2_DOMAIN,
aoqi@0 52 "com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
aoqi@0 53
aoqi@0 54 private static final QName textName =
aoqi@0 55 new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Text");
aoqi@0 56 private final QName valueName =
aoqi@0 57 new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Value", getPrefix());
aoqi@0 58 private final QName subcodeName =
aoqi@0 59 new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Subcode", getPrefix());
aoqi@0 60
aoqi@0 61 private SOAPElement innermostSubCodeElement = null;
aoqi@0 62
aoqi@0 63 public Fault1_2Impl(SOAPDocumentImpl ownerDoc, String name, String prefix) {
aoqi@0 64 super(ownerDoc, NameImpl.createFault1_2Name(name, prefix));
aoqi@0 65 }
aoqi@0 66
aoqi@0 67 public Fault1_2Impl(SOAPDocumentImpl ownerDocument, String prefix) {
aoqi@0 68 super(ownerDocument, NameImpl.createFault1_2Name(null, prefix));
aoqi@0 69 }
aoqi@0 70
aoqi@0 71 protected NameImpl getDetailName() {
aoqi@0 72 return NameImpl.createSOAP12Name("Detail", getPrefix());
aoqi@0 73 }
aoqi@0 74
aoqi@0 75 protected NameImpl getFaultCodeName() {
aoqi@0 76 return NameImpl.createSOAP12Name("Code", getPrefix());
aoqi@0 77 }
aoqi@0 78
aoqi@0 79 protected NameImpl getFaultStringName() {
aoqi@0 80 return getFaultReasonName();
aoqi@0 81 }
aoqi@0 82
aoqi@0 83 protected NameImpl getFaultActorName() {
aoqi@0 84 return getFaultRoleName();
aoqi@0 85 }
aoqi@0 86
aoqi@0 87 private NameImpl getFaultRoleName() {
aoqi@0 88 return NameImpl.createSOAP12Name("Role", getPrefix());
aoqi@0 89 }
aoqi@0 90
aoqi@0 91 private NameImpl getFaultReasonName() {
aoqi@0 92 return NameImpl.createSOAP12Name("Reason", getPrefix());
aoqi@0 93 }
aoqi@0 94
aoqi@0 95 private NameImpl getFaultReasonTextName() {
aoqi@0 96 return NameImpl.createSOAP12Name("Text", getPrefix());
aoqi@0 97 }
aoqi@0 98
aoqi@0 99 private NameImpl getFaultNodeName() {
aoqi@0 100 return NameImpl.createSOAP12Name("Node", getPrefix());
aoqi@0 101 }
aoqi@0 102
aoqi@0 103 private static NameImpl getXmlLangName() {
aoqi@0 104 return NameImpl.createXmlName("lang");
aoqi@0 105 }
aoqi@0 106
aoqi@0 107 protected DetailImpl createDetail() {
aoqi@0 108 return new Detail1_2Impl(
aoqi@0 109 ((SOAPDocument) getOwnerDocument()).getDocument());
aoqi@0 110 }
aoqi@0 111
aoqi@0 112 protected FaultElementImpl createSOAPFaultElement(String localName) {
aoqi@0 113 return new FaultElement1_2Impl(
aoqi@0 114 ((SOAPDocument) getOwnerDocument()).getDocument(),
aoqi@0 115 localName);
aoqi@0 116 }
aoqi@0 117
aoqi@0 118 protected void checkIfStandardFaultCode(String faultCode, String uri)
aoqi@0 119 throws SOAPException {
aoqi@0 120 QName qname = new QName(uri, faultCode);
aoqi@0 121 if (SOAPConstants.SOAP_DATAENCODINGUNKNOWN_FAULT.equals(qname) ||
aoqi@0 122 SOAPConstants.SOAP_MUSTUNDERSTAND_FAULT.equals(qname) ||
aoqi@0 123 SOAPConstants.SOAP_RECEIVER_FAULT.equals(qname) ||
aoqi@0 124 SOAPConstants.SOAP_SENDER_FAULT.equals(qname) ||
aoqi@0 125 SOAPConstants.SOAP_VERSIONMISMATCH_FAULT.equals(qname))
aoqi@0 126 return;
aoqi@0 127 log.log(
aoqi@0 128 Level.SEVERE,
aoqi@0 129 "SAAJ0435.ver1_2.code.not.standard",
aoqi@0 130 qname);
aoqi@0 131 throw new SOAPExceptionImpl(qname + " is not a standard Code value");
aoqi@0 132 }
aoqi@0 133
aoqi@0 134 protected void finallySetFaultCode(String faultcode) throws SOAPException {
aoqi@0 135 SOAPElement value = this.faultCodeElement.addChildElement(valueName);
aoqi@0 136 value.addTextNode(faultcode);
aoqi@0 137 }
aoqi@0 138
aoqi@0 139 private void findReasonElement() {
aoqi@0 140 findFaultStringElement();
aoqi@0 141 }
aoqi@0 142
aoqi@0 143 public Iterator getFaultReasonTexts() throws SOAPException {
aoqi@0 144 // Fault Reason has similar semantics as faultstring
aoqi@0 145 if (this.faultStringElement == null)
aoqi@0 146 findReasonElement();
aoqi@0 147 Iterator eachTextElement =
aoqi@0 148 this.faultStringElement.getChildElements(textName);
aoqi@0 149 List texts = new ArrayList();
aoqi@0 150 while (eachTextElement.hasNext()) {
aoqi@0 151 SOAPElement textElement = (SOAPElement) eachTextElement.next();
aoqi@0 152 Locale thisLocale = getLocale(textElement);
aoqi@0 153 if (thisLocale == null) {
aoqi@0 154 log.severe("SAAJ0431.ver1_2.xml.lang.missing");
aoqi@0 155 throw new SOAPExceptionImpl("\"xml:lang\" attribute is not present on the Text element");
aoqi@0 156 }
aoqi@0 157 texts.add(textElement.getValue());
aoqi@0 158 }
aoqi@0 159 if (texts.isEmpty()) {
aoqi@0 160 log.severe("SAAJ0434.ver1_2.text.element.not.present");
aoqi@0 161 throw new SOAPExceptionImpl("env:Text must be present inside env:Reason");
aoqi@0 162 }
aoqi@0 163 return texts.iterator();
aoqi@0 164 }
aoqi@0 165
aoqi@0 166 public void addFaultReasonText(String text, java.util.Locale locale)
aoqi@0 167 throws SOAPException {
aoqi@0 168
aoqi@0 169 if (locale == null) {
aoqi@0 170 log.severe("SAAJ0430.ver1_2.locale.required");
aoqi@0 171 throw new SOAPException("locale is required and must not be null");
aoqi@0 172 }
aoqi@0 173
aoqi@0 174 // Fault Reason has similar semantics as faultstring
aoqi@0 175 if (this.faultStringElement == null)
aoqi@0 176 findReasonElement();
aoqi@0 177 SOAPElement reasonText;
aoqi@0 178
aoqi@0 179 if (this.faultStringElement == null) {
aoqi@0 180 this.faultStringElement = addSOAPFaultElement("Reason");
aoqi@0 181 reasonText =
aoqi@0 182 this.faultStringElement.addChildElement(
aoqi@0 183 getFaultReasonTextName());
aoqi@0 184 } else {
aoqi@0 185 removeDefaultFaultString();
aoqi@0 186 reasonText = getFaultReasonTextElement(locale);
aoqi@0 187 if (reasonText != null) {
aoqi@0 188 reasonText.removeContents();
aoqi@0 189 } else {
aoqi@0 190 reasonText =
aoqi@0 191 this.faultStringElement.addChildElement(
aoqi@0 192 getFaultReasonTextName());
aoqi@0 193 }
aoqi@0 194 }
aoqi@0 195
aoqi@0 196 String xmlLang = localeToXmlLang(locale);
aoqi@0 197 reasonText.addAttribute(getXmlLangName(), xmlLang);
aoqi@0 198 reasonText.addTextNode(text);
aoqi@0 199 }
aoqi@0 200
aoqi@0 201 private void removeDefaultFaultString() throws SOAPException {
aoqi@0 202 SOAPElement reasonText = getFaultReasonTextElement(Locale.getDefault());
aoqi@0 203 if (reasonText != null) {
aoqi@0 204 String defaultFaultString =
aoqi@0 205 "Fault string, and possibly fault code, not set";
aoqi@0 206 if (defaultFaultString.equals(reasonText.getValue())) {
aoqi@0 207 reasonText.detachNode();
aoqi@0 208 }
aoqi@0 209 }
aoqi@0 210 }
aoqi@0 211
aoqi@0 212 public String getFaultReasonText(Locale locale) throws SOAPException {
aoqi@0 213
aoqi@0 214 if (locale == null)
aoqi@0 215 return null;
aoqi@0 216
aoqi@0 217 // Fault Reason has similar semantics as faultstring
aoqi@0 218 if (this.faultStringElement == null)
aoqi@0 219 findReasonElement();
aoqi@0 220
aoqi@0 221 if (this.faultStringElement != null) {
aoqi@0 222 SOAPElement textElement = getFaultReasonTextElement(locale);
aoqi@0 223 if (textElement != null) {
aoqi@0 224 textElement.normalize();
aoqi@0 225 return textElement.getFirstChild().getNodeValue();
aoqi@0 226 }
aoqi@0 227 }
aoqi@0 228
aoqi@0 229 return null;
aoqi@0 230 }
aoqi@0 231
aoqi@0 232 public Iterator getFaultReasonLocales() throws SOAPException {
aoqi@0 233 // Fault Reason has similar semantics as faultstring
aoqi@0 234 if (this.faultStringElement == null)
aoqi@0 235 findReasonElement();
aoqi@0 236 Iterator eachTextElement =
aoqi@0 237 this.faultStringElement.getChildElements(textName);
aoqi@0 238 List localeSet = new ArrayList();
aoqi@0 239 while (eachTextElement.hasNext()) {
aoqi@0 240 SOAPElement textElement = (SOAPElement) eachTextElement.next();
aoqi@0 241 Locale thisLocale = getLocale(textElement);
aoqi@0 242 if (thisLocale == null) {
aoqi@0 243 log.severe("SAAJ0431.ver1_2.xml.lang.missing");
aoqi@0 244 throw new SOAPExceptionImpl("\"xml:lang\" attribute is not present on the Text element");
aoqi@0 245 }
aoqi@0 246 localeSet.add(thisLocale);
aoqi@0 247 }
aoqi@0 248 if (localeSet.isEmpty()) {
aoqi@0 249 log.severe("SAAJ0434.ver1_2.text.element.not.present");
aoqi@0 250 throw new SOAPExceptionImpl("env:Text elements with mandatory xml:lang attributes must be present inside env:Reason");
aoqi@0 251 }
aoqi@0 252 return localeSet.iterator();
aoqi@0 253 }
aoqi@0 254
aoqi@0 255 public Locale getFaultStringLocale() {
aoqi@0 256 Locale locale = null;
aoqi@0 257 try {
aoqi@0 258 locale = (Locale) getFaultReasonLocales().next();
aoqi@0 259 } catch (SOAPException e) {}
aoqi@0 260 return locale;
aoqi@0 261 }
aoqi@0 262
aoqi@0 263 /*
aoqi@0 264 * This method assumes that locale and faultStringElement are non-null
aoqi@0 265 */
aoqi@0 266 private SOAPElement getFaultReasonTextElement(Locale locale)
aoqi@0 267 throws SOAPException {
aoqi@0 268
aoqi@0 269 // Fault Reason has similar semantics as faultstring
aoqi@0 270 Iterator eachTextElement =
aoqi@0 271 this.faultStringElement.getChildElements(textName);
aoqi@0 272 while (eachTextElement.hasNext()) {
aoqi@0 273 SOAPElement textElement = (SOAPElement) eachTextElement.next();
aoqi@0 274 Locale thisLocale = getLocale(textElement);
aoqi@0 275 if (thisLocale == null) {
aoqi@0 276 log.severe("SAAJ0431.ver1_2.xml.lang.missing");
aoqi@0 277 throw new SOAPExceptionImpl("\"xml:lang\" attribute is not present on the Text element");
aoqi@0 278 }
aoqi@0 279 if (thisLocale.equals(locale)) {
aoqi@0 280 return textElement;
aoqi@0 281 }
aoqi@0 282 }
aoqi@0 283 return null;
aoqi@0 284 }
aoqi@0 285
aoqi@0 286 public String getFaultNode() {
aoqi@0 287 SOAPElement faultNode = findChild(getFaultNodeName());
aoqi@0 288 if (faultNode == null) {
aoqi@0 289 return null;
aoqi@0 290 }
aoqi@0 291 return faultNode.getValue();
aoqi@0 292 }
aoqi@0 293
aoqi@0 294 public void setFaultNode(String uri) throws SOAPException {
aoqi@0 295 SOAPElement faultNode = findChild(getFaultNodeName());
aoqi@0 296 if (faultNode != null) {
aoqi@0 297 faultNode.detachNode();
aoqi@0 298 }
aoqi@0 299 faultNode = createSOAPFaultElement(getFaultNodeName());
aoqi@0 300 faultNode = faultNode.addTextNode(uri);
aoqi@0 301 if (getFaultRole() != null) {
aoqi@0 302 insertBefore(faultNode, this.faultActorElement);
aoqi@0 303 return;
aoqi@0 304 }
aoqi@0 305 if (hasDetail()) {
aoqi@0 306 insertBefore(faultNode, this.detail);
aoqi@0 307 return;
aoqi@0 308 }
aoqi@0 309 addNode(faultNode);
aoqi@0 310 }
aoqi@0 311
aoqi@0 312 public String getFaultRole() {
aoqi@0 313 return getFaultActor();
aoqi@0 314 }
aoqi@0 315
aoqi@0 316 public void setFaultRole(String uri) throws SOAPException {
aoqi@0 317 if (this.faultActorElement == null)
aoqi@0 318 findFaultActorElement();
aoqi@0 319 if (this.faultActorElement != null)
aoqi@0 320 this.faultActorElement.detachNode();
aoqi@0 321 this.faultActorElement =
aoqi@0 322 createSOAPFaultElement(getFaultActorName());
aoqi@0 323 this.faultActorElement.addTextNode(uri);
aoqi@0 324 if (hasDetail()) {
aoqi@0 325 insertBefore(this.faultActorElement, this.detail);
aoqi@0 326 return;
aoqi@0 327 }
aoqi@0 328 addNode(this.faultActorElement);
aoqi@0 329 }
aoqi@0 330
aoqi@0 331 public String getFaultCode() {
aoqi@0 332 if (this.faultCodeElement == null)
aoqi@0 333 findFaultCodeElement();
aoqi@0 334 Iterator codeValues =
aoqi@0 335 this.faultCodeElement.getChildElements(valueName);
aoqi@0 336 return ((SOAPElement) codeValues.next()).getValue();
aoqi@0 337 }
aoqi@0 338
aoqi@0 339 public QName getFaultCodeAsQName() {
aoqi@0 340 String faultcode = getFaultCode();
aoqi@0 341 if (faultcode == null) {
aoqi@0 342 return null;
aoqi@0 343 }
aoqi@0 344 if (this.faultCodeElement == null)
aoqi@0 345 findFaultCodeElement();
aoqi@0 346 Iterator valueElements =
aoqi@0 347 this.faultCodeElement.getChildElements(valueName);
aoqi@0 348 return convertCodeToQName(
aoqi@0 349 faultcode,
aoqi@0 350 (SOAPElement) valueElements.next());
aoqi@0 351 }
aoqi@0 352
aoqi@0 353 public Name getFaultCodeAsName() {
aoqi@0 354 String faultcode = getFaultCode();
aoqi@0 355 if (faultcode == null) {
aoqi@0 356 return null;
aoqi@0 357 }
aoqi@0 358 if (this.faultCodeElement == null)
aoqi@0 359 findFaultCodeElement();
aoqi@0 360 Iterator valueElements =
aoqi@0 361 this.faultCodeElement.getChildElements(valueName);
aoqi@0 362 return NameImpl.convertToName(
aoqi@0 363 convertCodeToQName(
aoqi@0 364 faultcode,
aoqi@0 365 (SOAPElement) valueElements.next()));
aoqi@0 366 }
aoqi@0 367
aoqi@0 368 public String getFaultString() {
aoqi@0 369 String reason = null;
aoqi@0 370 try {
aoqi@0 371 //reason = getFaultReasonText(Locale.getDefault());
aoqi@0 372 //if (reason == null)
aoqi@0 373 reason = (String) getFaultReasonTexts().next();
aoqi@0 374 } catch (SOAPException e) {}
aoqi@0 375 return reason;
aoqi@0 376 }
aoqi@0 377
aoqi@0 378 public void setFaultString(String faultString) throws SOAPException {
aoqi@0 379 addFaultReasonText(faultString, Locale.getDefault());
aoqi@0 380 }
aoqi@0 381
aoqi@0 382 public void setFaultString(
aoqi@0 383 String faultString,
aoqi@0 384 Locale locale)
aoqi@0 385 throws SOAPException {
aoqi@0 386 addFaultReasonText(faultString, locale);
aoqi@0 387 }
aoqi@0 388
aoqi@0 389 public void appendFaultSubcode(QName subcode) throws SOAPException {
aoqi@0 390 if (subcode == null) {
aoqi@0 391 return;
aoqi@0 392 }
aoqi@0 393 if (subcode.getNamespaceURI() == null ||
aoqi@0 394 "".equals(subcode.getNamespaceURI())) {
aoqi@0 395
aoqi@0 396 log.severe("SAAJ0432.ver1_2.subcode.not.ns.qualified");
aoqi@0 397 throw new SOAPExceptionImpl("A Subcode must be namespace-qualified");
aoqi@0 398 }
aoqi@0 399 if (innermostSubCodeElement == null) {
aoqi@0 400 if (faultCodeElement == null)
aoqi@0 401 findFaultCodeElement();
aoqi@0 402 innermostSubCodeElement = faultCodeElement;
aoqi@0 403 }
aoqi@0 404 String prefix = null;
aoqi@0 405 if (subcode.getPrefix() == null || "".equals(subcode.getPrefix())) {
aoqi@0 406 prefix =
aoqi@0 407 ((ElementImpl) innermostSubCodeElement).getNamespacePrefix(
aoqi@0 408 subcode.getNamespaceURI());
aoqi@0 409 } else
aoqi@0 410 prefix = subcode.getPrefix();
aoqi@0 411 if (prefix == null || "".equals(prefix)) {
aoqi@0 412 prefix = "ns1";
aoqi@0 413 }
aoqi@0 414 innermostSubCodeElement =
aoqi@0 415 innermostSubCodeElement.addChildElement(subcodeName);
aoqi@0 416 SOAPElement subcodeValueElement =
aoqi@0 417 innermostSubCodeElement.addChildElement(valueName);
aoqi@0 418 ((ElementImpl) subcodeValueElement).ensureNamespaceIsDeclared(
aoqi@0 419 prefix,
aoqi@0 420 subcode.getNamespaceURI());
aoqi@0 421 subcodeValueElement.addTextNode(prefix + ":" + subcode.getLocalPart());
aoqi@0 422 }
aoqi@0 423
aoqi@0 424 public void removeAllFaultSubcodes() {
aoqi@0 425 if (this.faultCodeElement == null)
aoqi@0 426 findFaultCodeElement();
aoqi@0 427 Iterator subcodeElements =
aoqi@0 428 this.faultCodeElement.getChildElements(subcodeName);
aoqi@0 429 if (subcodeElements.hasNext()) {
aoqi@0 430 SOAPElement subcode = (SOAPElement) subcodeElements.next();
aoqi@0 431 subcode.detachNode();
aoqi@0 432 }
aoqi@0 433 }
aoqi@0 434
aoqi@0 435 public Iterator getFaultSubcodes() {
aoqi@0 436 if (this.faultCodeElement == null)
aoqi@0 437 findFaultCodeElement();
aoqi@0 438 final List subcodeList = new ArrayList();
aoqi@0 439 SOAPElement currentCodeElement = this.faultCodeElement;
aoqi@0 440 Iterator subcodeElements =
aoqi@0 441 currentCodeElement.getChildElements(subcodeName);
aoqi@0 442 while (subcodeElements.hasNext()) {
aoqi@0 443 currentCodeElement = (ElementImpl) subcodeElements.next();
aoqi@0 444 Iterator valueElements =
aoqi@0 445 currentCodeElement.getChildElements(valueName);
aoqi@0 446 SOAPElement valueElement = (SOAPElement) valueElements.next();
aoqi@0 447 String code = valueElement.getValue();
aoqi@0 448 subcodeList.add(convertCodeToQName(code, valueElement));
aoqi@0 449 subcodeElements = currentCodeElement.getChildElements(subcodeName);
aoqi@0 450 }
aoqi@0 451 //return subcodeList.iterator();
aoqi@0 452 return new Iterator() {
aoqi@0 453 Iterator subCodeIter = subcodeList.iterator();
aoqi@0 454
aoqi@0 455 public boolean hasNext() {
aoqi@0 456 return subCodeIter.hasNext();
aoqi@0 457 }
aoqi@0 458
aoqi@0 459 public Object next() {
aoqi@0 460 return subCodeIter.next();
aoqi@0 461 }
aoqi@0 462
aoqi@0 463 public void remove() {
aoqi@0 464 throw new UnsupportedOperationException(
aoqi@0 465 "Method remove() not supported on SubCodes Iterator");
aoqi@0 466 }
aoqi@0 467 };
aoqi@0 468 }
aoqi@0 469
aoqi@0 470 private static Locale getLocale(SOAPElement reasonText) {
aoqi@0 471 return xmlLangToLocale(reasonText.getAttributeValue(getXmlLangName()));
aoqi@0 472 }
aoqi@0 473
aoqi@0 474 /*
aoqi@0 475 * Override setEncodingStyle of ElementImpl to restrict adding encodingStyle
aoqi@0 476 * attribute to SOAP Fault (SOAP 1.2 spec, part 1, section 5.1.1)
aoqi@0 477 */
aoqi@0 478 public void setEncodingStyle(String encodingStyle) throws SOAPException {
aoqi@0 479 log.severe("SAAJ0407.ver1_2.no.encodingStyle.in.fault");
aoqi@0 480 throw new SOAPExceptionImpl("encodingStyle attribute cannot appear on Fault");
aoqi@0 481 }
aoqi@0 482
aoqi@0 483 public SOAPElement addAttribute(Name name, String value)
aoqi@0 484 throws SOAPException {
aoqi@0 485 if (name.getLocalName().equals("encodingStyle")
aoqi@0 486 && name.getURI().equals(NameImpl.SOAP12_NAMESPACE)) {
aoqi@0 487 setEncodingStyle(value);
aoqi@0 488 }
aoqi@0 489 return super.addAttribute(name, value);
aoqi@0 490 }
aoqi@0 491
aoqi@0 492 public SOAPElement addAttribute(QName name, String value)
aoqi@0 493 throws SOAPException {
aoqi@0 494 if (name.getLocalPart().equals("encodingStyle")
aoqi@0 495 && name.getNamespaceURI().equals(NameImpl.SOAP12_NAMESPACE)) {
aoqi@0 496 setEncodingStyle(value);
aoqi@0 497 }
aoqi@0 498 return super.addAttribute(name, value);
aoqi@0 499 }
aoqi@0 500
aoqi@0 501 public SOAPElement addTextNode(String text) throws SOAPException {
aoqi@0 502 log.log(
aoqi@0 503 Level.SEVERE,
aoqi@0 504 "SAAJ0416.ver1_2.adding.text.not.legal",
aoqi@0 505 getElementQName());
aoqi@0 506 throw new SOAPExceptionImpl("Adding text to SOAP 1.2 Fault is not legal");
aoqi@0 507 }
aoqi@0 508
aoqi@0 509 public SOAPElement addChildElement(SOAPElement element)
aoqi@0 510 throws SOAPException {
aoqi@0 511 String localName = element.getLocalName();
aoqi@0 512 if ("Detail".equalsIgnoreCase(localName)) {
aoqi@0 513 if (hasDetail()) {
aoqi@0 514 log.severe("SAAJ0436.ver1_2.detail.exists.error");
aoqi@0 515 throw new SOAPExceptionImpl("Cannot add Detail, Detail already exists");
aoqi@0 516 }
aoqi@0 517 String uri = element.getElementQName().getNamespaceURI();
aoqi@0 518 if (!uri.equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
aoqi@0 519 log.severe("SAAJ0437.ver1_2.version.mismatch.error");
aoqi@0 520 throw new SOAPExceptionImpl("Cannot add Detail, Incorrect SOAP version specified for Detail element");
aoqi@0 521 }
aoqi@0 522 }
aoqi@0 523 if (element instanceof Detail1_2Impl) {
aoqi@0 524 ElementImpl importedElement = (ElementImpl) importElement(element);
aoqi@0 525 addNode(importedElement);
aoqi@0 526 return convertToSoapElement(importedElement);
aoqi@0 527 } else
aoqi@0 528 return super.addChildElement(element);
aoqi@0 529 }
aoqi@0 530
aoqi@0 531 protected boolean isStandardFaultElement(String localName) {
aoqi@0 532 if (localName.equalsIgnoreCase("code") ||
aoqi@0 533 localName.equalsIgnoreCase("reason") ||
aoqi@0 534 localName.equalsIgnoreCase("node") ||
aoqi@0 535 localName.equalsIgnoreCase("role") ||
aoqi@0 536 localName.equalsIgnoreCase("detail")) {
aoqi@0 537 return true;
aoqi@0 538 }
aoqi@0 539 return false;
aoqi@0 540 }
aoqi@0 541
aoqi@0 542 protected QName getDefaultFaultCode() {
aoqi@0 543 return SOAPConstants.SOAP_SENDER_FAULT;
aoqi@0 544 }
aoqi@0 545
aoqi@0 546 protected FaultElementImpl createSOAPFaultElement(QName qname) {
aoqi@0 547 return new FaultElement1_2Impl(
aoqi@0 548 ((SOAPDocument) getOwnerDocument()).getDocument(),
aoqi@0 549 qname);
aoqi@0 550 }
aoqi@0 551
aoqi@0 552 protected FaultElementImpl createSOAPFaultElement(Name qname) {
aoqi@0 553 return new FaultElement1_2Impl(
aoqi@0 554 ((SOAPDocument) getOwnerDocument()).getDocument(),
aoqi@0 555 (NameImpl)qname);
aoqi@0 556 }
aoqi@0 557
aoqi@0 558 public void setFaultActor(String faultActor) throws SOAPException {
aoqi@0 559 this.setFaultRole(faultActor);
aoqi@0 560 }
aoqi@0 561
aoqi@0 562 }

mercurial