public abstract class RequestHandler extends Object
Modifier and Type | Class and Description |
---|---|
static class |
RequestHandler.RequestHandlerBadRequestException |
static class |
RequestHandler.RequestHandlerErrorException |
static class |
RequestHandler.RequestHandlerException |
static class |
RequestHandler.RequestHandlerForbiddenException |
Modifier and Type | Field and Description |
---|---|
protected Map<String,String> |
args
The GET request arguments
|
protected String |
content
default response
|
protected String |
contentType
default content type
|
static boolean |
globalConfirmationDefault |
static String |
globalConfirmationKey |
static boolean |
loadInNewLayerDefault |
static String |
loadInNewLayerKey |
protected String |
myCommand
will be filled with the command assigned to the subclass
|
protected String |
request
The request URL without "GET".
|
protected String |
sender
who send th request?
|
Constructor and Description |
---|
RequestHandler() |
Modifier and Type | Method and Description |
---|---|
(package private) void |
checkMandatoryParams() |
void |
checkPermission()
Check permissions in preferences and display error message
or ask for permission.
|
protected String |
decodeParam(String param) |
String |
getContent() |
String |
getContentType() |
abstract String[] |
getMandatoryParams() |
String[] |
getOptionalParams() |
abstract String |
getPermissionMessage()
Get a specific message to ask the user for permission for the operation
requested via remote control.
|
abstract PermissionPrefWithDefault |
getPermissionPref()
Get a PermissionPref object containing the name of a special permission
preference to individually allow the requested operation and an error
message to be displayed when a disabled operation is requested.
|
String[] |
getUsageExamples() |
String[] |
getUsageExamples(String cmd)
Returns usage examples for the given command.
|
void |
handle()
Check permission and parameters and handle request.
|
protected abstract void |
handleRequest()
Handle a specific command sent as remote control.
|
protected boolean |
isLoadInNewLayer() |
protected void |
parseArgs()
Parse the request parameters as key=value pairs.
|
void |
setCommand(String command)
Save command associated with this handler.
|
void |
setSender(String sender) |
void |
setUrl(String url)
Set request URL and parse args.
|
protected abstract void |
validateRequest()
Validates the request before attempting to perform it.
|
public static final String globalConfirmationKey
public static final boolean globalConfirmationDefault
public static final String loadInNewLayerKey
public static final boolean loadInNewLayerDefault
protected String contentType
public RequestHandler()
public final void handle() throws RequestHandler.RequestHandlerForbiddenException, RequestHandler.RequestHandlerBadRequestException, RequestHandler.RequestHandlerErrorException
protected abstract void validateRequest() throws RequestHandler.RequestHandlerBadRequestException
RequestHandler.RequestHandlerBadRequestException
protected abstract void handleRequest() throws RequestHandler.RequestHandlerErrorException, RequestHandler.RequestHandlerBadRequestException
public abstract String getPermissionMessage()
public abstract PermissionPrefWithDefault getPermissionPref()
public abstract String[] getMandatoryParams()
public String[] getOptionalParams()
public String[] getUsageExamples()
public String[] getUsageExamples(String cmd)
cmd
- The command askedpublic final void checkPermission() throws RequestHandler.RequestHandlerForbiddenException
public void setUrl(String url)
url
- The request URL.protected void parseArgs()
this.args
.
Can be overridden by subclass.void checkMandatoryParams() throws RequestHandler.RequestHandlerBadRequestException
public void setCommand(String command)
command
- The command.public String getContent()
public String getContentType()
protected boolean isLoadInNewLayer()
protected final String decodeParam(String param)