public abstract class ApiImplementor extends Object
Constructor and Description |
---|
ApiImplementor() |
Modifier and Type | Method and Description |
---|---|
void |
addApiAction(ApiAction action) |
void |
addApiOptions(AbstractParam param)
Adds the given options to the API implementor.
|
void |
addApiOthers(ApiOther other) |
void |
addApiShortcut(String shortcut) |
void |
addApiView(ApiView view) |
void |
addCustomHeaders(String name,
API.RequestType type,
HttpMessage msg)
Override to add custom headers for specific API operations
|
ApiAction |
getApiAction(String name) |
List<ApiAction> |
getApiActions() |
ApiOther |
getApiOther(String name) |
List<ApiOther> |
getApiOthers() |
protected List<String> |
getApiShortcuts() |
ApiView |
getApiView(String name) |
List<ApiView> |
getApiViews() |
protected boolean |
getParam(net.sf.json.JSONObject params,
String name,
boolean defaultValue) |
protected int |
getParam(net.sf.json.JSONObject params,
String name,
int defaultValue) |
protected String |
getParam(net.sf.json.JSONObject params,
String name,
String defaultValue) |
abstract String |
getPrefix() |
ApiResponse |
handleApiAction(String name,
net.sf.json.JSONObject params)
Override if implementing one or more actions
|
ApiResponse |
handleApiOptionAction(String name,
net.sf.json.JSONObject params) |
ApiResponse |
handleApiOptionView(String name,
net.sf.json.JSONObject params) |
HttpMessage |
handleApiOther(HttpMessage msg,
String name,
net.sf.json.JSONObject params)
Override if implementing one or more 'other' operations - these are operations that _dont_ return structured data
|
ApiResponse |
handleApiView(String name,
net.sf.json.JSONObject params)
Override if implementing one or more views
|
String |
handleCallBack(HttpMessage msg)
Override if handling callbacks
|
HttpMessage |
handleShortcut(HttpMessage msg) |
protected void |
validateParamExists(net.sf.json.JSONObject parameters,
String name)
Validates that a parameter with the given
name exists (and it has a value) in the given parameters . |
public void addApiView(ApiView view)
public void addApiOthers(ApiOther other)
public void addApiAction(ApiAction action)
public void addApiShortcut(String shortcut)
public void addApiOptions(AbstractParam param)
param
- the options for the APIZapApiIgnore
public ApiResponse handleApiOptionView(String name, net.sf.json.JSONObject params) throws ApiException
ApiException
public ApiResponse handleApiOptionAction(String name, net.sf.json.JSONObject params) throws ApiException
ApiException
public ApiResponse handleApiView(String name, net.sf.json.JSONObject params) throws ApiException
name
- the name of the requested viewparams
- the API request parametersApiException
- if an error occurred while handling the API view endpointpublic ApiResponse handleApiAction(String name, net.sf.json.JSONObject params) throws ApiException
name
- the name of the requested actionparams
- the API request parametersApiException
- if an error occurred while handling the API action endpointpublic HttpMessage handleApiOther(HttpMessage msg, String name, net.sf.json.JSONObject params) throws ApiException
msg
- the HTTP message containing the API requestname
- the name of the requested other endpointparams
- the API request parametersApiException
- if an error occurred while handling the API other endpointpublic String handleCallBack(HttpMessage msg) throws ApiException
msg
- the HTTP message containing the API request and responseApiException
- if an error occurred while handling the API callbackpublic HttpMessage handleShortcut(HttpMessage msg) throws ApiException
ApiException
public abstract String getPrefix()
protected int getParam(net.sf.json.JSONObject params, String name, int defaultValue)
protected boolean getParam(net.sf.json.JSONObject params, String name, boolean defaultValue)
protected void validateParamExists(net.sf.json.JSONObject parameters, String name) throws ApiException
name
exists (and it has a value) in the given parameters
.parameters
- the parametersname
- the name of the parameter that must existApiException
- if the parameter with the given name does not exist or it has no value.public void addCustomHeaders(String name, API.RequestType type, HttpMessage msg)
name
- the name of the operationtype
- the type of the operationmsg
- the HTTP response message to the API request