Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 81121 invoked from network); 18 Nov 2005 16:04:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Nov 2005 16:04:35 -0000 Received: (qmail 56159 invoked by uid 500); 18 Nov 2005 16:04:34 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 56086 invoked by uid 500); 18 Nov 2005 16:04:34 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 56072 invoked by uid 500); 18 Nov 2005 16:04:34 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 56068 invoked by uid 99); 18 Nov 2005 16:04:33 -0000 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 18 Nov 2005 08:04:33 -0800 Received: (qmail 80851 invoked by uid 65534); 18 Nov 2005 16:04:13 -0000 Message-ID: <20051118160413.80845.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r345511 - /webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/AxisFault.java Date: Fri, 18 Nov 2005 16:04:11 -0000 To: axis2-cvs@ws.apache.org From: stevel@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: stevel Date: Fri Nov 18 08:04:04 2005 New Revision: 345511 URL: http://svn.apache.org/viewcvs?rev=345511&view=rev Log: moving to new model Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/AxisFault.java Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/AxisFault.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/AxisFault.java?rev=345511&r1=345510&r2=345511&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/AxisFault.java (original) +++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/AxisFault.java Fri Nov 18 08:04:04 2005 @@ -16,12 +16,28 @@ package org.apache.axis2; +import org.apache.axis2.fault.FaultCode; +import org.apache.axis2.fault.FaultReasonList; +import org.apache.axis2.om.OMElement; +import org.apache.axis2.soap.SOAPFault; +import org.apache.axis2.soap.SOAPFaultCode; +import org.apache.axis2.soap.SOAPHeader; + +import javax.xml.namespace.QName; import java.lang.reflect.InvocationTargetException; import java.rmi.RemoteException; +import java.util.ArrayList; +import java.util.List; +import java.util.ListIterator; /** * An exception which maps cleanly to a SOAP fault. * This is a base class for exceptions which are mapped to faults. + * + * @see + * SOAP1.2 specification + * @see SOAP1.1 Faults + * SOAP faults contain *
    *
  1. A fault string @@ -29,30 +45,128 @@ *
  2. A fault actor *
  3. Fault details; an xml tree of fault specific elements *
+ * + * As SOAP1.2 faults are a superset of SOAP1.1 faults, this type holds soap1.2 fault information. When + * a SOAP1.1 fault is created, spurious information can be discarded. + * Mapping + *
+ * SOAP1.2              SOAP1.1
+ * node                 faultactor
+ * reason(0).text       faultstring
+ * faultcode.value      faultcode
+ * faultcode.subcode    (discarded)
+ * detail               detail
+ * role                 (discarded)
+ * 
*/ public class AxisFault extends RemoteException { - private String soapFaultCode; - public AxisFault(Throwable arg1) { - super(arg1.getMessage(), arg1); + /** + * Contains the faultcode + */ + private FaultCode faultCode=new FaultCode(); + + /** + * SOAP1.2: URI of faulting node. Null for unknown. + * + * The value of the Node element information item is the URI that + * identifies the SOAP node that generated the fault. + * SOAP nodes that do not act as the ultimate SOAP receiver MUST include this element + * information item. + * An ultimate SOAP receiver MAY include this element information item to + * indicate explicitly that it generated the fault. + */ + private String nodeURI; + + /** + * our failt reasons + */ + private FaultReasonList reasons=new FaultReasonList(); + + private OMElement detail; + + /** + * An incoming SOAPFault + */ + private SOAPFault soapFault; + + + /** + * assume headers are not used very often + */ + private List headers=new ArrayList(0); + + + /** + * construct a fault from an exception + * TODO: handle AxisFaults or SOAPFaultException implementations differently? + * @param cause + */ + public AxisFault(Throwable cause) { + this(cause!=null?cause.getMessage():null,cause); + } + + /** + * @param message + */ + public AxisFault(String message) { + super(message); + addReason(message); + } + + /** + * @param message + * @param cause + */ + public AxisFault(String message, Throwable cause) { + super(message, cause); + if(message!=null) { + addReason(message); + } + } + + /** + * @param messageText - this will appear as the Text in the Reason information item of SOAP Fault + * @param faultCode - this will appear as the Value in the Code information item of SOAP Fault + */ + public AxisFault(String messageText, String faultCode) { + this(messageText); + setFaultCode(faultCode); + } + + /** + * @param messageText - this will appear as the Text in the Reason information item of SOAP Fault + * @param faultCode - this will appear as the Value in the Code information item of SOAP Fault + * @param cause - this will appear under the Detail information item of SOAP Fault + */ + public AxisFault(String messageText, String faultCode, Throwable cause) { + this(messageText, cause); + setFaultCode(faultCode); } + /** - * @param arg0 + * @param messageText - this will appear as the Text in the Reason information item of SOAP Fault + * @param faultCode - this will appear as the Value in the Code information item of SOAP Fault + * @param cause - this will appear under the Detail information item of SOAP Fault */ - public AxisFault(String arg0) { - super(arg0); + public AxisFault(String messageText, QName faultCode, Throwable cause) { + this(messageText, cause); + setFaultCode(faultCode); } + /** - * @param arg0 - * @param arg1 + * Make an AxisFault from an incoming SOAPFault + * @param fault that caused the failure */ - public AxisFault(String arg0, Throwable arg1) { - super(arg0, arg1); + public AxisFault(SOAPFault fault) { + soapFault = fault; + init(soapFault); } + /** * Make an AxisFault based on a passed Exception. If the Exception is * already an AxisFault, simply use that. Otherwise, wrap it in an @@ -73,35 +187,106 @@ if (e instanceof AxisFault) { return (AxisFault) e; } - return new AxisFault(e.getMessage(), e); + return new AxisFault(e); } - /** - * - * @param messageText - this will appear as the Text in the Reason information item of SOAP Fault - * @param faultCode - this will appear as the Value in the Code information item of SOAP Fault - * @param cause - this will appear under the Detail information item of SOAP Fault - */ - public AxisFault(String messageText, String faultCode, Throwable cause) { - super(messageText, cause); - this.soapFaultCode = faultCode; - } /** - * - * @param messageText - this will appear as the Text in the Reason information item of SOAP Fault - * @param faultCode - this will appear as the Value in the Code information item of SOAP Fault + * Initialise from a SOAPFault. This is how incoming fault messages + * get turned into AxisFaults. + * @param fault incoming fault */ - public AxisFault(String messageText, String faultCode) { - super(messageText); - this.soapFaultCode = faultCode; + private void init(SOAPFault fault) { + SOAPFaultCode faultcodesource =fault.getCode(); + faultCode=new FaultCode(faultcodesource); + detail=fault.getDetail(); + fault.getNode(); } + + public String getFaultCode() { - return soapFaultCode; + return faultCode.getValueString(); } public void setFaultCode(String soapFaultCode) { - this.soapFaultCode = soapFaultCode; + faultCode.setValueString(soapFaultCode); + } + + public void setFaultCode(QName soapFaultCode) { + faultCode.setValue(soapFaultCode); + } + + /** + * Add a reason for the fault + * @param text text message + * @param language language + */ + public void addReason(String text,String language) { + reasons.add(text,language); + } + + /** + * Add a reason for the fault in the empty "" language + * @param text text message + */ + public void addReason(String text) { + addReason(text, ""); + } + + /** + * Add a header to the list of fault headers + * @param header to add. + */ + public void addHeader(SOAPHeader header) { + headers.add(header); + } + + /** + * Iterate over all of the headers + * @return + */ + public ListIterator headerIterator() { + return headers.listIterator(); + } + + /** + * Get at the headers. Useful for java1.5 iteration. + * @return the headers for this fault + */ + public List headers() { + return headers; + } + + /** + * Get the faulting node uri. + * SOAP1.2 + * @return URI as a string or null + */ + public String getNodeURI() { + return nodeURI; + } + + /** + * Set the faulting node uri. SOAP1.2 + */ + public void setNodeURI(String nodeURI) { + this.nodeURI = nodeURI; + } + + /** + * Get the current fault detail + * @return + */ + public OMElement getDetail() { + return detail; + } + + /** + * Set the entire detail element of the fault + * @param detail + */ + public void setDetail(OMElement detail) { + this.detail = detail; } }