001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.servicemix.soap;
018:
019: import java.net.URI;
020:
021: import javax.xml.namespace.QName;
022: import javax.xml.transform.Source;
023:
024: import org.apache.servicemix.soap.marshalers.SoapMarshaler;
025:
026: /**
027: * Represents a SOAP fault which occurred while processing the
028: * message.
029: *
030: * @author Guillaume Nodet
031: * @version $Revision: 1.5 $
032: * @since 3.0
033: */
034: public class SoapFault extends Exception {
035:
036: private static final long serialVersionUID = 984561453557136677L;
037:
038: public static final QName SENDER = SoapMarshaler.SOAP_12_CODE_SENDER;
039: public static final QName RECEIVER = SoapMarshaler.SOAP_12_CODE_RECEIVER;
040:
041: private QName code;
042: private QName subcode;
043: private String reason;
044: private URI node;
045: private URI role;
046: private Source details;
047:
048: public SoapFault(Exception cause) {
049: super (cause);
050: }
051:
052: public SoapFault(QName code, String reason) {
053: super (reason);
054: this .code = code;
055: this .reason = reason;
056: }
057:
058: public SoapFault(QName code, QName subcode, String reason) {
059: super (reason);
060: this .code = code;
061: this .subcode = subcode;
062: this .reason = reason;
063: }
064:
065: public SoapFault(QName code, String reason, URI node, URI role) {
066: super (reason);
067: this .code = code;
068: this .reason = reason;
069: this .node = node;
070: this .role = role;
071: }
072:
073: public SoapFault(QName code, String reason, URI node, URI role,
074: Source details) {
075: super (reason);
076: this .code = code;
077: this .reason = reason;
078: this .node = node;
079: this .role = role;
080: this .details = details;
081: }
082:
083: public SoapFault(QName code, QName subcode, String reason,
084: URI node, URI role, Source details) {
085: super (reason);
086: this .code = code;
087: this .subcode = subcode;
088: this .reason = reason;
089: this .node = node;
090: this .role = role;
091: this .details = details;
092: }
093:
094: public QName getCode() {
095: return code;
096: }
097:
098: public QName getSubcode() {
099: return subcode;
100: }
101:
102: public String getReason() {
103: return reason;
104: }
105:
106: public URI getNode() {
107: return node;
108: }
109:
110: public URI getRole() {
111: return role;
112: }
113:
114: public Source getDetails() {
115: return details;
116: }
117:
118: public void translateCodeTo11() {
119: if (code != null) {
120: if (subcode != null) {
121: code = subcode;
122: subcode = null;
123: } else if (SoapMarshaler.SOAP_12_CODE_DATAENCODINGUNKNOWN
124: .equals(code)) {
125: code = SoapMarshaler.SOAP_11_CODE_CLIENT;
126: } else if (SoapMarshaler.SOAP_12_CODE_MUSTUNDERSTAND
127: .equals(code)) {
128: code = SoapMarshaler.SOAP_11_CODE_MUSTUNDERSTAND;
129: } else if (SoapMarshaler.SOAP_12_CODE_RECEIVER.equals(code)) {
130: code = SoapMarshaler.SOAP_11_CODE_SERVER;
131: } else if (SoapMarshaler.SOAP_12_CODE_SENDER.equals(code)) {
132: code = SoapMarshaler.SOAP_11_CODE_CLIENT;
133: }
134: } else {
135: code = SoapMarshaler.SOAP_11_CODE_SERVER;
136: }
137: }
138:
139: public void translateCodeTo12() {
140: if (code != null && subcode == null) {
141: if (SoapMarshaler.SOAP_11_CODE_CLIENT.equals(code)) {
142: code = SoapMarshaler.SOAP_12_CODE_SENDER;
143: } else if (SoapMarshaler.SOAP_11_CODE_MUSTUNDERSTAND
144: .equals(code)) {
145: code = SoapMarshaler.SOAP_12_CODE_MUSTUNDERSTAND;
146: } else if (SoapMarshaler.SOAP_11_CODE_SERVER.equals(code)) {
147: code = SoapMarshaler.SOAP_12_CODE_RECEIVER;
148: } else if (SoapMarshaler.SOAP_11_CODE_VERSIONMISMATCH
149: .equals(code)) {
150: code = SoapMarshaler.SOAP_12_CODE_VERSIONMISMATCH;
151: } else {
152: subcode = code;
153: code = SoapMarshaler.SOAP_12_CODE_SENDER;
154: }
155: } else if (code == null) {
156: code = SoapMarshaler.SOAP_12_CODE_RECEIVER;
157: }
158: }
159: }
|