Package nzilbb.labbcat.server.api
Class APIRequestHandler
- java.lang.Object
-
- nzilbb.labbcat.server.api.APIRequestHandler
-
- Direct Known Subclasses:
Agreement,Annotators,Attributes,Attributes,ConfigWebApp,Corpus,Data,Dictionary,Doc,ExtWebApp,Files,Fragments,Fragments,Graphs,Intervals,KeepAlive,Password,Password,Praat,Results,Search,Store,SystemAttributes,TableServletBase,Task,TaskWebApp,Token,Upload,Upload,User,Utterances,Versions
public class APIRequestHandler extends Object
Base class for request enpoints, which implents common functionality.- Author:
- Robert Fromont robert@fromont.net.nz
-
-
Field Summary
Fields Modifier and Type Field Description static intSC_BAD_REQUESTstatic intSC_CONFLICTstatic intSC_FORBIDDENstatic intSC_INTERNAL_SERVER_ERRORstatic intSC_METHOD_NOT_ALLOWEDstatic intSC_NOT_FOUNDstatic intSC_OKstatic intSC_UNPROCESSABLE_CONTENTstatic intSC_UNSUPPORTED_MEDIA_TYPE
-
Constructor Summary
Constructors Constructor Description APIRequestHandler()Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringGetSystemAttribute(String name, Connection db)Gets the value of the given system attribute.voidinit(APIRequestContext context)Initialise the endpoint data.voidwriteResponse(OutputStream out, javax.json.JsonObject jsonOut)Write a given JSON response to a given OutputStream.
-
-
-
Field Detail
-
SC_OK
public static final int SC_OK
- See Also:
- Constant Field Values
-
SC_BAD_REQUEST
public static final int SC_BAD_REQUEST
- See Also:
- Constant Field Values
-
SC_FORBIDDEN
public static final int SC_FORBIDDEN
- See Also:
- Constant Field Values
-
SC_NOT_FOUND
public static final int SC_NOT_FOUND
- See Also:
- Constant Field Values
-
SC_METHOD_NOT_ALLOWED
public static final int SC_METHOD_NOT_ALLOWED
- See Also:
- Constant Field Values
-
SC_CONFLICT
public static final int SC_CONFLICT
- See Also:
- Constant Field Values
-
SC_UNSUPPORTED_MEDIA_TYPE
public static final int SC_UNSUPPORTED_MEDIA_TYPE
- See Also:
- Constant Field Values
-
SC_UNPROCESSABLE_CONTENT
public static final int SC_UNPROCESSABLE_CONTENT
- See Also:
- Constant Field Values
-
SC_INTERNAL_SERVER_ERROR
public static final int SC_INTERNAL_SERVER_ERROR
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init(APIRequestContext context)
Initialise the endpoint data.
-
GetSystemAttribute
public static String GetSystemAttribute(String name, Connection db) throws SQLException
Gets the value of the given system attribute.- Parameters:
name-db-- Returns:
- Value for the given system attribute, or null if it's not set.
- Throws:
SQLException
-
writeResponse
public void writeResponse(OutputStream out, javax.json.JsonObject jsonOut)
Write a given JSON response to a given OutputStream.- Parameters:
out- Output stream to write to.jsonOut- JSON object the write.
-
-