Version: 1.1.1

org.biomoby.shared.parser
Class ServiceException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.biomoby.shared.MobyException
              extended by org.biomoby.shared.parser.ServiceException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
MobyServiceException

public class ServiceException
extends MobyException

A container for an exception raised by a service provider when something wrong has to be reported back to a client. These exceptions are carried in "service notes" in MobyPackage.

It also contains constants for known error codes and for exception severity levels.

Version:
$Id: ServiceException.java,v 1.14 2009/06/09 18:55:35 gordonp Exp $
Author:
Martin Senger
See Also:
Serialized Form

Field Summary
static int COMMUNICATION_FAILURE
          Error code: A generic network failure.
static int ERROR
          A severity code that corresponds to a fatal error.
static int INFO
          A severity code that corresponds to a message not related to any error.
static int INPUT_EMPTY_OBJECT
          Error code: Given an empty input data.
static int INPUT_INCORRECT_COLLECTION
          Error code: Given input of type Collection is incorrect.
static int INPUT_INCORRECT_NAMESPACE
          Error code: Incorrect Namespace in the input object.
static int INPUT_INCORRECT_PARAMETER
          Error code: Given parameter is incorrect.
static int INPUT_INCORRECT_SIMPLE
          Error code: Given input of type Simple is incorrect.
static int INPUT_NOT_ACCEPTED
          Error code: Used when a client tries to send input data to a job created in a previous call but the server does not any more accept input data.
static int INPUT_REQUIRED_PARAMETER
          Error code: Service requires a parameter but none was given.
static int INPUT_REQUIRED_PARAMETERS
          Error code: Service requires two or more data inputs.
static int INPUTS_INVALID
          Error code: Input data are invalid; they do not match with their definitions, or with their dependency conditions.
static int INTERNAL_PROCESSING_ERROR
          Error code: A placeholder for all other errors not defined explicitly in the Biomoby API.
static int NO_METADATA_AVAILABLE
          Error code: There are no metadata available for the executed service/analysis.
static int NOT_IMPLEMENTED
          Error code: A requested method is not implemented.
static int NOT_RUNNABLE
          Error code: The same job (analysis) has already been executed, or the data that had been set previously do not exist or are not accessible anymore.
static int NOT_RUNNING
          Error code: A job (analysis) has not yet been started.
static int NOT_TERMINATED
          Error code: For some reasons, a job (analysis) is not interruptible, but an attempt to do so was done.
static int OK
          Error code: No error.
static int PROTOCOLS_UNACCEPTED
          Error code: Used when a service does not agree on using any of the proposed notification protocols.
static int UNKNOWN_NAME
          Error code: Setting input data under a non-existing name, or asking for a result using an unknown name.
static int UNKNOWN_STATE
          Error code: Used when a service call expects to find an existing state but failed.
static int WARNING
          A severity code that corresponds to an informative diagnostic message.
 
Constructor Summary
ServiceException()
          An empty constructor.
ServiceException(int severity, int code, String message)
          A usual constructor setting severity, code and message about an exception.
ServiceException(int severity, int code, String jobId, String dataName)
          A richer constructor setting more details about an exception.
ServiceException(int severity, int code, String jobId, String dataName, String msg)
          A full constructor setting more details about an exception.
 
Method Summary
static ServiceException error(int code, String msg)
          Create an instance of ServiceException that represents an error.
static ServiceException error(String msg)
          Create an instance of ServiceException that represents an error.
static ServiceException[] extractExceptions(org.jdom.Element serviceNotes)
          Extract all exceptions from a serviceNotes XML element.
 String format(int indent)
          Return the same contents as toString() method but indented by level expressed in the parameter 'indent'.
 String getDataName()
          Return an article (data) name of an offending data input.
 int getErrorCode()
          Return an error code associated with this exception.
 String getErrorCodeAsString()
          Return a stringified form of the error code associated with this exception.
 String getJobId()
          Return an identifier of an offending job.
 String getMessage()
          Return an error message associated with this exception.
 int getSeverity()
          Return the current severity level.
 String getSeverityAsString()
          Return the current severity level in a stringified form.
static ServiceException info(String msg)
          Create an instance of ServiceException that represents an info.
 void setDataName(String name)
          Set an article name of an offending data input.
 void setErrorCode(int code)
          Assign an error code to this exception.
 void setJobId(MobyJob job)
          Set an identifier of an offending job.
 void setJobId(String id)
          Set an identifier of an offending job.
 void setMessage(String msg)
          Assign an error message to this exception.
 void setSeverity(int severity)
          Set severity level.
 void setSeverity(String severityName)
          Set severity level.
 String toString()
           
 org.jdom.Element toXML()
           
 String toXMLString()
           
static ServiceException warning(String msg)
          Create an instance of ServiceException that represents a warning.
 
Methods inherited from class org.biomoby.shared.MobyException
formatAndLog, getOriginalException
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ERROR

public static final int ERROR
A severity code that corresponds to a fatal error.

See Also:
Constant Field Values

WARNING

public static final int WARNING
A severity code that corresponds to an informative diagnostic message.

See Also:
Constant Field Values

INFO

public static final int INFO
A severity code that corresponds to a message not related to any error.

See Also:
Constant Field Values

OK

public static final int OK
Error code: No error. Used together with severity code INFO - indicating that actually no error occured and the service was executed normally.

See Also:
Constant Field Values

UNKNOWN_NAME

public static final int UNKNOWN_NAME
Error code: Setting input data under a non-existing name, or asking for a result using an unknown name.

See Also:
Constant Field Values

INPUTS_INVALID

public static final int INPUTS_INVALID
Error code: Input data are invalid; they do not match with their definitions, or with their dependency conditions.

See Also:
Constant Field Values

INPUT_NOT_ACCEPTED

public static final int INPUT_NOT_ACCEPTED
Error code: Used when a client tries to send input data to a job created in a previous call but the server does not any more accept input data.

See Also:
Constant Field Values

INPUT_REQUIRED_PARAMETER

public static final int INPUT_REQUIRED_PARAMETER
Error code: Service requires a parameter but none was given.

See Also:
Constant Field Values

INPUT_INCORRECT_PARAMETER

public static final int INPUT_INCORRECT_PARAMETER
Error code: Given parameter is incorrect.

See Also:
Constant Field Values

INPUT_INCORRECT_SIMPLE

public static final int INPUT_INCORRECT_SIMPLE
Error code: Given input of type Simple is incorrect.

See Also:
Constant Field Values

INPUT_REQUIRED_PARAMETERS

public static final int INPUT_REQUIRED_PARAMETERS
Error code: Service requires two or more data inputs.

See Also:
Constant Field Values

INPUT_INCORRECT_COLLECTION

public static final int INPUT_INCORRECT_COLLECTION
Error code: Given input of type Collection is incorrect.

See Also:
Constant Field Values

INPUT_EMPTY_OBJECT

public static final int INPUT_EMPTY_OBJECT
Error code: Given an empty input data.

See Also:
Constant Field Values

INPUT_INCORRECT_NAMESPACE

public static final int INPUT_INCORRECT_NAMESPACE
Error code: Incorrect Namespace in the input object.

See Also:
Constant Field Values

NOT_RUNNABLE

public static final int NOT_RUNNABLE
Error code: The same job (analysis) has already been executed, or the data that had been set previously do not exist or are not accessible anymore.

See Also:
Constant Field Values

NOT_RUNNING

public static final int NOT_RUNNING
Error code: A job (analysis) has not yet been started. Note that this exception is not raised when the job has been already finished.

See Also:
Constant Field Values

NOT_TERMINATED

public static final int NOT_TERMINATED
Error code: For some reasons, a job (analysis) is not interruptible, but an attempt to do so was done.

See Also:
Constant Field Values

NO_METADATA_AVAILABLE

public static final int NO_METADATA_AVAILABLE
Error code: There are no metadata available for the executed service/analysis.

See Also:
Constant Field Values

PROTOCOLS_UNACCEPTED

public static final int PROTOCOLS_UNACCEPTED
Error code: Used when a service does not agree on using any of the proposed notification protocols.

See Also:
Constant Field Values

INTERNAL_PROCESSING_ERROR

public static final int INTERNAL_PROCESSING_ERROR
Error code: A placeholder for all other errors not defined explicitly in the Biomoby API.

See Also:
Constant Field Values

COMMUNICATION_FAILURE

public static final int COMMUNICATION_FAILURE
Error code: A generic network failure.

See Also:
Constant Field Values

UNKNOWN_STATE

public static final int UNKNOWN_STATE
Error code: Used when a service call expects to find an existing state but failed.

See Also:
Constant Field Values

NOT_IMPLEMENTED

public static final int NOT_IMPLEMENTED
Error code: A requested method is not implemented.

See Also:
Constant Field Values
Constructor Detail

ServiceException

public ServiceException()
An empty constructor. Sets severity code to INFO and error code to OK.


ServiceException

public ServiceException(int severity,
                        int code,
                        String message)
A usual constructor setting severity, code and message about an exception. It does not specify which job or data it reports about.


ServiceException

public ServiceException(int severity,
                        int code,
                        String jobId,
                        String dataName)
A richer constructor setting more details about an exception.


ServiceException

public ServiceException(int severity,
                        int code,
                        String jobId,
                        String dataName,
                        String msg)
A full constructor setting more details about an exception.

Method Detail

error

public static ServiceException error(int code,
                                     String msg)
Create an instance of ServiceException that represents an error.

Parameters:
code - error code
msg - error message

error

public static ServiceException error(String msg)
Create an instance of ServiceException that represents an error.

Parameters:
msg - error message

warning

public static ServiceException warning(String msg)
Create an instance of ServiceException that represents a warning.

Parameters:
msg - warning message

info

public static ServiceException info(String msg)
Create an instance of ServiceException that represents an info.

Parameters:
msg - info message

getJobId

public String getJobId()
Return an identifier of an offending job.


setJobId

public void setJobId(String id)
Set an identifier of an offending job.


setJobId

public void setJobId(MobyJob job)
Set an identifier of an offending job.

Parameters:
job - a job whose Id is used

getDataName

public String getDataName()
Return an article (data) name of an offending data input.


setDataName

public void setDataName(String name)
Set an article name of an offending data input.


getMessage

public String getMessage()
Return an error message associated with this exception.

Overrides:
getMessage in class Throwable
Returns:
whatever was previously set by setMessage(java.lang.String), or a default description (if nothing was set and the error code is known to this class), or null.

setMessage

public void setMessage(String msg)
Assign an error message to this exception.


getSeverity

public int getSeverity()
Return the current severity level.

See Also:
ERROR, WARNING, INFO

getSeverityAsString

public String getSeverityAsString()
Return the current severity level in a stringified form.


setSeverity

public void setSeverity(int severity)
Set severity level.


setSeverity

public void setSeverity(String severityName)
Set severity level.


getErrorCode

public int getErrorCode()
Return an error code associated with this exception.


getErrorCodeAsString

public String getErrorCodeAsString()
Return a stringified form of the error code associated with this exception.

Returns:
a stringified error code or an empty string (if the code is service-specific)

setErrorCode

public void setErrorCode(int code)
Assign an error code to this exception.


toString

public String toString()
Overrides:
toString in class Throwable

format

public String format(int indent)
Return the same contents as toString() method but indented by level expressed in the parameter 'indent'.

Parameters:
indent - means a level of wanted indentation: number 1 means three spaces, number two six spaces, etc.
Returns:
a formatted, and indented, string

toXML

public org.jdom.Element toXML()

extractExceptions

public static ServiceException[] extractExceptions(org.jdom.Element serviceNotes)
Extract all exceptions from a serviceNotes XML element. This is a convenient method that can be used when dealing with an XML response from a service without parsing the whole response to a MobyPackage.

Parameters:
serviceNotes - a piece of XML <serviceNotes>...</serviceNotes>
Returns:
an array, potentially an empty array, of all exceptions extracted from the 'serviceNotes'

toXMLString

public String toXMLString()

Version: 1.1.1

Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010