public abstract class SimpleRequest
extends java.lang.Object
implements org.json.JSONString
Example request type and parser.
Requests are represented as JSON as follows:
{
request = {
"#mandatory" : [ "type", "data" ],
"type" : "string",
"data" : "object",
}
} where:
type is the request type.data is the request data.| Modifier and Type | Class and Description |
|---|---|
static class |
SimpleRequest.Type
Request type.
|
| Modifier | Constructor and Description |
|---|---|
protected |
SimpleRequest(SimpleRequest.Type type,
java.lang.String identity,
SimpleUser user)
Create a simple request with the provided data.
|
| Modifier and Type | Method and Description |
|---|---|
abstract SimpleRespondMessageContext |
execute()
Executes the operation and returns the response.
|
abstract org.json.JSONObject |
getData() |
java.lang.String |
getIdentity() |
SimpleRequest.Type |
getType() |
SimpleUser |
getUser() |
static SimpleRequest |
parse(java.lang.String identity,
SimpleUser user,
com.netflix.msl.msg.MessageInputStream request,
java.util.Map<java.lang.String,com.netflix.msl.crypto.ICryptoContext> cryptoContexts)
Parse a request from the provided input stream.
|
java.lang.String |
toJSONString() |
protected SimpleRequest(SimpleRequest.Type type, java.lang.String identity, SimpleUser user)
Create a simple request with the provided data.
type - request type.identity - request entity identity.user - request user. May be null.public static SimpleRequest parse(java.lang.String identity, SimpleUser user, com.netflix.msl.msg.MessageInputStream request, java.util.Map<java.lang.String,com.netflix.msl.crypto.ICryptoContext> cryptoContexts) throws SimpleRequestUnknownException, SimpleRequestParseException, SimpleRequestUserException, java.io.IOException
Parse a request from the provided input stream. The requesting entity identity must be provided. The requesting user may be null.
identity - request entity identity.user - request user. May be null.request - request data.cryptoContexts - service token crypto contexts.java.io.IOException - if there is an error reading from the input stream.SimpleRequestUnknownException - if the request cannot be
identified.SimpleRequestParseException - if the request data fails to parse
successfully.SimpleRequestUserException - if the request type requires a user
but there is none provided.public SimpleRequest.Type getType()
public java.lang.String getIdentity()
public SimpleUser getUser()
public abstract org.json.JSONObject getData()
public abstract SimpleRespondMessageContext execute() throws SimpleRequestUserException, SimpleRequestExecutionException
Executes the operation and returns the response.
SimpleRequestUserException - if the request type requires a user
but there is none provided.SimpleRequestExecutionException - if there is an error executing
the request.public java.lang.String toJSONString()
toJSONString in interface org.json.JSONString