Class Annotators


  • @RequiredRole("admin")
    public class Annotators
    extends APIRequestHandler
    Servlet that manages installation/upgrade/uninstallation of annotators.

    /api/admin/annotator

    Only the POST method is accepted. The protocol for installation of an annotator module is:

    1. Upload the annotator .jar file with a multipart POST request (the first file parameter encountered is taken, regardless of its name). The response is a JSON-encoded envelope with a "model" object with the following attributes:
      jar
      The name of the .jar file uploaded (this must be used in the subsequent request).
      annotatorId
      The ID of the annotator found in the .jar file.
      version
      The version of the annotator implementation.
      installedVersion
      The version of the already-installed annotator implementation, if any.
      hasConfigWebapp
      Whether or not the annotator implements a 'config' webapp
      hasTaskWebapp
      Whether or not the annotator implements a 'task' webapp
      hasExtWebapp
      Whether or not the annotator implements an 'ext' webapp
      info
      A complete HTML document containing a description of the annotator.
    2. Make a POST request with the following application/x-www-form-urlencoded parameters:
      action
      Either install or cancel
      jar
      The name of the .jar file, as returned in the response to the preovious request.
      If action was instsall, then the response is a JSON-encoded envelope with a "model" object with the following attributes:
      jar
      The name of the .jar file, as returned in the response to the preovious request.
      annotatorId
      The ID of the annotator found in the .jar file.
      url
      The URL that must be visited next in order to complete the installation by configuring the annotator. This may be the URL of the 'config' webapp if there is one, or the 'setConfig' request if not.
    3. Visit the url returned in the reponse to the previous request. The resulting response will be an HTML document.

    Annotators can be uninstalled by making a POST request with the following application/x-www-form-urlencoded parameters:

    action
    uninstall
    annotatorId
    The ID of the annotator.
    Author:
    Robert Fromont robert@fromont.net.nz
    • Constructor Detail

      • Annotators

        public Annotators​(File tempDir)
        Default constructor.
    • Method Detail

      • post

        public javax.json.JsonObject post​(RequestParameters parameters,
                                          Consumer<Integer> httpStatus,
                                          File annotatorDir)
        POST handler - receive an uploaded file or an installation confirmation.
        Parameters:
        parameters - Request parameter map.
        httpStatus - Receives the response status code, in case or error.
        annotatorDir - The directory in which annotator jars and their files are stored.
        Returns:
        JSON-encoded object representing the response