public abstract class WebService extends StorableObject implements HttpUtil
HttpUtil.HEADER, HttpUtil.Helper, HttpUtil.METHOD, HttpUtil.STATUS
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
KEY_DESCRIPTION
The dictionary key for the description text.
|
static java.lang.String |
KEY_MATCH
The dictionary key for the request match array.
|
protected java.util.ArrayList |
matchers
The array of matcher objects.
|
static java.lang.String[] |
METHODS_GET
An array with only the HTTP GET method.
|
static java.lang.String[] |
METHODS_GET_POST
An array with only the HTTP GET and HTTP POST methods.
|
static java.lang.String[] |
METHODS_POST
An array with only the HTTP POST method.
|
static Path |
PATH
The web service object storage path.
|
dict, KEY_CLASSNAME, KEY_ID, KEY_TYPE
Constructor and Description |
---|
WebService(java.lang.String id,
java.lang.String type,
Dict dict)
Creates a new web service from a serialized representation.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
description()
Returns the description text.
|
protected void |
doDelete(Request request)
Processes an HTTP DELETE request.
|
protected void |
doGet(Request request)
Processes an HTTP GET request.
|
protected void |
doHead(Request request)
Processes an HTTP HEAD request.
|
protected void |
doOptions(Request request)
Processes an HTTP OPTIONS request.
|
protected void |
doPatch(Request request)
Processes an HTTP PATCH request.
|
protected void |
doPost(Request request)
Processes an HTTP POST request.
|
protected void |
doPut(Request request)
Processes an HTTP PUT request.
|
protected void |
doTrace(Request request)
Processes an HTTP TRACE request.
|
protected void |
errorBadRequest(Request request,
java.lang.String message)
Sends an HTTP 400 bad request error.
|
protected void |
errorForbidden(Request request)
Sends an HTTP 403 forbidden error.
|
protected void |
errorInternal(Request request,
java.lang.String message)
Sends an HTTP 500 internal server error.
|
protected void |
errorMethodNotAllowed(Request request)
Sends an HTTP 405 method not allowed error.
|
protected void |
errorNotFound(Request request)
Sends an HTTP 404 not found error.
|
protected void |
errorUnauthorized(Request request)
Sends an HTTP 401 unauthorized or 403 forbidden error.
|
static WebMatcher[] |
findAllMatchers(Storage storage)
Searches for all matchers in all web services in the storage.
|
protected void |
headerAllow(Request request)
Adds the HTTP allow header to the response.
|
java.lang.String[] |
methods(Request request)
Returns the HTTP methods supported for the specified request.
|
protected abstract java.lang.String[] |
methodsImpl(Request request)
Returns the HTTP methods implemented for the specified
request.
|
void |
process(Request request)
Processes a request for this handler.
|
Session |
session(Request request,
boolean create)
Returns the current session for the request.
|
public static final java.lang.String[] METHODS_GET
public static final java.lang.String[] METHODS_POST
public static final java.lang.String[] METHODS_GET_POST
public static final java.lang.String KEY_DESCRIPTION
public static final java.lang.String KEY_MATCH
public static final Path PATH
protected java.util.ArrayList matchers
public WebService(java.lang.String id, java.lang.String type, Dict dict)
id
- the object identifiertype
- the object type namedict
- the serialized representationpublic static WebMatcher[] findAllMatchers(Storage storage)
storage
- the storage to search inpublic java.lang.String description()
public java.lang.String[] methods(Request request)
request
- the request to checkprotected abstract java.lang.String[] methodsImpl(Request request)
request
- the request to checkmethods(Request)
public Session session(Request request, boolean create)
request
- the request to checkcreate
- the session create flagpublic void process(Request request)
request
- the request to processWebMatcher.process(Request)
protected void doOptions(Request request)
request
- the request to processprotected void doHead(Request request)
request
- the request to processprotected void doGet(Request request)
request
- the request to processprotected void doPost(Request request)
request
- the request to processprotected void doPatch(Request request)
request
- the request to processprotected void doPut(Request request)
request
- the request to processprotected void doDelete(Request request)
request
- the request to processprotected void doTrace(Request request)
request
- the request to processprotected void headerAllow(Request request)
request
- the request to modifyprotected void errorBadRequest(Request request, java.lang.String message)
request
- the request to processmessage
- the additional error messageprotected void errorUnauthorized(Request request)
request
- the request to processprotected void errorForbidden(Request request)
request
- the request to processprotected void errorNotFound(Request request)
request
- the request to processprotected void errorMethodNotAllowed(Request request)
request
- the request to processprotected void errorInternal(Request request, java.lang.String message)
request
- the request to processmessage
- the additional error message