org.globus.wsrf.utils
Class FaultHelper

java.lang.Object
  extended byorg.globus.wsrf.utils.FaultHelper

public class FaultHelper
extends java.lang.Object

This class provides convenience functions around BaseFault API. It also provides a common way of including stack traces with Faults. A stack trace of a Fault is added as a chained BaseFault with an error code dialect attribute set to STACK_TRACE. A regular Java exception is automatically converted into a BaseFault with the description of exception message and with a chained BaseFault with STACK_TRACE error code dialect.


Field Summary
static org.apache.axis.types.URI EXCEPTION
          Exception error code URI
private  BaseFaultType fault
           
private static org.globus.util.I18n i18n
           
private static java.lang.String LS
           
static org.apache.axis.types.URI STACK_TRACE
          Stack trace error code URI
 
Constructor Summary
FaultHelper(BaseFaultType fault)
          Creates FaultHelper with a fault.
FaultHelper(BaseFaultType fault, boolean convertStackTrace)
          Creates FaultHelper with a fault.
 
Method Summary
 void addDescription(java.lang.String description)
          Adds a description to the description list of the fault.
private  void addFaultCause(BaseFaultType fault)
           
 void addFaultCause(java.lang.Throwable exception)
          Adds a fault cause to the fault.
private  void addStackTraceFault()
           
private  void addStackTraceFault(java.lang.Throwable exception)
           
private static BaseFaultType createStackFault(java.lang.String message, java.lang.String stackTrace)
           
 java.lang.String[] getDescription()
          Returns descriptions of the fault.
 java.lang.String getDescriptionAsString()
          Returns all the descriptions of the fault as a simple string.
 BaseFaultType getFault()
          Gets the fault.
 java.lang.String getMessage()
          Gets error message of the fault.
static java.lang.String getMessage(java.lang.Throwable exception)
          Gets the error message of the exception.
 java.lang.String getStackTrace()
          Gets stack trace of the fault.
 void printStackTrace()
          Prints stack trace of the fault to System.err.
 void printStackTrace(java.io.PrintStream s)
          Writes stack trace of the fault to stream.
 void printStackTrace(java.io.PrintWriter s)
          Writes stack trace of the fault to writer.
static void printStackTrace(java.lang.Throwable exception)
          Gets the stack trace of the exception.
 void setDescription(java.lang.String description)
          Sets the description of the fault.
 void setDescription(java.lang.String[] description)
          Sets the description of the fault.
static BaseFaultType toBaseFault(java.lang.Throwable exception)
          Converts exception to a BaseFault.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LS

private static final java.lang.String LS

STACK_TRACE

public static final org.apache.axis.types.URI STACK_TRACE
Stack trace error code URI


EXCEPTION

public static final org.apache.axis.types.URI EXCEPTION
Exception error code URI


i18n

private static org.globus.util.I18n i18n

fault

private BaseFaultType fault
Constructor Detail

FaultHelper

public FaultHelper(BaseFaultType fault)
Creates FaultHelper with a fault. If the fault contains a stack trace it will be automatically converted into a chained BaseFault with an error code dialect attribute set to set to STACK_TRACE.

Parameters:
fault - fault

FaultHelper

public FaultHelper(BaseFaultType fault,
                   boolean convertStackTrace)
Creates FaultHelper with a fault.

Parameters:
fault - fault
convertStackTrace - if true and if the fault contains a stack trace it will be automatically converted into a chained BaseFault with an error code dialect attribute set to set to STACK_TRACE.
Method Detail

getFault

public BaseFaultType getFault()
Gets the fault.


getDescriptionAsString

public java.lang.String getDescriptionAsString()
Returns all the descriptions of the fault as a simple string.


getDescription

public java.lang.String[] getDescription()
Returns descriptions of the fault.

Returns:
the descriptions. Might be null.

setDescription

public void setDescription(java.lang.String description)
Sets the description of the fault.

Parameters:
description - the new description of the fault.

setDescription

public void setDescription(java.lang.String[] description)
Sets the description of the fault.

Parameters:
description - the new descriptions of the fault.

addDescription

public void addDescription(java.lang.String description)
Adds a description to the description list of the fault.

Parameters:
description - the description to add.

addFaultCause

public void addFaultCause(java.lang.Throwable exception)
Adds a fault cause to the fault.

Parameters:
exception - the exception to add as a cause of this fault. If the exception is of BaseFault type then it is just added as is as a fault cause. Otherwise, the exception is converted into a new BaseFault and then added as a fault cause.

addFaultCause

private void addFaultCause(BaseFaultType fault)

addStackTraceFault

private void addStackTraceFault()

addStackTraceFault

private void addStackTraceFault(java.lang.Throwable exception)

createStackFault

private static BaseFaultType createStackFault(java.lang.String message,
                                              java.lang.String stackTrace)

toBaseFault

public static BaseFaultType toBaseFault(java.lang.Throwable exception)
Converts exception to a BaseFault.

Parameters:
exception - the exception to convert.
Returns:
If the exception is of BaseFault type then it is returned as is. Otherwise, the exception is converted into a BaseFault with the description of the exception message and with a chained BaseFault with STACK_TRACE error code dialect and error code value that contains the exception stack trace.

getMessage

public static java.lang.String getMessage(java.lang.Throwable exception)
Gets the error message of the exception.

Parameters:
exception - if exception is of type BaseFaultType getMessage() is called to get the error message. Otherwise, getMessage operation is called on the exception.

printStackTrace

public static void printStackTrace(java.lang.Throwable exception)
Gets the stack trace of the exception.

Parameters:
exception - if exception is of type BaseFaultType printStackTrace() is called to get the error message. Otherwise, printStackTrace operation is called on the exception.

printStackTrace

public void printStackTrace()
Prints stack trace of the fault to System.err. See getStackTrace() for more information.


printStackTrace

public void printStackTrace(java.io.PrintStream s)
Writes stack trace of the fault to stream. See getStackTrace() for more information.


printStackTrace

public void printStackTrace(java.io.PrintWriter s)
Writes stack trace of the fault to writer. See getStackTrace() for more information.


getMessage

public java.lang.String getMessage()
Gets error message of the fault.

Returns:
If the fault has error code dialect of STACK_TRACE null is returned. Otherwise, the error message is composed of all descriptions of the fault and descriptions of the chained faults.

getStackTrace

public java.lang.String getStackTrace()
Gets stack trace of the fault. Note, this stack trace only contains information sent from server. It does not contain client stack trace information.

Returns:
stack trace of the fault. It includes any chained faults.