View Javadoc

1   /*
2    * Copyright 2006 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
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 =
54                      getAxiomFault().getReason().getAttribute(new QName("http://www.w3.org/XML/1998/namespace", "lang"));
55              if (langAttribute != null) {
56                  String xmlLangString = langAttribute.getAttributeValue();
57                  if (xmlLangString != null) {
58                      return AxiomUtils.toLocale(xmlLangString);
59                  }
60  
61              }
62          }
63          return null;
64      }
65  
66  }