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 org.apache.axiom.om.OMException;
20  import org.apache.axiom.soap.SOAPFactory;
21  import org.apache.axiom.soap.SOAPFault;
22  import org.apache.axiom.soap.SOAPFaultDetail;
23  import org.apache.axiom.soap.SOAPFaultRole;
24  import org.apache.axiom.soap.SOAPProcessingException;
25  import org.springframework.ws.soap.SoapFault;
26  import org.springframework.ws.soap.SoapFaultDetail;
27  
28  /** @author Arjen Poutsma */
29  abstract class AxiomSoapFault extends AxiomSoapElement implements SoapFault {
30  
31      protected AxiomSoapFault(SOAPFault axiomFault, SOAPFactory axiomFactory) {
32          super(axiomFault, axiomFactory);
33      }
34  
35      public String getFaultActorOrRole() {
36          SOAPFaultRole faultRole = getAxiomFault().getRole();
37          return faultRole != null ? faultRole.getRoleValue() : null;
38      }
39  
40      public void setFaultActorOrRole(String actor) {
41          try {
42              SOAPFaultRole axiomFaultRole = getAxiomFactory().createSOAPFaultRole(getAxiomFault());
43              axiomFaultRole.setRoleValue(actor);
44          }
45          catch (SOAPProcessingException ex) {
46              throw new AxiomSoapFaultException(ex);
47          }
48  
49      }
50  
51      public SoapFaultDetail getFaultDetail() {
52          try {
53              SOAPFaultDetail axiomFaultDetail = getAxiomFault().getDetail();
54              return axiomFaultDetail != null ? new AxiomSoapFaultDetail(axiomFaultDetail, getAxiomFactory()) : null;
55          }
56          catch (OMException ex) {
57              throw new AxiomSoapFaultException(ex);
58          }
59  
60      }
61  
62      public SoapFaultDetail addFaultDetail() {
63          try {
64              SOAPFaultDetail axiomFaultDetail = getAxiomFactory().createSOAPFaultDetail(getAxiomFault());
65              return new AxiomSoapFaultDetail(axiomFaultDetail, getAxiomFactory());
66          }
67          catch (OMException ex) {
68              throw new AxiomSoapFaultException(ex);
69          }
70  
71      }
72  
73      protected SOAPFault getAxiomFault() {
74          return (SOAPFault) getAxiomElement();
75      }
76  
77  }