This project has retired. For details please refer to its Attic page.
DispositionReportFaultMessage xref
View Javadoc
1   /*
2    * Copyright 2001-2008 The Apache Software Foundation.
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  
18  
19  package org.uddi.v3_service;
20  
21  import java.lang.reflect.InvocationTargetException;
22  import java.lang.reflect.UndeclaredThrowableException;
23  import java.rmi.RemoteException;
24  
25  import javax.xml.bind.JAXBException;
26  import javax.xml.soap.Detail;
27  import javax.xml.ws.WebFault;
28  import javax.xml.ws.soap.SOAPFaultException;
29  
30  import org.apache.commons.logging.Log;
31  import org.apache.commons.logging.LogFactory;
32  import org.uddi.api_v3.DispositionReport;
33  import org.uddi.api_v3.ErrInfo;
34  import org.uddi.api_v3.Result;
35  
36  
37  /**
38   * This class was generated by the JAX-WS RI.
39   * JAX-WS RI 2.1.5-b03-
40   * Generated source version: 2.1
41   * 
42   */
43  @WebFault(name = "dispositionReport", targetNamespace = "urn:uddi-org:api_v3")
44  public class DispositionReportFaultMessage
45      extends RemoteException
46  {
47  	private static final long serialVersionUID = -3901821587689888649L;
48  	private static transient Log log = LogFactory.getLog(DispositionReportFaultMessage.class);
49  	/**
50       * Java type that goes as soapenv:Fault detail element.
51       * 
52       */
53      private DispositionReport faultInfo;
54  
55      /**
56       * 
57       * @param message
58       * @param faultInfo
59       */
60      public DispositionReportFaultMessage(String message, DispositionReport faultInfo) {
61          super(message);
62          this.faultInfo = faultInfo;
63      }
64  
65      /**
66       * 
67       * @param message
68       * @param faultInfo
69       * @param cause
70       */
71      public DispositionReportFaultMessage(String message, DispositionReport faultInfo, Throwable cause) {
72          super(message, cause);
73          this.faultInfo = faultInfo;
74      }
75  
76      /**
77       * 
78       * @return
79       *     returns fault bean: org.uddi.api_v3.DispositionReport
80       */
81      public DispositionReport getFaultInfo() {
82          return faultInfo;
83      }
84      
85      /** 
86       * Convenience method to figure out if the Exception at hand contains a
87       * DispositionReport. Disposition report will be null if none can be found.
88       * 
89       * @param e the Exception at hang
90       * @return DispositionReport if one can be found, or null if it is not.
91       */
92      public static DispositionReport getDispositionReport(Exception e) {
93      	DispositionReport report = null;
94      	if (e instanceof DispositionReportFaultMessage) {
95      		DispositionReportFaultMessage faultMsg = (DispositionReportFaultMessage) e;
96      		report = faultMsg.getFaultInfo();
97      	} else if (e instanceof SOAPFaultException) {
98      		SOAPFaultException soapFault = (SOAPFaultException) e;
99      		Detail detail = soapFault.getFault().getDetail();
100     		if (detail != null && detail.getFirstChild()!=null) {
101     			try {
102     				report =  new DispositionReport(detail.getFirstChild());
103     			} catch (JAXBException je) {
104     				log.error("Could not unmarshall detail to a DispositionReport");
105     			}
106     		}
107     	} else if (e instanceof UndeclaredThrowableException) {
108     		UndeclaredThrowableException ute =(UndeclaredThrowableException) e;
109     		if (ute.getUndeclaredThrowable()!=null && ute.getUndeclaredThrowable().getCause()!=null
110     		    && ute.getUndeclaredThrowable().getCause().getCause() instanceof DispositionReportFaultMessage) {
111     			DispositionReportFaultMessage faultMsg = (DispositionReportFaultMessage) ute.getUndeclaredThrowable().getCause().getCause();
112 	    		report = faultMsg.getFaultInfo();
113     		}
114     	} else if (e instanceof InvocationTargetException){
115           //https://issues.apache.org/jira/browse/JUDDI-965
116           log.error("InvocationTargetException: It's not a known instance of DispositionReport. Target: ",((InvocationTargetException)e).getTargetException());
117      } else{
118     		log.error("Unsupported Exception: It's not a known instance of DispositionReport. ",e);
119           
120     	}
121     	return report;
122     }
123 }