1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
25
26 /**
27 *
28 * @author SAAJ RI Development Team
29 */
30 package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
31
32 import java.util.*;
33 import java.util.logging.Logger;
34 import java.util.logging.Level;
35
36 import javax.xml.namespace.QName;
37 import javax.xml.soap.*;
38
39 import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
40 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
41 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
42 import com.sun.xml.internal.messaging.saaj.soap.impl.*;
43 import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
44 import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
45
46
47 public class Fault1_2Impl extends FaultImpl {
48
49 protected static final Logger log =
50 Logger.getLogger(
51 LogDomainConstants.SOAP_VER1_2_DOMAIN,
52 "com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
53
54 private static final QName textName =
55 new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Text");
56 private final QName valueName =
57 new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Value", getPrefix());
58 private final QName subcodeName =
59 new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Subcode", getPrefix());
60
61 private SOAPElement innermostSubCodeElement = null;
62
63 public Fault1_2Impl(SOAPDocumentImpl ownerDoc, String name, String prefix) {
64 super(ownerDoc, NameImpl.createFault1_2Name(name, prefix));
65 }
66
67 public Fault1_2Impl(SOAPDocumentImpl ownerDocument, String prefix) {
68 super(ownerDocument, NameImpl.createFault1_2Name(null, prefix));
69 }
70
71 protected NameImpl getDetailName() {
72 return NameImpl.createSOAP12Name("Detail", getPrefix());
73 }
74
75 protected NameImpl getFaultCodeName() {
76 return NameImpl.createSOAP12Name("Code", getPrefix());
77 }
78
79 protected NameImpl getFaultStringName() {
80 return getFaultReasonName();
81 }
82
83 protected NameImpl getFaultActorName() {
84 return getFaultRoleName();
85 }
86
87 private NameImpl getFaultRoleName() {
88 return NameImpl.createSOAP12Name("Role", getPrefix());
89 }
90
504 "SAAJ0416.ver1_2.adding.text.not.legal",
505 getElementQName());
506 throw new SOAPExceptionImpl("Adding text to SOAP 1.2 Fault is not legal");
507 }
508
509 public SOAPElement addChildElement(SOAPElement element)
510 throws SOAPException {
511 String localName = element.getLocalName();
512 if ("Detail".equalsIgnoreCase(localName)) {
513 if (hasDetail()) {
514 log.severe("SAAJ0436.ver1_2.detail.exists.error");
515 throw new SOAPExceptionImpl("Cannot add Detail, Detail already exists");
516 }
517 String uri = element.getElementQName().getNamespaceURI();
518 if (!uri.equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
519 log.severe("SAAJ0437.ver1_2.version.mismatch.error");
520 throw new SOAPExceptionImpl("Cannot add Detail, Incorrect SOAP version specified for Detail element");
521 }
522 }
523 if (element instanceof Detail1_2Impl) {
524 ElementImpl importedElement = (ElementImpl) importElement(element);
525 addNode(importedElement);
526 return convertToSoapElement(importedElement);
527 } else
528 return super.addChildElement(element);
529 }
530
531 protected boolean isStandardFaultElement(String localName) {
532 if (localName.equalsIgnoreCase("code") ||
533 localName.equalsIgnoreCase("reason") ||
534 localName.equalsIgnoreCase("node") ||
535 localName.equalsIgnoreCase("role") ||
536 localName.equalsIgnoreCase("detail")) {
537 return true;
538 }
539 return false;
540 }
541
542 protected QName getDefaultFaultCode() {
543 return SOAPConstants.SOAP_SENDER_FAULT;
544 }
|
1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
25
26 /**
27 *
28 * @author SAAJ RI Development Team
29 */
30 package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
31
32 import java.util.*;
33 import java.util.logging.Logger;
34 import java.util.logging.Level;
35
36 import javax.xml.namespace.QName;
37 import javax.xml.soap.*;
38
39 import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
40 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
41 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
42 import com.sun.xml.internal.messaging.saaj.soap.impl.*;
43 import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
44 import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
45 import org.w3c.dom.Element;
46
47
48 public class Fault1_2Impl extends FaultImpl {
49
50 protected static final Logger log =
51 Logger.getLogger(
52 LogDomainConstants.SOAP_VER1_2_DOMAIN,
53 "com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
54
55 private static final QName textName =
56 new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Text");
57 private final QName valueName =
58 new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Value", getPrefix());
59 private final QName subcodeName =
60 new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Subcode", getPrefix());
61
62 private SOAPElement innermostSubCodeElement = null;
63
64 public Fault1_2Impl(SOAPDocumentImpl ownerDoc, String name, String prefix) {
65 super(ownerDoc, NameImpl.createFault1_2Name(name, prefix));
66 }
67
68 public Fault1_2Impl(SOAPDocumentImpl ownerDocument, String prefix) {
69 super(ownerDocument, NameImpl.createFault1_2Name(null, prefix));
70 }
71
72 public Fault1_2Impl(Element domElement, SOAPDocumentImpl ownerDoc) {
73 super(ownerDoc, domElement);
74 }
75
76 protected NameImpl getDetailName() {
77 return NameImpl.createSOAP12Name("Detail", getPrefix());
78 }
79
80 protected NameImpl getFaultCodeName() {
81 return NameImpl.createSOAP12Name("Code", getPrefix());
82 }
83
84 protected NameImpl getFaultStringName() {
85 return getFaultReasonName();
86 }
87
88 protected NameImpl getFaultActorName() {
89 return getFaultRoleName();
90 }
91
92 private NameImpl getFaultRoleName() {
93 return NameImpl.createSOAP12Name("Role", getPrefix());
94 }
95
509 "SAAJ0416.ver1_2.adding.text.not.legal",
510 getElementQName());
511 throw new SOAPExceptionImpl("Adding text to SOAP 1.2 Fault is not legal");
512 }
513
514 public SOAPElement addChildElement(SOAPElement element)
515 throws SOAPException {
516 String localName = element.getLocalName();
517 if ("Detail".equalsIgnoreCase(localName)) {
518 if (hasDetail()) {
519 log.severe("SAAJ0436.ver1_2.detail.exists.error");
520 throw new SOAPExceptionImpl("Cannot add Detail, Detail already exists");
521 }
522 String uri = element.getElementQName().getNamespaceURI();
523 if (!uri.equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
524 log.severe("SAAJ0437.ver1_2.version.mismatch.error");
525 throw new SOAPExceptionImpl("Cannot add Detail, Incorrect SOAP version specified for Detail element");
526 }
527 }
528 if (element instanceof Detail1_2Impl) {
529 Element importedElement = importElement(element);
530 addNode(importedElement);
531 return convertToSoapElement(importedElement);
532 } else
533 return super.addChildElement(element);
534 }
535
536 protected boolean isStandardFaultElement(String localName) {
537 if (localName.equalsIgnoreCase("code") ||
538 localName.equalsIgnoreCase("reason") ||
539 localName.equalsIgnoreCase("node") ||
540 localName.equalsIgnoreCase("role") ||
541 localName.equalsIgnoreCase("detail")) {
542 return true;
543 }
544 return false;
545 }
546
547 protected QName getDefaultFaultCode() {
548 return SOAPConstants.SOAP_SENDER_FAULT;
549 }
|