Class Stimulus
- java.lang.Object
-
- nzilbb.labbcat.server.api.APIRequestHandler
-
- nzilbb.labbcat.server.api.admin.elicit.Stimulus
-
@RequiredRole("admin") public class Stimulus extends APIRequestHandler
Servlet that manages speech elicitation task stimuli files./api/admin/elicit/stimulus[/file-name]
The following operations, specified by the HTTP method, are supported:
- POST
- Upload a stimulus image/video. using a multipart POST request.
(the first file parameter encountered is taken, regardless of its name).
- Request Body - A multi-part encoded request with one file parameter (the first file parameter encountered is taken, regardless of its name). Accepted file types are: png, gif, jpeg, mp4.
- Response Body - the standard JSON envelope, with the model as an
object with the following attributes:
- file_size
- A string representing size of the file in bytes.
- file_content_type
- The file content type.
- file_name
- The name of the file on the server.
- Response Status
- 201 : The stimulus file was successfully created or replaced.
- 415 : The file was not of a supported type.
- GET
- List stimulus files.
- No parameters are required
- Response Body - the standard JSON envelope, with the model as a corresponding array of file names.
- Response Status
- 200 : The records could be listed.
- DELETE
- Delete an existing file.
- Request Path - /api/admin/elicit/stimulus/file-name.
- Response Body - the standard JSON envelope, including a message if the request succeeds or an error explaining the reason for failure.
- Response Status
- 200 : The stimulus file was successfully deleted.
- 415 : The file was not of a supported type.
- 404 : The file was not found.
- Author:
- Robert Fromont robert@fromont.net.nz
-
-
Field Summary
-
Fields inherited from class nzilbb.labbcat.server.api.APIRequestHandler
SC_BAD_REQUEST, SC_CONFLICT, SC_CREATED, SC_FORBIDDEN, SC_INTERNAL_SERVER_ERROR, SC_METHOD_NOT_ALLOWED, SC_NOT_FOUND, SC_OK, SC_UNAUTHORIZED, SC_UNPROCESSABLE_CONTENT, SC_UNSUPPORTED_MEDIA_TYPE
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.json.JsonObjectdelete(String pathInfo, Consumer<Integer> httpStatus)DELETE handler: Delete the given stimulus file.javax.json.JsonObjectget(Consumer<Integer> httpStatus)GET handler - list stimulus files.javax.json.JsonObjectpost(RequestParameters parameters, Consumer<Integer> httpStatus)POST handler - receive an uploaded stimulus file.-
Methods inherited from class nzilbb.labbcat.server.api.APIRequestHandler
getContext, GetSystemAttribute, init, writeResponse
-
-
-
-
Constructor Detail
-
Stimulus
public Stimulus(File stimulusDir)
Default constructor.
-
-
Method Detail
-
post
public javax.json.JsonObject post(RequestParameters parameters, Consumer<Integer> httpStatus)
POST handler - receive an uploaded stimulus file.- Parameters:
parameters- Request parameter map.httpStatus- Receives the response status code, in case of error.- Returns:
- JSON-encoded object representing the response
-
get
public javax.json.JsonObject get(Consumer<Integer> httpStatus)
GET handler - list stimulus files.- Parameters:
httpStatus- Receives the response status code, in case of error.- Returns:
- JSON-encoded object representing the response
-
-