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

changeset 286
f50545b5e2f1
child 368
0989ad8c0860
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ver1_2/Fault1_2Impl.java	Tue Mar 06 16:09:35 2012 -0800
     1.3 @@ -0,0 +1,562 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +/**
    1.30 +*
    1.31 +* @author SAAJ RI Development Team
    1.32 +*/
    1.33 +package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
    1.34 +
    1.35 +import java.util.*;
    1.36 +import java.util.logging.Logger;
    1.37 +import java.util.logging.Level;
    1.38 +
    1.39 +import javax.xml.namespace.QName;
    1.40 +import javax.xml.soap.*;
    1.41 +
    1.42 +import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
    1.43 +import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
    1.44 +import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
    1.45 +import com.sun.xml.internal.messaging.saaj.soap.impl.*;
    1.46 +import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
    1.47 +import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
    1.48 +
    1.49 +
    1.50 +public class Fault1_2Impl extends FaultImpl {
    1.51 +
    1.52 +    protected static final Logger log =
    1.53 +        Logger.getLogger(
    1.54 +            LogDomainConstants.SOAP_VER1_2_DOMAIN,
    1.55 +            "com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
    1.56 +
    1.57 +    private static final QName textName =
    1.58 +        new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Text");
    1.59 +    private final QName valueName =
    1.60 +        new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Value", getPrefix());
    1.61 +    private final QName subcodeName =
    1.62 +        new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Subcode", getPrefix());
    1.63 +
    1.64 +    private SOAPElement innermostSubCodeElement = null;
    1.65 +
    1.66 +    public Fault1_2Impl(SOAPDocumentImpl ownerDoc, String name, String prefix) {
    1.67 +        super(ownerDoc, NameImpl.createFault1_2Name(name, prefix));
    1.68 +    }
    1.69 +
    1.70 +    public Fault1_2Impl(SOAPDocumentImpl ownerDocument, String prefix) {
    1.71 +        super(ownerDocument, NameImpl.createFault1_2Name(null, prefix));
    1.72 +    }
    1.73 +
    1.74 +    protected NameImpl getDetailName() {
    1.75 +        return NameImpl.createSOAP12Name("Detail", getPrefix());
    1.76 +    }
    1.77 +
    1.78 +    protected NameImpl getFaultCodeName() {
    1.79 +        return NameImpl.createSOAP12Name("Code", getPrefix());
    1.80 +    }
    1.81 +
    1.82 +    protected NameImpl getFaultStringName() {
    1.83 +        return getFaultReasonName();
    1.84 +    }
    1.85 +
    1.86 +    protected NameImpl getFaultActorName() {
    1.87 +        return getFaultRoleName();
    1.88 +    }
    1.89 +
    1.90 +    private  NameImpl getFaultRoleName() {
    1.91 +        return NameImpl.createSOAP12Name("Role", getPrefix());
    1.92 +    }
    1.93 +
    1.94 +    private  NameImpl getFaultReasonName() {
    1.95 +        return NameImpl.createSOAP12Name("Reason", getPrefix());
    1.96 +    }
    1.97 +
    1.98 +    private  NameImpl getFaultReasonTextName() {
    1.99 +        return NameImpl.createSOAP12Name("Text", getPrefix());
   1.100 +    }
   1.101 +
   1.102 +    private  NameImpl getFaultNodeName() {
   1.103 +        return NameImpl.createSOAP12Name("Node", getPrefix());
   1.104 +    }
   1.105 +
   1.106 +    private static NameImpl getXmlLangName() {
   1.107 +        return NameImpl.createXmlName("lang");
   1.108 +    }
   1.109 +
   1.110 +    protected DetailImpl createDetail() {
   1.111 +        return new Detail1_2Impl(
   1.112 +                       ((SOAPDocument) getOwnerDocument()).getDocument());
   1.113 +    }
   1.114 +
   1.115 +    protected FaultElementImpl createSOAPFaultElement(String localName) {
   1.116 +        return new FaultElement1_2Impl(
   1.117 +                       ((SOAPDocument) getOwnerDocument()).getDocument(),
   1.118 +                       localName);
   1.119 +    }
   1.120 +
   1.121 +    protected void checkIfStandardFaultCode(String faultCode, String uri)
   1.122 +        throws SOAPException {
   1.123 +        QName qname = new QName(uri, faultCode);
   1.124 +        if (SOAPConstants.SOAP_DATAENCODINGUNKNOWN_FAULT.equals(qname) ||
   1.125 +            SOAPConstants.SOAP_MUSTUNDERSTAND_FAULT.equals(qname) ||
   1.126 +            SOAPConstants.SOAP_RECEIVER_FAULT.equals(qname) ||
   1.127 +            SOAPConstants.SOAP_SENDER_FAULT.equals(qname) ||
   1.128 +            SOAPConstants.SOAP_VERSIONMISMATCH_FAULT.equals(qname))
   1.129 +            return;
   1.130 +        log.log(
   1.131 +            Level.SEVERE,
   1.132 +            "SAAJ0435.ver1_2.code.not.standard",
   1.133 +            qname);
   1.134 +        throw new SOAPExceptionImpl(qname + " is not a standard Code value");
   1.135 +    }
   1.136 +
   1.137 +    protected void finallySetFaultCode(String faultcode) throws SOAPException {
   1.138 +        SOAPElement value = this.faultCodeElement.addChildElement(valueName);
   1.139 +        value.addTextNode(faultcode);
   1.140 +    }
   1.141 +
   1.142 +    private void findReasonElement() {
   1.143 +        findFaultStringElement();
   1.144 +    }
   1.145 +
   1.146 +    public Iterator getFaultReasonTexts() throws SOAPException {
   1.147 +        // Fault Reason has similar semantics as faultstring
   1.148 +        if (this.faultStringElement == null)
   1.149 +            findReasonElement();
   1.150 +        Iterator eachTextElement =
   1.151 +            this.faultStringElement.getChildElements(textName);
   1.152 +        List texts = new ArrayList();
   1.153 +        while (eachTextElement.hasNext()) {
   1.154 +            SOAPElement textElement = (SOAPElement) eachTextElement.next();
   1.155 +            Locale thisLocale = getLocale(textElement);
   1.156 +            if (thisLocale == null) {
   1.157 +                log.severe("SAAJ0431.ver1_2.xml.lang.missing");
   1.158 +                throw new SOAPExceptionImpl("\"xml:lang\" attribute is not present on the Text element");
   1.159 +            }
   1.160 +            texts.add(textElement.getValue());
   1.161 +        }
   1.162 +        if (texts.isEmpty()) {
   1.163 +            log.severe("SAAJ0434.ver1_2.text.element.not.present");
   1.164 +            throw new SOAPExceptionImpl("env:Text must be present inside env:Reason");
   1.165 +        }
   1.166 +        return texts.iterator();
   1.167 +    }
   1.168 +
   1.169 +    public void addFaultReasonText(String text, java.util.Locale locale)
   1.170 +        throws SOAPException {
   1.171 +
   1.172 +        if (locale == null) {
   1.173 +            log.severe("SAAJ0430.ver1_2.locale.required");
   1.174 +            throw new SOAPException("locale is required and must not be null");
   1.175 +        }
   1.176 +
   1.177 +        // Fault Reason has similar semantics as faultstring
   1.178 +        if (this.faultStringElement == null)
   1.179 +            findReasonElement();
   1.180 +        SOAPElement reasonText;
   1.181 +
   1.182 +        if (this.faultStringElement == null) {
   1.183 +            this.faultStringElement = addSOAPFaultElement("Reason");
   1.184 +            reasonText =
   1.185 +                this.faultStringElement.addChildElement(
   1.186 +                    getFaultReasonTextName());
   1.187 +        } else {
   1.188 +            removeDefaultFaultString();
   1.189 +            reasonText = getFaultReasonTextElement(locale);
   1.190 +            if (reasonText != null) {
   1.191 +                reasonText.removeContents();
   1.192 +            } else {
   1.193 +                reasonText =
   1.194 +                    this.faultStringElement.addChildElement(
   1.195 +                        getFaultReasonTextName());
   1.196 +            }
   1.197 +        }
   1.198 +
   1.199 +        String xmlLang = localeToXmlLang(locale);
   1.200 +        reasonText.addAttribute(getXmlLangName(), xmlLang);
   1.201 +        reasonText.addTextNode(text);
   1.202 +    }
   1.203 +
   1.204 +    private void removeDefaultFaultString() throws SOAPException {
   1.205 +        SOAPElement reasonText = getFaultReasonTextElement(Locale.getDefault());
   1.206 +        if (reasonText != null) {
   1.207 +            String defaultFaultString =
   1.208 +                "Fault string, and possibly fault code, not set";
   1.209 +            if (defaultFaultString.equals(reasonText.getValue())) {
   1.210 +                reasonText.detachNode();
   1.211 +            }
   1.212 +        }
   1.213 +    }
   1.214 +
   1.215 +    public String getFaultReasonText(Locale locale) throws SOAPException {
   1.216 +
   1.217 +        if (locale == null)
   1.218 +            return null;
   1.219 +
   1.220 +        // Fault Reason has similar semantics as faultstring
   1.221 +        if (this.faultStringElement == null)
   1.222 +            findReasonElement();
   1.223 +
   1.224 +        if (this.faultStringElement != null) {
   1.225 +            SOAPElement textElement = getFaultReasonTextElement(locale);
   1.226 +            if (textElement != null) {
   1.227 +                textElement.normalize();
   1.228 +                return textElement.getFirstChild().getNodeValue();
   1.229 +            }
   1.230 +        }
   1.231 +
   1.232 +        return null;
   1.233 +    }
   1.234 +
   1.235 +    public Iterator getFaultReasonLocales() throws SOAPException {
   1.236 +        // Fault Reason has similar semantics as faultstring
   1.237 +        if (this.faultStringElement == null)
   1.238 +            findReasonElement();
   1.239 +        Iterator eachTextElement =
   1.240 +            this.faultStringElement.getChildElements(textName);
   1.241 +        List localeSet = new ArrayList();
   1.242 +        while (eachTextElement.hasNext()) {
   1.243 +            SOAPElement textElement = (SOAPElement) eachTextElement.next();
   1.244 +            Locale thisLocale = getLocale(textElement);
   1.245 +            if (thisLocale == null) {
   1.246 +                log.severe("SAAJ0431.ver1_2.xml.lang.missing");
   1.247 +                throw new SOAPExceptionImpl("\"xml:lang\" attribute is not present on the Text element");
   1.248 +            }
   1.249 +            localeSet.add(thisLocale);
   1.250 +        }
   1.251 +        if (localeSet.isEmpty()) {
   1.252 +            log.severe("SAAJ0434.ver1_2.text.element.not.present");
   1.253 +            throw new SOAPExceptionImpl("env:Text elements with mandatory xml:lang attributes must be present inside env:Reason");
   1.254 +        }
   1.255 +        return localeSet.iterator();
   1.256 +    }
   1.257 +
   1.258 +    public Locale getFaultStringLocale() {
   1.259 +        Locale locale = null;
   1.260 +        try {
   1.261 +            locale = (Locale) getFaultReasonLocales().next();
   1.262 +        } catch (SOAPException e) {}
   1.263 +        return locale;
   1.264 +    }
   1.265 +
   1.266 +    /*
   1.267 +     * This method assumes that locale and faultStringElement are non-null
   1.268 +     */
   1.269 +    private SOAPElement getFaultReasonTextElement(Locale locale)
   1.270 +        throws SOAPException {
   1.271 +
   1.272 +        // Fault Reason has similar semantics as faultstring
   1.273 +        Iterator eachTextElement =
   1.274 +            this.faultStringElement.getChildElements(textName);
   1.275 +        while (eachTextElement.hasNext()) {
   1.276 +            SOAPElement textElement = (SOAPElement) eachTextElement.next();
   1.277 +            Locale thisLocale = getLocale(textElement);
   1.278 +            if (thisLocale == null) {
   1.279 +                log.severe("SAAJ0431.ver1_2.xml.lang.missing");
   1.280 +                throw new SOAPExceptionImpl("\"xml:lang\" attribute is not present on the Text element");
   1.281 +            }
   1.282 +            if (thisLocale.equals(locale)) {
   1.283 +                return textElement;
   1.284 +            }
   1.285 +        }
   1.286 +        return null;
   1.287 +    }
   1.288 +
   1.289 +    public String getFaultNode() {
   1.290 +        SOAPElement faultNode = findChild(getFaultNodeName());
   1.291 +        if (faultNode == null) {
   1.292 +            return null;
   1.293 +        }
   1.294 +        return faultNode.getValue();
   1.295 +    }
   1.296 +
   1.297 +    public void setFaultNode(String uri) throws SOAPException {
   1.298 +        SOAPElement faultNode = findChild(getFaultNodeName());
   1.299 +        if (faultNode != null) {
   1.300 +            faultNode.detachNode();
   1.301 +        }
   1.302 +        faultNode = createSOAPFaultElement(getFaultNodeName());
   1.303 +        faultNode = faultNode.addTextNode(uri);
   1.304 +        if (getFaultRole() != null) {
   1.305 +            insertBefore(faultNode, this.faultActorElement);
   1.306 +            return;
   1.307 +        }
   1.308 +        if (hasDetail()) {
   1.309 +            insertBefore(faultNode, this.detail);
   1.310 +            return;
   1.311 +        }
   1.312 +        addNode(faultNode);
   1.313 +    }
   1.314 +
   1.315 +    public String getFaultRole() {
   1.316 +        return getFaultActor();
   1.317 +    }
   1.318 +
   1.319 +    public void setFaultRole(String uri) throws SOAPException {
   1.320 +        if (this.faultActorElement == null)
   1.321 +            findFaultActorElement();
   1.322 +        if (this.faultActorElement != null)
   1.323 +            this.faultActorElement.detachNode();
   1.324 +        this.faultActorElement =
   1.325 +            createSOAPFaultElement(getFaultActorName());
   1.326 +        this.faultActorElement.addTextNode(uri);
   1.327 +        if (hasDetail()) {
   1.328 +            insertBefore(this.faultActorElement, this.detail);
   1.329 +            return;
   1.330 +        }
   1.331 +        addNode(this.faultActorElement);
   1.332 +    }
   1.333 +
   1.334 +    public String getFaultCode() {
   1.335 +        if (this.faultCodeElement == null)
   1.336 +            findFaultCodeElement();
   1.337 +        Iterator codeValues =
   1.338 +            this.faultCodeElement.getChildElements(valueName);
   1.339 +        return ((SOAPElement) codeValues.next()).getValue();
   1.340 +    }
   1.341 +
   1.342 +    public QName getFaultCodeAsQName() {
   1.343 +        String faultcode = getFaultCode();
   1.344 +        if (faultcode == null) {
   1.345 +            return null;
   1.346 +        }
   1.347 +        if (this.faultCodeElement == null)
   1.348 +            findFaultCodeElement();
   1.349 +        Iterator valueElements =
   1.350 +            this.faultCodeElement.getChildElements(valueName);
   1.351 +        return convertCodeToQName(
   1.352 +            faultcode,
   1.353 +            (SOAPElement) valueElements.next());
   1.354 +    }
   1.355 +
   1.356 +    public Name getFaultCodeAsName() {
   1.357 +        String faultcode = getFaultCode();
   1.358 +        if (faultcode == null) {
   1.359 +            return null;
   1.360 +        }
   1.361 +        if (this.faultCodeElement == null)
   1.362 +            findFaultCodeElement();
   1.363 +        Iterator valueElements =
   1.364 +            this.faultCodeElement.getChildElements(valueName);
   1.365 +        return NameImpl.convertToName(
   1.366 +            convertCodeToQName(
   1.367 +                faultcode,
   1.368 +                (SOAPElement) valueElements.next()));
   1.369 +    }
   1.370 +
   1.371 +    public String getFaultString() {
   1.372 +        String reason = null;
   1.373 +        try {
   1.374 +            //reason = getFaultReasonText(Locale.getDefault());
   1.375 +            //if (reason == null)
   1.376 +            reason = (String) getFaultReasonTexts().next();
   1.377 +        } catch (SOAPException e) {}
   1.378 +        return reason;
   1.379 +    }
   1.380 +
   1.381 +    public void setFaultString(String faultString) throws SOAPException {
   1.382 +        addFaultReasonText(faultString, Locale.getDefault());
   1.383 +    }
   1.384 +
   1.385 +    public void setFaultString(
   1.386 +        String faultString,
   1.387 +        Locale locale)
   1.388 +        throws SOAPException {
   1.389 +        addFaultReasonText(faultString, locale);
   1.390 +    }
   1.391 +
   1.392 +    public void appendFaultSubcode(QName subcode) throws SOAPException {
   1.393 +        if (subcode == null) {
   1.394 +            return;
   1.395 +        }
   1.396 +        if (subcode.getNamespaceURI() == null ||
   1.397 +            "".equals(subcode.getNamespaceURI())) {
   1.398 +
   1.399 +            log.severe("SAAJ0432.ver1_2.subcode.not.ns.qualified");
   1.400 +            throw new SOAPExceptionImpl("A Subcode must be namespace-qualified");
   1.401 +        }
   1.402 +        if (innermostSubCodeElement == null) {
   1.403 +            if (faultCodeElement == null)
   1.404 +                findFaultCodeElement();
   1.405 +            innermostSubCodeElement = faultCodeElement;
   1.406 +        }
   1.407 +        String prefix = null;
   1.408 +        if (subcode.getPrefix() == null || "".equals(subcode.getPrefix())) {
   1.409 +            prefix =
   1.410 +                ((ElementImpl) innermostSubCodeElement).getNamespacePrefix(
   1.411 +                    subcode.getNamespaceURI());
   1.412 +        } else
   1.413 +            prefix = subcode.getPrefix();
   1.414 +        if (prefix == null || "".equals(prefix)) {
   1.415 +            prefix = "ns1";
   1.416 +        }
   1.417 +        innermostSubCodeElement =
   1.418 +            innermostSubCodeElement.addChildElement(subcodeName);
   1.419 +        SOAPElement subcodeValueElement =
   1.420 +            innermostSubCodeElement.addChildElement(valueName);
   1.421 +        ((ElementImpl) subcodeValueElement).ensureNamespaceIsDeclared(
   1.422 +            prefix,
   1.423 +            subcode.getNamespaceURI());
   1.424 +        subcodeValueElement.addTextNode(prefix + ":" + subcode.getLocalPart());
   1.425 +    }
   1.426 +
   1.427 +    public void removeAllFaultSubcodes() {
   1.428 +        if (this.faultCodeElement == null)
   1.429 +            findFaultCodeElement();
   1.430 +        Iterator subcodeElements =
   1.431 +            this.faultCodeElement.getChildElements(subcodeName);
   1.432 +        if (subcodeElements.hasNext()) {
   1.433 +            SOAPElement subcode = (SOAPElement) subcodeElements.next();
   1.434 +            subcode.detachNode();
   1.435 +        }
   1.436 +    }
   1.437 +
   1.438 +    public Iterator getFaultSubcodes() {
   1.439 +        if (this.faultCodeElement == null)
   1.440 +            findFaultCodeElement();
   1.441 +        final List subcodeList = new ArrayList();
   1.442 +        SOAPElement currentCodeElement = this.faultCodeElement;
   1.443 +        Iterator subcodeElements =
   1.444 +            currentCodeElement.getChildElements(subcodeName);
   1.445 +        while (subcodeElements.hasNext()) {
   1.446 +            currentCodeElement = (ElementImpl) subcodeElements.next();
   1.447 +            Iterator valueElements =
   1.448 +                currentCodeElement.getChildElements(valueName);
   1.449 +            SOAPElement valueElement = (SOAPElement) valueElements.next();
   1.450 +            String code = valueElement.getValue();
   1.451 +            subcodeList.add(convertCodeToQName(code, valueElement));
   1.452 +            subcodeElements = currentCodeElement.getChildElements(subcodeName);
   1.453 +        }
   1.454 +        //return subcodeList.iterator();
   1.455 +        return new Iterator() {
   1.456 +            Iterator subCodeIter = subcodeList.iterator();
   1.457 +
   1.458 +            public boolean hasNext() {
   1.459 +                return subCodeIter.hasNext();
   1.460 +            }
   1.461 +
   1.462 +            public Object next() {
   1.463 +                return subCodeIter.next();
   1.464 +            }
   1.465 +
   1.466 +            public void remove() {
   1.467 +                throw new UnsupportedOperationException(
   1.468 +                    "Method remove() not supported on SubCodes Iterator");
   1.469 +            }
   1.470 +        };
   1.471 +    }
   1.472 +
   1.473 +    private static Locale getLocale(SOAPElement reasonText) {
   1.474 +        return xmlLangToLocale(reasonText.getAttributeValue(getXmlLangName()));
   1.475 +    }
   1.476 +
   1.477 +    /*
   1.478 +     * Override setEncodingStyle of ElementImpl to restrict adding encodingStyle
   1.479 +     * attribute to SOAP Fault (SOAP 1.2 spec, part 1, section 5.1.1)
   1.480 +     */
   1.481 +    public void setEncodingStyle(String encodingStyle) throws SOAPException {
   1.482 +        log.severe("SAAJ0407.ver1_2.no.encodingStyle.in.fault");
   1.483 +        throw new SOAPExceptionImpl("encodingStyle attribute cannot appear on Fault");
   1.484 +    }
   1.485 +
   1.486 +    public SOAPElement addAttribute(Name name, String value)
   1.487 +        throws SOAPException {
   1.488 +        if (name.getLocalName().equals("encodingStyle")
   1.489 +            && name.getURI().equals(NameImpl.SOAP12_NAMESPACE)) {
   1.490 +            setEncodingStyle(value);
   1.491 +        }
   1.492 +        return super.addAttribute(name, value);
   1.493 +    }
   1.494 +
   1.495 +    public SOAPElement addAttribute(QName name, String value)
   1.496 +        throws SOAPException {
   1.497 +        if (name.getLocalPart().equals("encodingStyle")
   1.498 +            && name.getNamespaceURI().equals(NameImpl.SOAP12_NAMESPACE)) {
   1.499 +            setEncodingStyle(value);
   1.500 +        }
   1.501 +        return super.addAttribute(name, value);
   1.502 +    }
   1.503 +
   1.504 +    public SOAPElement addTextNode(String text) throws SOAPException {
   1.505 +        log.log(
   1.506 +            Level.SEVERE,
   1.507 +            "SAAJ0416.ver1_2.adding.text.not.legal",
   1.508 +            getElementQName());
   1.509 +        throw new SOAPExceptionImpl("Adding text to SOAP 1.2 Fault is not legal");
   1.510 +    }
   1.511 +
   1.512 +    public SOAPElement addChildElement(SOAPElement element)
   1.513 +        throws SOAPException {
   1.514 +        String localName = element.getLocalName();
   1.515 +        if ("Detail".equalsIgnoreCase(localName)) {
   1.516 +            if (hasDetail()) {
   1.517 +                log.severe("SAAJ0436.ver1_2.detail.exists.error");
   1.518 +                throw new SOAPExceptionImpl("Cannot add Detail, Detail already exists");
   1.519 +            }
   1.520 +            String uri = element.getElementQName().getNamespaceURI();
   1.521 +            if (!uri.equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
   1.522 +                log.severe("SAAJ0437.ver1_2.version.mismatch.error");
   1.523 +                throw new SOAPExceptionImpl("Cannot add Detail, Incorrect SOAP version specified for Detail element");
   1.524 +            }
   1.525 +        }
   1.526 +        if (element instanceof Detail1_2Impl) {
   1.527 +            ElementImpl importedElement = (ElementImpl) importElement(element);
   1.528 +            addNode(importedElement);
   1.529 +            return convertToSoapElement(importedElement);
   1.530 +        } else
   1.531 +            return super.addChildElement(element);
   1.532 +    }
   1.533 +
   1.534 +    protected boolean isStandardFaultElement(String localName) {
   1.535 +        if (localName.equalsIgnoreCase("code") ||
   1.536 +            localName.equalsIgnoreCase("reason") ||
   1.537 +            localName.equalsIgnoreCase("node") ||
   1.538 +            localName.equalsIgnoreCase("role") ||
   1.539 +            localName.equalsIgnoreCase("detail")) {
   1.540 +            return true;
   1.541 +        }
   1.542 +        return false;
   1.543 +    }
   1.544 +
   1.545 +    protected QName getDefaultFaultCode() {
   1.546 +        return SOAPConstants.SOAP_SENDER_FAULT;
   1.547 +    }
   1.548 +
   1.549 +     protected FaultElementImpl createSOAPFaultElement(QName qname) {
   1.550 +         return new FaultElement1_2Impl(
   1.551 +                       ((SOAPDocument) getOwnerDocument()).getDocument(),
   1.552 +                       qname);
   1.553 +    }
   1.554 +
   1.555 +    protected FaultElementImpl createSOAPFaultElement(Name qname) {
   1.556 +         return new FaultElement1_2Impl(
   1.557 +                       ((SOAPDocument) getOwnerDocument()).getDocument(),
   1.558 +                       (NameImpl)qname);
   1.559 +    }
   1.560 +
   1.561 +     public void setFaultActor(String faultActor) throws SOAPException {
   1.562 +        this.setFaultRole(faultActor);
   1.563 +    }
   1.564 +
   1.565 +}

mercurial