Package org.rapidcontext.app.web
Class ProcedureWebService
java.lang.Object
org.rapidcontext.core.storage.StorableObject
org.rapidcontext.core.type.WebService
org.rapidcontext.app.web.ProcedureWebService
- All Implemented Interfaces:
HttpUtil
A procedure API web service. This service is used for executing procedures
through HTTP GET or POST calls. Arguments are automatically matched by name
or from 'arg0'... request parameters.
- Version:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.rapidcontext.util.HttpUtil
HttpUtil.HEADER, HttpUtil.Helper, HttpUtil.METHOD, HttpUtil.STATUS
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The dictionary key for the input arguments data format.static final String
The dictionary key for the output response data format.static final String
The dictionary key for the procedure name prefix.Fields inherited from class org.rapidcontext.core.type.WebService
KEY_DESCRIPTION, KEY_MATCH, matchers, METHODS_GET, METHODS_GET_POST, METHODS_POST, PATH
Fields inherited from class org.rapidcontext.core.storage.StorableObject
dict, KEY_ACTIVATED_TIME, KEY_CLASSNAME, KEY_ID, KEY_TYPE, PREFIX_COMPUTED, PREFIX_HIDDEN
-
Constructor Summary
ConstructorsConstructorDescriptionProcedureWebService
(String id, String type, Dict dict) Creates a new file web service from a serialized representation. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Processes an HTTP GET request.protected void
Processes an HTTP POST request.Returns the input arguments data format.protected String[]
methodsImpl
(Request request) Returns the HTTP methods implemented for the specified request.Returns the output response data format.prefix()
Returns the procedure name prefix.protected Object[]
processArgs
(Procedure proc, Request request, String logPrefix) Extracts procedure arguments from the request parameters.protected Dict
processCall
(String name, Request request, String source) Processes a procedure call and returns the result dictionary.protected void
processProcedure
(Request request) Processes a procedure execution request.Methods inherited from class org.rapidcontext.core.type.WebService
all, description, doDelete, doHead, doOptions, doPatch, doPut, doTrace, errorBadRequest, errorForbidden, errorInternal, errorMethodNotAllowed, errorNotFound, errorUnauthorized, headerAllow, init, matchers, methods, process, session
Methods inherited from class org.rapidcontext.core.storage.StorableObject
activate, activatedTime, destroy, id, isActive, isModified, passivate, path, serialize, sterilize, toString, type
-
Field Details
-
KEY_PREFIX
The dictionary key for the procedure name prefix.- See Also:
-
KEY_INPUT_TYPE
The dictionary key for the input arguments data format.- See Also:
-
KEY_OUTPUT_TYPE
The dictionary key for the output response data format.- See Also:
-
-
Constructor Details
-
ProcedureWebService
Creates a new file web service from a serialized representation.- Parameters:
id
- the object identifiertype
- the object type namedict
- the serialized representation
-
-
Method Details
-
prefix
Returns the procedure name prefix.- Returns:
- the procedure name prefix, or an empty string for none
-
inputType
Returns the input arguments data format.- Returns:
- the input arguments data format
-
outputType
Returns the output response data format.- Returns:
- the output response data format
-
methodsImpl
Returns the HTTP methods implemented for the specified request. The OPTIONS or HEAD methods doesn't have to be added to the result (added automatically later).- Specified by:
methodsImpl
in classWebService
- Parameters:
request
- the request to check- Returns:
- the array of HTTP method names supported
- See Also:
-
doGet
Processes an HTTP GET request.- Overrides:
doGet
in classWebService
- Parameters:
request
- the request to process
-
doPost
Processes an HTTP POST request.- Overrides:
doPost
in classWebService
- Parameters:
request
- the request to process
-
processProcedure
Processes a procedure execution request. This is used to trigger server-side procedure execution with the POST:ed data.- Parameters:
request
- the request to process
-
processCall
Processes a procedure call and returns the result dictionary.- Parameters:
name
- the procedure namerequest
- the request to processsource
- the call source information- Returns:
- the process result dictionary (with "data" or "error" keys)
-
processArgs
protected Object[] processArgs(Procedure proc, Request request, String logPrefix) throws IOException, ProcedureException Extracts procedure arguments from the request parameters. The arguments will be unserialized from JSON unless input format isn't "text".- Parameters:
proc
- the procedurerequest
- the request to processlogPrefix
- the log prefix- Returns:
- an array with procedure arguments
- Throws:
IOException
- if an argument wasn't valid JSONProcedureException
- if an argument was missing
-