public class StandardDataFactory
extends java.lang.Object
DataDefinition
s and DataValue
s for
standard vAPI structures, like errors and localizable messages.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ALREADY_EXISTS |
static java.lang.String |
ARGS_FIELD_NAME |
static java.lang.String |
DATA_FIELD_NAME |
static java.lang.String |
DEFAUL_MSG_FIELD_NAME |
static java.lang.String |
ID_FIELD_NAME |
static java.lang.String |
INTERNAL_SERVER_ERROR |
static java.lang.String |
INVALID_ARGUMENT |
static java.lang.String |
MESSAGE_STRUCT_NAME |
static java.lang.String |
MESSAGES_FIELD_NAME |
static java.lang.String |
NOT_FOUND |
static java.lang.String |
OPERATION_NOT_FOUND |
static java.util.Map<java.lang.String,com.vmware.vapi.data.DataDefinition> |
STANDARD_ERROR_FIELDS |
static java.lang.String |
UNAUTHENTICATED |
static java.lang.String |
UNEXPECTED_INPUT |
Constructor and Description |
---|
StandardDataFactory() |
Modifier and Type | Method and Description |
---|---|
static ErrorValue |
createErrorValueForMessages(com.vmware.vapi.data.ErrorDefinition errorDef,
java.util.List<com.vmware.vapi.Message> messages)
Creates instance for given error definition and list of
Messages s. |
static ErrorValue |
createErrorValueForMessages(java.lang.String errorName,
java.util.List<com.vmware.vapi.Message> messages)
Creates a standard error
ErrorValue for the given
name list of Messages s. |
static com.vmware.vapi.data.ErrorDefinition |
createStandardErrorDefinition(java.lang.String errorName)
Factory method for
ErrorDefinition s for standard
vAPI errors. |
static com.vmware.vapi.data.StructDefinition |
getLocalizableMessageDefinition() |
static java.util.List<com.vmware.vapi.Message> |
getMessagesFromErrorValue(StructValue error)
Returns messages associated with the specified standard error
ErrorValue represented as list of Message s. |
public static final java.lang.String ALREADY_EXISTS
public static final java.lang.String INTERNAL_SERVER_ERROR
public static final java.lang.String OPERATION_NOT_FOUND
public static final java.lang.String INVALID_ARGUMENT
public static final java.lang.String NOT_FOUND
public static final java.lang.String UNAUTHENTICATED
public static final java.lang.String UNEXPECTED_INPUT
public static final java.lang.String MESSAGE_STRUCT_NAME
public static final java.lang.String ID_FIELD_NAME
public static final java.lang.String DEFAUL_MSG_FIELD_NAME
public static final java.lang.String ARGS_FIELD_NAME
public static final java.lang.String MESSAGES_FIELD_NAME
public static final java.lang.String DATA_FIELD_NAME
public static final java.util.Map<java.lang.String,com.vmware.vapi.data.DataDefinition> STANDARD_ERROR_FIELDS
public static com.vmware.vapi.data.StructDefinition getLocalizableMessageDefinition()
public static com.vmware.vapi.data.ErrorDefinition createStandardErrorDefinition(java.lang.String errorName)
ErrorDefinition
s for standard
vAPI errors.
Creates instance for the specified name. The name is used as name
of the StructDefinition
represented by the instance.
Additionally, a field named "messages" is added to the
StructDefinition
, the definition of this field is:
ListDefinition StructDefinition id -> StringDefinition default_message -> StringDefinition args -> ListDefinition StringDefinitionThat is a list of localizable messages.
errorName
- the error nameErrorDefinition
isntancepublic static ErrorValue createErrorValueForMessages(java.lang.String errorName, java.util.List<com.vmware.vapi.Message> messages)
ErrorValue
for the given
name list of Messages
s.public static ErrorValue createErrorValueForMessages(com.vmware.vapi.data.ErrorDefinition errorDef, java.util.List<com.vmware.vapi.Message> messages)
Messages
s. The name is used as name of the
StructValue
represented by the instance. Messages are
converted to list of structures and set as "messages" field (of
StructValue
) of this instance. The structure of the
"messages" field is:
ListValue StructValue id -> StringValue default_message -> StringValue args -> ListValue StringValue
errorDef
- error definitionmessages
- the messages for the new ErrorValue
ErrirValue
instancejava.lang.IllegalArgumentException
- if messages
or
errorDef
is null
or
messages
is empty or contains null
element(s)public static java.util.List<com.vmware.vapi.Message> getMessagesFromErrorValue(StructValue error)
ErrorValue
represented as list of Message
s.
This method assumes the structure of "messages" field from
createErrorValueForMessages(ErrorDefinition, List)
.
In case this structure is not present - empty list is returned.error
- standard error value