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.saaj;
18  
19  import javax.xml.namespace.QName;
20  import javax.xml.soap.Detail;
21  import javax.xml.soap.SOAPException;
22  import javax.xml.soap.SOAPFault;
23  
24  import org.springframework.ws.soap.SoapFault;
25  import org.springframework.ws.soap.SoapFaultDetail;
26  
27  /**
28   * SAAJ-specific abstract base class of the <code>SoapFault</code> interface. Wraps a {@link javax.xml.soap.SOAPFault}.
29   *
30   * @author Arjen Poutsma
31   * @since 1.0.0
32   */
33  abstract class SaajSoapFault extends SaajSoapElement implements SoapFault {
34  
35      protected SaajSoapFault(SOAPFault fault) {
36          super(fault);
37      }
38  
39      public QName getFaultCode() {
40          return getImplementation().getFaultCode(getSaajFault());
41      }
42  
43      protected SOAPFault getSaajFault() {
44          return (SOAPFault) getSaajElement();
45      }
46  
47      public SoapFaultDetail getFaultDetail() {
48          Detail saajDetail = getImplementation().getFaultDetail(getSaajFault());
49          return saajDetail == null ? null : new SaajSoapFaultDetail(saajDetail);
50      }
51  
52      public SoapFaultDetail addFaultDetail() {
53          try {
54              Detail saajDetail = getImplementation().addFaultDetail(getSaajFault());
55              return new SaajSoapFaultDetail(saajDetail);
56          }
57          catch (SOAPException ex) {
58              throw new SaajSoapFaultException(ex);
59          }
60      }
61  }