Class ProcedureWebService

All Implemented Interfaces:
HttpUtil

public class ProcedureWebService extends WebService
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
  • Field Details

    • KEY_PREFIX

      public static final String KEY_PREFIX
      The dictionary key for the procedure name prefix.
      See Also:
    • KEY_INPUT_TYPE

      public static final String KEY_INPUT_TYPE
      The dictionary key for the input arguments data format.
      See Also:
    • KEY_OUTPUT_TYPE

      public static final String KEY_OUTPUT_TYPE
      The dictionary key for the output response data format.
      See Also:
  • Constructor Details

    • ProcedureWebService

      public ProcedureWebService(String id, String type, Dict dict)
      Creates a new file web service from a serialized representation.
      Parameters:
      id - the object identifier
      type - the object type name
      dict - the serialized representation
  • Method Details

    • prefix

      public String prefix()
      Returns the procedure name prefix.
      Returns:
      the procedure name prefix, or an empty string for none
    • inputType

      public String inputType()
      Returns the input arguments data format.
      Returns:
      the input arguments data format
    • outputType

      public String outputType()
      Returns the output response data format.
      Returns:
      the output response data format
    • methodsImpl

      protected String[] methodsImpl(Request request)
      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 class WebService
      Parameters:
      request - the request to check
      Returns:
      the array of HTTP method names supported
      See Also:
    • doGet

      protected void doGet(Request request)
      Processes an HTTP GET request.
      Overrides:
      doGet in class WebService
      Parameters:
      request - the request to process
    • doPost

      protected void doPost(Request request)
      Processes an HTTP POST request.
      Overrides:
      doPost in class WebService
      Parameters:
      request - the request to process
    • processProcedure

      protected void processProcedure(Request request)
      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

      protected Dict processCall(String name, Request request, String source)
      Processes a procedure call and returns the result dictionary.
      Parameters:
      name - the procedure name
      request - the request to process
      source - 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 procedure
      request - the request to process
      logPrefix - the log prefix
      Returns:
      an array with procedure arguments
      Throws:
      IOException - if an argument wasn't valid JSON
      ProcedureException - if an argument was missing