Script: Class dw.system.Status
Class Status
- Object
- dw.system.Status
A Status is used for communicating an API status code back to a client. A status consists of multiple StatusItem. Most often a Status contains only one StatusItem. For convenience, a message with parameters is formatted using standard formatting patterns. If you want to display locale-specific messages in your application, you should use the Status.getCode() as key for a resource bundle.
Properties
code : String Read Only
The status code either of the first ERROR StatusItem or when there is no ERROR StatusITEM, the first StatusItem in the overall list. The status code is the unique identifier for the message and can be used by client programs to check for a specific status and to generate a localized message.
details : Map Read Only
The details either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
error : boolean Read Only
Checks if the status is an ERROR. The Status is an ERROR if one of the contained StatusItems is an ERROR.
static ERROR : Number
status value to indicate an ERROR status
items : List Read Only
All status items.
message : String Read Only
The message either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list. Note: Custom code and client programs must not use this message to identify a specific status. The getCode() must be used for that purpose. The actual message can change from release to release.
static OK : Number
status value to indicate an OK status
parameters : List Read Only
The parameters either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
status : Number Read Only
The overall status. If all StatusItems are OK, the method returns OK. If one StatusItem is an ERROR it returns ERROR.
Constructor Summary
Status()
Creates a Status object with no StatusItems.
Creates a Status with a single StatusItem.
Status(status : Number, code : String)
Creates a Status with a single StatusItem.
Status(status : Number, code : String, message : String, parameters : Object...)
Creates a Status with a single StatusItem.
Method Summary
addDetail(key : String, value : Object) : void
Add detail information for the given key of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
addItem(item : StatusItem) : void
Adds an additional status item to this status instance.
Returns the status code either of the first ERROR StatusItem or when there is no ERROR StatusITEM, the first StatusItem in the overall list.
getDetail(key : String) : Object
Returns the detail value for the given key of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
getDetails() : Map
Returns the details either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
Returns all status items.
getMessage() : String
Returns the message either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
getParameters() : List
Returns the parameters either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
Returns the overall status.
isError() : boolean
Checks if the status is an ERROR.
Methods inherited from class Object
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
Constructor Detail
Status
publicStatus()
Creates a Status object with no StatusItems.
Status
publicStatus(status : Number)
Creates a Status with a single StatusItem. The status is set to the given value.
Parameters:
status - either OK or ERROR
Status
publicStatus(status : Number, code : String)
Creates a Status with a single StatusItem. The StatusItem is initialized with the given values.
Parameters:
status - either OK or ERROR
code - a string representing a more detailed status code, e.g. "IMPEX-120"
Status
publicStatus(status : Number, code : String, message : String, parameters : Object...)
Creates a Status with a single StatusItem. The StatusItem is initialized with the given values.
Parameters:
status - either OK or ERROR
code - a string representing a more detailed status code, e.g. "IMPEX-120".
message - a default human readable message
parameters - a list of parameters to construct a custom message
Method Detail
addDetail
addDetail(key : String, value : Object) : void
Add detail information for the given key of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
Parameters:
key - the key of the first ERROR StatusItem or the first StatusItem in the list.
value - the detail value.
addItem
addItem(item : StatusItem) : void
Adds an additional status item to this status instance.
Parameters:
item - the status item to add.
getCode
getCode() : String
Returns the status code either of the first ERROR StatusItem or when there is no ERROR StatusITEM, the first StatusItem in the overall list. The status code is the unique identifier for the message and can be used by client programs to check for a specific status and to generate a localized message.
Returns:
the status code
getDetail
getDetail(key : String) : Object
Returns the detail value for the given key of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
Parameters:
key - the key for the detail to return.
Returns:
the detail value for the given key of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
getDetails
getDetails() : Map
Returns the details either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
Returns:
the details either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
getItems
getItems() : List
Returns all status items.
Returns:
all status items.
getMessage
getMessage() : String
Returns the message either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list. Note: Custom code and client programs must not use this message to identify a specific status. The getCode() must be used for that purpose. The actual message can change from release to release.
Returns:
the message either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
getParameters
getParameters() : List
Returns the parameters either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
Returns:
the parameters either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
getStatus
getStatus() : Number
Returns the overall status. If all StatusItems are OK, the method returns OK. If one StatusItem is an ERROR it returns ERROR.
Returns:
either OK or ERROR
isError
isError() : boolean
Checks if the status is an ERROR. The Status is an ERROR if one of the contained StatusItems is an ERROR.
Returns:
true if status is an ERROR, false otherwise.