Package nzilbb.labbcat.server.api
Class TableServletBase
- java.lang.Object
-
- nzilbb.labbcat.server.api.APIRequestHandler
-
- nzilbb.labbcat.server.api.TableServletBase
-
- Direct Known Subclasses:
Categories
,Categories
,Corpora
,Dashboard
,Managers
,MediaTracks
,Permissions
,Roles
,SystemAttributes
,Users
public class TableServletBase extends APIRequestHandler
Base class that handles generic database table management.Subclasses specify the table name, key fields, and fields.
- Author:
- Robert Fromont robert@fromont.net.nz
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
TableServletBase.DeleteCheck
A query used to check each row to determine if there's a reason it can't be deleted.
-
Field Summary
-
Fields inherited from class nzilbb.labbcat.server.api.APIRequestHandler
SC_BAD_REQUEST, SC_CONFLICT, SC_FORBIDDEN, SC_INTERNAL_SERVER_ERROR, SC_METHOD_NOT_ALLOWED, SC_NOT_FOUND, SC_OK, SC_UNPROCESSABLE_CONTENT, SC_UNSUPPORTED_MEDIA_TYPE
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete(String pathInfo, OutputStream out, Consumer<String> contentTypeConsumer, Consumer<Integer> httpStatus)
DELETE handler - remove existing row.void
get(String pathInfo, RequestParameters parameters, UnaryOperator<String> requestHeaders, OutputStream out, Consumer<String> contentTypeConsumer, Consumer<String> fileName, Consumer<Integer> httpStatus)
GET handler lists all rows.void
post(InputStream requestBody, UnaryOperator<String> requestHeaders, OutputStream out, Consumer<String> contentTypeConsumer, Consumer<Integer> httpStatus)
POST handler - add a new row.void
put(InputStream requestBody, OutputStream out, Consumer<String> contentTypeConsumer, Consumer<Integer> httpStatus)
PUT handler - update an existing row.-
Methods inherited from class nzilbb.labbcat.server.api.APIRequestHandler
GetSystemAttribute, init, writeResponse
-
-
-
-
Method Detail
-
get
public void get(String pathInfo, RequestParameters parameters, UnaryOperator<String> requestHeaders, OutputStream out, Consumer<String> contentTypeConsumer, Consumer<String> fileName, Consumer<Integer> httpStatus)
GET handler lists all rows.The return is JSON encoded, unless the "Accept" request header, or the "Accept" request parameter, is "text/csv", in which case CSV is returned.
- Parameters:
pathInfo
- The URL path.parameters
- Request parameter map.requestHeaders
- Access to HTTP request headers.out
- Response body output stream.contentTypeConsumer
- Receives the content type for specification in the response headers.fileName
- Receives the filename for specification in the response headers.httpStatus
- Receives the response status code, in case of error.
-
post
public void post(InputStream requestBody, UnaryOperator<String> requestHeaders, OutputStream out, Consumer<String> contentTypeConsumer, Consumer<Integer> httpStatus)
POST handler - add a new row.- Parameters:
requestBody
- Stream containing the request body.requestHeaders
- Access to HTTP request headers.out
- Response body output stream.contentTypeConsumer
- Receives the content type for specification in the response headers.httpStatus
- Receives the response status code, in case of error.
-
put
public void put(InputStream requestBody, OutputStream out, Consumer<String> contentTypeConsumer, Consumer<Integer> httpStatus)
PUT handler - update an existing row.- Parameters:
requestBody
- Stream supplying the body of the request.out
- Stream for writing the response.contentTypeConsumer
- Consumer for receiving the output content type..httpStatus
- Receives the response status code, in case of error.
-
delete
public void delete(String pathInfo, OutputStream out, Consumer<String> contentTypeConsumer, Consumer<Integer> httpStatus)
DELETE handler - remove existing row.- Parameters:
pathInfo
- The URL path.out
- Response body output stream.contentTypeConsumer
- Receives the content type for specification in the response headers.httpStatus
- Receives the response status code, in case of error.
-
-