01: /*
02: * Copyright 2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.ws.soap.axiom;
18:
19: import java.util.Locale;
20: import javax.xml.namespace.QName;
21:
22: import org.apache.axiom.om.OMAttribute;
23: import org.apache.axiom.soap.SOAPFactory;
24: import org.apache.axiom.soap.SOAPFault;
25: import org.springframework.ws.soap.axiom.support.AxiomUtils;
26: import org.springframework.ws.soap.soap11.Soap11Fault;
27:
28: /**
29: * Axiom-specific version of <code>org.springframework.ws.soap.Soap11Fault</code>.
30: *
31: * @author Arjen Poutsma
32: * @since 1.0.0
33: */
34: class AxiomSoap11Fault extends AxiomSoapFault implements Soap11Fault {
35:
36: AxiomSoap11Fault(SOAPFault axiomFault, SOAPFactory axiomFactory) {
37: super (axiomFault, axiomFactory);
38: }
39:
40: public QName getFaultCode() {
41: return getAxiomFault().getCode().getTextAsQName();
42: }
43:
44: public String getFaultStringOrReason() {
45: if (getAxiomFault().getReason() != null) {
46: return getAxiomFault().getReason().getText();
47: }
48: return null;
49: }
50:
51: public Locale getFaultStringLocale() {
52: if (getAxiomFault().getReason() != null) {
53: OMAttribute langAttribute = getAxiomFault()
54: .getReason()
55: .getAttribute(
56: new QName(
57: "http://www.w3.org/XML/1998/namespace",
58: "lang"));
59: if (langAttribute != null) {
60: String xmlLangString = langAttribute
61: .getAttributeValue();
62: if (xmlLangString != null) {
63: return AxiomUtils.toLocale(xmlLangString);
64: }
65:
66: }
67: }
68: return null;
69: }
70:
71: }
|