public class DmtException
extends java.lang.Exception
DmtException
always contains an error code (one of the
constants specified in this class), and may optionally contain the URI of the
related node, and information about the cause of the exception.
Some of the error codes defined in this class have a corresponding error code defined in OMA DM, in these cases the name and numerical value from OMA DM is used. Error codes without counterparts in OMA DM were given numbers from a different range, starting from 1.
The cause of the exception (if specified) can either be a single
Throwable
instance, or a list of such instances if several problems
occurred during the execution of a method. An example for the latter is the
close
method of DmtSession
that tries to close multiple
plugins, and has to report the exceptions of all failures.
Each constructor has two variants, one accepts a String
node URI, the
other accepts a String[]
node path. The former is used by the
DmtAdmin implementation, the latter by the plugins, who receive the node URI
as an array of segment names. The constructors are otherwise identical.
Getter methods are provided to retrieve the values of the additional
parameters, and the printStackTrace(PrintWriter)
method is extended
to print the stack trace of all causing throwables as well.
Modifier and Type | Field and Description |
---|---|
static int |
ALERT_NOT_ROUTED
An alert can not be sent from the device to the given principal.
|
static int |
COMMAND_FAILED
The recipient encountered an error which prevented it from fulfilling the
request.
|
static int |
COMMAND_NOT_ALLOWED
The requested command is not allowed on the target node.
|
static int |
CONCURRENT_ACCESS
An error occurred related to concurrent access of nodes.
|
static int |
DATA_STORE_FAILURE
An error related to the recipient data store occurred while processing
the request.
|
static int |
FEATURE_NOT_SUPPORTED
The requested command failed because an optional feature required by the
command is not supported.
|
static int |
INVALID_URI
The requested command failed because the target URI or node name is
null or syntactically invalid. |
static int |
LIMIT_EXCEEDED
The requested operation failed because a specific limit was exceeded,
e.g.
|
static int |
METADATA_MISMATCH
Operation failed because of meta data restrictions.
|
static int |
NODE_ALREADY_EXISTS
The requested node creation operation failed because the target already
exists.
|
static int |
NODE_NOT_FOUND
The requested target node was not found.
|
static int |
PERMISSION_DENIED
The requested command failed because the principal associated with the
session does not have adequate access control permissions (ACL) on the
target.
|
static int |
REMOTE_ERROR
A device initiated remote operation failed.
|
static int |
ROLLBACK_FAILED
The rollback command was not completed successfully.
|
static int |
SESSION_CREATION_TIMEOUT
Creation of a session timed out because of another ongoing session.
|
static int |
TRANSACTION_ERROR
A transaction-related error occurred in an atomic session.
|
static int |
UNAUTHORIZED
The originator's authentication credentials specify a principal with
insufficient rights to complete the command.
|
static int |
URI_TOO_LONG
The requested command failed because the target URI is too long for what
the recipient is able or willing to process.
|
Constructor and Description |
---|
DmtException(java.lang.String[] path,
int code,
java.lang.String message)
Create an instance of the exception, specifying the target node as an
array of path segments.
|
DmtException(java.lang.String[] path,
int code,
java.lang.String message,
java.lang.Throwable cause)
Create an instance of the exception, specifying the target node as an
array of path segments, and specifying the cause exception.
|
DmtException(java.lang.String[] path,
int code,
java.lang.String message,
java.util.Vector<? extends java.lang.Throwable> causes,
boolean fatal)
Create an instance of the exception, specifying the target node as an
array of path segments, the list of cause exceptions, and whether the
exception is a fatal one.
|
DmtException(java.lang.String uri,
int code,
java.lang.String message)
Create an instance of the exception.
|
DmtException(java.lang.String uri,
int code,
java.lang.String message,
java.lang.Throwable cause)
Create an instance of the exception, specifying the cause exception.
|
DmtException(java.lang.String uri,
int code,
java.lang.String message,
java.util.Vector<? extends java.lang.Throwable> causes,
boolean fatal)
Create an instance of the exception, specifying the list of cause
exceptions and whether the exception is a fatal one.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Throwable |
getCause()
Get the cause of this exception.
|
java.lang.Throwable[] |
getCauses()
Get all causes of this exception.
|
int |
getCode()
Get the error code associated with this exception.
|
java.lang.String |
getMessage()
Get the message associated with this exception.
|
java.lang.String |
getURI()
Get the node on which the failed DMT operation was issued.
|
boolean |
isFatal()
Check whether this exception is marked as fatal in the session.
|
void |
printStackTrace(java.io.PrintStream s)
Prints the exception and its stacktrace to the specified print stream.
|
public static final int UNAUTHORIZED
This status code is used as response to device originated sessions if the remote management server cannot authorize the device to perform the requested operation.
This error code corresponds to the OMA DM response status code 401 "Unauthorized".
public static final int NODE_NOT_FOUND
This is only used when the requested node name is valid, otherwise the
more specific error codes URI_TOO_LONG
or INVALID_URI
are used. This error code corresponds to the OMA DM response status code
404 "Not Found".
public static final int COMMAND_NOT_ALLOWED
This error code corresponds to the OMA DM response status code 405 "Command not allowed".
public static final int FEATURE_NOT_SUPPORTED
When getting or setting values for interior nodes (an optional optimization feature), a plugin can use this error code to indicate that the given interior node does not support values.
This error code corresponds to the OMA DM response status code 406 "Optional feature not supported".
public static final int LIMIT_EXCEEDED
This error code corresponds to the OMA DM response status code 413 "Request entity too large".
public static final int URI_TOO_LONG
This error code corresponds to the OMA DM response status code 414 "URI too long".
public static final int NODE_ALREADY_EXISTS
create...
methods), or indirectly (during a copy
operation).
This error code corresponds to the OMA DM response status code 418 "Already exists".
public static final int PERMISSION_DENIED
This error code corresponds to the OMA DM response status code 425 "Permission denied".
public static final int COMMAND_FAILED
This error code is only used in situations not covered by any of the other error codes that a method may use. Some methods specify more specific error situations for this code, but it can generally be used for any unexpected condition that causes the command to fail.
This error code corresponds to the OMA DM response status code 500 "Command Failed".
public static final int DATA_STORE_FAILURE
This error code corresponds to the OMA DM response status code 510 "Data store failure".
public static final int ROLLBACK_FAILED
This error code corresponds to the OMA DM response status code 516 "Atomic roll back failed".
public static final int REMOTE_ERROR
Alert routing errors (that occur while looking for the proper protocol
adapter to use) are indicated by ALERT_NOT_ROUTED
, this code is
only for errors encountered while sending the routed alert. This error
code does not correspond to any OMA DM response status code. It should be
translated to the code 500 "Command Failed" when transferring
over OMA DM.
public static final int METADATA_MISMATCH
MetaNode
objects of the affected nodes, for example in the following situations:
MetaNode.CMD_EXECUTE
access
type)
This error code can also be used to indicate any other meta data
violation, even if it cannot be described by the MetaNode
class.
For example, detecting a multi-node constraint violation while committing
an atomic session should result in this error.
This error code does not correspond to any OMA DM response status code. It should be translated to the code 405 "Command not allowed" when transferring over OMA DM.
public static final int INVALID_URI
null
or syntactically invalid. This covers the following cases:
.
" at a position
other than the beginning of the URI..
" or the URI contains such a
segment
See the Uri.encode(String)
method for support on escaping invalid
characters in a URI.
This code is only used if the URI or node name does not match any of the
criteria for URI_TOO_LONG
. This error code does not correspond
to any OMA DM response status code. It should be translated to the code
404 "Not Found" when transferring over OMA DM.
public static final int CONCURRENT_ACCESS
This error code does not correspond to any OMA DM response status code. It should be translated to the code 500 "Command Failed" when transferring over OMA DM.
public static final int ALERT_NOT_ROUTED
This error code does not correspond to any OMA DM response status code. It should be translated to the code 500 "Command Failed" when transferring over OMA DM.
public static final int TRANSACTION_ERROR
DmtSession.commit()
for
details.
This error code does not correspond to any OMA DM response status code. It should be translated to the code 500 "Command Failed" when transferring over OMA DM.
public static final int SESSION_CREATION_TIMEOUT
This error code does not correspond to any OMA DM response status code. OMA has several status codes related to timeout, but these are meant to be used when a request times out, not if a session can not be established. This error code should be translated to the code 500 "Command Failed" when transferring over OMA DM.
public DmtException(java.lang.String uri, int code, java.lang.String message)
uri
and message
parameters are optional. No originating exception is specified.uri
- the node on which the failed DMT operation was issued, or
null
if the operation is not associated with a nodecode
- the error code of the failuremessage
- the message associated with the exception, or null
if there is no error messagepublic DmtException(java.lang.String uri, int code, java.lang.String message, java.lang.Throwable cause)
uri
, message
and cause
parameters are optional.uri
- the node on which the failed DMT operation was issued, or
null
if the operation is not associated with a nodecode
- the error code of the failuremessage
- the message associated with the exception, or null
if there is no error messagecause
- the originating exception, or null
if there is no
originating exceptionpublic DmtException(java.lang.String uri, int code, java.lang.String message, java.util.Vector<? extends java.lang.Throwable> causes, boolean fatal)
uri
, message
and causes
parameters are optional.
If a fatal exception is thrown, no further business methods will be called on the originator plugin. In case of atomic sessions, all other open plugins will be rolled back automatically, except if the fatal exception was thrown during commit.
uri
- the node on which the failed DMT operation was issued, or
null
if the operation is not associated with a nodecode
- the error code of the failuremessage
- the message associated with the exception, or null
if there is no error messagecauses
- the list of originating exceptions, or empty list or
null
if there are no originating exceptionsfatal
- whether the exception is fatalpublic DmtException(java.lang.String[] path, int code, java.lang.String message)
path
- the path of the node on which the failed DMT operation was
issued, or null
if the operation is not associated with a
nodecode
- the error code of the failuremessage
- the message associated with the exception, or null
if there is no error messageDmtException(String, int, String)
public DmtException(java.lang.String[] path, int code, java.lang.String message, java.lang.Throwable cause)
path
- the path of the node on which the failed DMT operation was
issued, or null
if the operation is not associated with a
nodecode
- the error code of the failuremessage
- the message associated with the exception, or null
if there is no error messagecause
- the originating exception, or null
if there is no
originating exceptionDmtException(String, int, String, Throwable)
public DmtException(java.lang.String[] path, int code, java.lang.String message, java.util.Vector<? extends java.lang.Throwable> causes, boolean fatal)
path
- the path of the node on which the failed DMT operation was
issued, or null
if the operation is not associated with a
nodecode
- the error code of the failuremessage
- the message associated with the exception, or null
if there is no error messagecauses
- the list of originating exceptions, or empty list or
null
if there are no originating exceptionsfatal
- whether the exception is fatalDmtException(String, int, String, Vector, boolean)
public java.lang.String getURI()
DmtSession.close()
don't require an URI, in this
case this method returns null
.null
public int getCode()
public java.lang.String getMessage()
null
):
<exception_code>[: '<uri>'][: <error_message>]
getMessage
in class java.lang.Throwable
public java.lang.Throwable getCause()
null
, if this
exception is caused by one or more other exceptions (like a
NullPointerException
in a DmtPlugin). If there are more than one
cause exceptions, the first one is returned.getCause
in class java.lang.Throwable
null
if no cause was
givenpublic java.lang.Throwable[] getCauses()
public boolean isFatal()
public void printStackTrace(java.io.PrintStream s)
printStackTrace
in class java.lang.Throwable
s
- PrintStream
to use for outputCopyright © OSGi Alliance (2000, 2018). All Rights Reserved. Licensed under the OSGi Specification License, Version 2.0