KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > soap > SoapFault


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.servicemix.soap;
18
19 import java.net.URI JavaDoc;
20
21 import javax.xml.namespace.QName JavaDoc;
22 import javax.xml.transform.Source JavaDoc;
23
24 import org.apache.servicemix.soap.marshalers.SoapMarshaler;
25
26 /**
27  * Represents a SOAP fault which occurred while processing the
28  * message.
29  *
30  * @author Guillaume Nodet
31  * @version $Revision: 1.5 $
32  * @since 3.0
33  */

34 public class SoapFault extends Exception JavaDoc {
35     
36     private static final long serialVersionUID = 984561453557136677L;
37     
38     public static final QName JavaDoc SENDER = SoapMarshaler.SOAP_12_CODE_SENDER;
39     public static final QName JavaDoc RECEIVER = SoapMarshaler.SOAP_12_CODE_RECEIVER;
40     
41     private QName JavaDoc code;
42     private QName JavaDoc subcode;
43     private String JavaDoc reason;
44     private URI JavaDoc node;
45     private URI JavaDoc role;
46     private Source JavaDoc details;
47
48     public SoapFault(Exception JavaDoc cause) {
49         super(cause);
50     }
51
52     public SoapFault(QName JavaDoc code, String JavaDoc reason) {
53         super(reason);
54         this.code = code;
55         this.reason = reason;
56     }
57
58     public SoapFault(QName JavaDoc code, QName JavaDoc subcode, String JavaDoc reason) {
59         super(reason);
60         this.code = code;
61         this.subcode = subcode;
62         this.reason = reason;
63     }
64
65     public SoapFault(QName JavaDoc code, String JavaDoc reason, URI JavaDoc node, URI JavaDoc role) {
66         super(reason);
67         this.code = code;
68         this.reason = reason;
69         this.node = node;
70         this.role = role;
71     }
72
73     public SoapFault(QName JavaDoc code, String JavaDoc reason, URI JavaDoc node, URI JavaDoc role, Source JavaDoc details) {
74         super(reason);
75         this.code = code;
76         this.reason = reason;
77         this.node = node;
78         this.role = role;
79         this.details = details;
80     }
81
82     public SoapFault(QName JavaDoc code, QName JavaDoc subcode, String JavaDoc reason, URI JavaDoc node, URI JavaDoc role, Source JavaDoc details) {
83         super(reason);
84         this.code = code;
85         this.subcode = subcode;
86         this.reason = reason;
87         this.node = node;
88         this.role = role;
89         this.details = details;
90     }
91
92     public QName JavaDoc getCode() {
93         return code;
94     }
95
96     public QName JavaDoc getSubcode() {
97         return subcode;
98     }
99
100     public String JavaDoc getReason() {
101         return reason;
102     }
103
104     public URI JavaDoc getNode() {
105         return node;
106     }
107
108     public URI JavaDoc getRole() {
109         return role;
110     }
111
112     public Source JavaDoc getDetails() {
113         return details;
114     }
115
116     public void translateCodeTo11() {
117         if (code != null) {
118             if (subcode != null) {
119                 code = subcode;
120                 subcode = null;
121             } else if (SoapMarshaler.SOAP_12_CODE_DATAENCODINGUNKNOWN.equals(code)) {
122                 code = SoapMarshaler.SOAP_11_CODE_CLIENT;
123             } else if (SoapMarshaler.SOAP_12_CODE_MUSTUNDERSTAND.equals(code)) {
124                 code = SoapMarshaler.SOAP_11_CODE_MUSTUNDERSTAND;
125             } else if (SoapMarshaler.SOAP_12_CODE_RECEIVER.equals(code)) {
126                 code = SoapMarshaler.SOAP_11_CODE_SERVER;
127             } else if (SoapMarshaler.SOAP_12_CODE_SENDER.equals(code)) {
128                 code = SoapMarshaler.SOAP_11_CODE_CLIENT;
129             }
130         } else {
131             code = SoapMarshaler.SOAP_11_CODE_SERVER;
132         }
133     }
134
135     public void translateCodeTo12() {
136         if (code != null && subcode == null) {
137             if (SoapMarshaler.SOAP_11_CODE_CLIENT.equals(code)) {
138                 code = SoapMarshaler.SOAP_12_CODE_SENDER;
139             } else if (SoapMarshaler.SOAP_11_CODE_MUSTUNDERSTAND.equals(code)) {
140                 code = SoapMarshaler.SOAP_12_CODE_MUSTUNDERSTAND;
141             } else if (SoapMarshaler.SOAP_11_CODE_SERVER.equals(code)) {
142                 code = SoapMarshaler.SOAP_12_CODE_RECEIVER;
143             } else if (SoapMarshaler.SOAP_11_CODE_VERSIONMISMATCH.equals(code)) {
144                 code = SoapMarshaler.SOAP_12_CODE_VERSIONMISMATCH;
145             } else {
146                 subcode = code;
147                 code = SoapMarshaler.SOAP_12_CODE_SENDER;
148             }
149         } else if (code == null) {
150             code = SoapMarshaler.SOAP_12_CODE_RECEIVER;
151         }
152     }
153 }
154
Popular Tags