public class PostCommand<ResponseType extends CommandResponse> extends Command<ResponseType>
Client code will not typically use this class directly, but will
instead use one of the classes that extend this class (e.g.,
UpdateRowsCommand
).
However, if future versions of the LabKey Server expose new HTTP APIs requiring a POST
that are not yet supported with a specialized class in this library,
the developer may still invoke these APIs by creating an instance of the
PostCommand object directly, providing the controller and action name for
the new API. The post body may then be supplied by overriding the
getJsonObject()
method, returning the JSON object to post.
Command.CommonParameters, Command.Response
CONTENT_TYPE_JSON
Constructor and Description |
---|
PostCommand(PostCommand source) |
PostCommand(java.lang.String controllerName,
java.lang.String actionName)
Constructs a new PostCommand given a controller and action name.
|
Modifier and Type | Method and Description |
---|---|
PostCommand |
copy()
Returns a copy of this object.
|
protected org.apache.http.client.methods.HttpUriRequest |
createRequest(java.net.URI uri)
Overrides
Command.createRequest(URI) to create an
HttpPost object. |
org.json.simple.JSONObject |
getJsonObject()
Returns the JSON object to post, or null if the JSON object
has not yet been set.
|
void |
setJsonObject(org.json.simple.JSONObject jsonObject)
Sets the JSON object to post.
|
_execute, checkThrowError, createResponse, execute, getActionName, getActionUrl, getControllerName, getHttpRequest, getParameters, getParamValueAsString, getQueryString, getRequiredVersion, getTimeout, setParameters, setRequiredVersion, setTimeout
public PostCommand(java.lang.String controllerName, java.lang.String actionName)
controllerName
- The controller name.actionName
- The action name.public PostCommand(PostCommand source)
public org.json.simple.JSONObject getJsonObject()
public void setJsonObject(org.json.simple.JSONObject jsonObject)
jsonObject
- The JSON object to postprotected org.apache.http.client.methods.HttpUriRequest createRequest(java.net.URI uri)
Command.createRequest(URI)
to create an
HttpPost
object.
Override this method if your post command sends something other than JSON in the post body. In your override, create the PostMethod and set the RequestEntity appropriately.
createRequest
in class Command<ResponseType extends CommandResponse>
uri
- the uri to convertpublic PostCommand copy()
Command
copy
in class Command<ResponseType extends CommandResponse>