Script Manager

A script in the clerezza platform has the following properties:
  • name: the name of the script
  • language: the language and its version in which the script is written
  • media type: the media type of the script
  • produced media type: the media type of the script's output
The Script Manager provides a web interface to:
  • install (create) scripts,
  • list and show available scripts,
  • update scripts,
  • delete scripts, and
  • execute scripts

Installing Scripts

The web page for installing scripts is accessible under the path: /admin/script-manager/script-install. There are two ways to install scripts into the platform:
  • type in the script directly into a text box labeled "Script", or
  • upload a file containing the script.
Along with the script installation, there are some information about the script to be delivered:
  • language: the language (and language version) of a script can only take one of the values listed in a drop-down box on the page. Those are languages supported by the platform.
  • name: if a script is installed by uploading a file, the file's name is used as the script's name, otherwise the user must specify the name of the script.
  • media type (optional): if the user does not specify the media type of the installed script, it is extracted from the media type of the script file sent by the browser. If the script is directly typed into a text box and the media type is unspecified, then it will have the default value text/plain.
  • produced media type (optional): if the script returns a GraphNode, then the produced media type of the script is ignored, otherwise the default value of the produced media type is text/plain.
  • execution URI (optional): an execution URI can be specified, under which the execution of the script can be requested.

Manipulating and Executing Scripts

Once a script is installed, it can be manipulated and executed via the path /admin/script-manager/script-overview. A list of all installed scripts will be shown and if a script is selected, its contents as well as information about the script will be shown and can be updated. There are 3 push buttons available to do the followings:
  • save: save changes made to the selected script
  • delete: delete the selected script and all related information
  • execute: execute the selected script
A script can also be executed by sending a GET request on its execution URI.

Managing Execution URIs

A script can have more than one execution URIs. Execution URIs are accessible via the path /admin/script-manager/execution-uri-overview. Through this path, existing execution URIs of a script can be deleted and new ones can be added.

Accessing Platform Services

Three platform services are made available to scripts through Bindings: TcManager, DiscobitsHandler, and ContentGraphProvider. The variables to access those services are tcManager, contentHandler, and contentGraphProvider respectively. Note that those variables have engine scope and in JRuby script their names are preceded with '$', e.g., $tcManager.

Accessing Information about the GET Request on an Execution URI

If a script gets executed through a GET request on one of its execution URIs, the following information about the GET request can be accessed by the script: javax.ws.rs.core.UriInfo, javax.ws.rs.core.Request, and javax.ws.rs.core.HttpHeaders. The variables to access those data are: uriInfo, request, and httpHeaders respectively, and they all have engine scope.