API v1.0 is deprecated

There are several predefined injected APIs, which can be used directly from the script code. The new version promotes use of holder object $ and corresponding getters. There are four major types of injected APIs - objects, services, utilities and extensions:

Objects

  • context - a standard Map that can be used as a context holder during execution.

$.getExecutionContext();


  • out - the standard System output, which is redirected to the trace file.

$.getSystemOutput();


  • datasource - the default JDBC Datasource configured at server instance level.

$.getDatasource();


  • datasources - the container of the custom JDBC Datasources configured at server instance level.

$.getNamedDatasources();


$.getRequest();


$.getResponse();


$.getSession();


  • repository - the reference to Dirigible’s Content Repository

$.getRepository();


  • input - the standard Request’s input stream InputStream object

$.getRequestInput();


  • user - the name of the current logged-in user

$.getUserName();


$.getInitialContext();


  • storage - simple binary storage - put(path, data), get(path), clear() and delete(path) are supported. Interface can be found here.

$.getBinaryStorage();


  • fileStorage - simple file storage - put(path, data), get(path), clear() and delete(path) are supported. Interface can be found here.

$.getFileStorage();


  • config - simple configuration storage - put(path, data), get(path), clear() and delete(path) are supported. Interface can be found here.

$.getConfigurationStorage();


Services

  • mail - a service linking the underlying mail server provided by the platform. Interface can be found here.

$.getMailService();


$.getExtensionService();


  • indexer - indexing service uses Apache Lucene. Method getIndex([index name]) returns an IIndex instance. Interface can be found here.

$.getIndexingService();


  • messageHub - passive message hub with functions: subscribe(client, topic), send(client, topic, subject, body), receive(client, topic?). Optional functions: registerClient(client), registerTopic(client), cleanup(). Interface can be found here.

$.getMessagingService();


  • connectivity - a service linking the underlying configuration storage provided by the platform. Interface can be found here.

$.getConnectivityService();


  • templatingEngine - a service exposing the internal Velocity engine to users. Interface can be found here.

$.getTemplatingService();


Utilities

$.getIOUtils();


  • http - Apache Commons Http Client wrapped utility object with methods:
    • [HttpGet](http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/methods/HttpGet.html) createGet(strURL)
    • [HttpPost](http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/methods/HttpPost.html) createPost(strURL)
    • [HttpPut](http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/methods/HttpPut.html) createPut(strURL)
    • [HttpDelete](http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/methods/HttpDelete.html) createDelete(strURL)
    • [DefaultHttpClient](http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/DefaultHttpClient.html) createHttpClient()
    • void consume([HttpEntity](http://hc.apache.org/httpcomponents-core-4.2.x/httpcore/apidocs/org/apache/http/HttpEntity.html) entity) Class can be found here.

$.getHttpUtils();


  • base64 - Apache Commons Codecs Base64

$.getBase64Utils();


  • hex - Apache Commons Codecs Hex

$.getHexUtils();


  • digest - Apache Commons Codecs Digest

$.getDigestUtils();


  • url - URLEncode and URLDecoder wrapped in an object with methods:
    • void encode(String s, String enc)
    • void decode(String s, String enc) Class can be found here.

$.getUrlUtils();


$.getUploadUtils();


  • uuid - Universally Unique Identifier (UUID) 128-bit generator

$.getUuidUtils();


  • db - an utillity object with methods:
    • createSequence(sequenceName, start)
    • getNext(sequenceName)
    • dropSequence(sequenceName)
    • existSequence(sequenceName)
    • createLimitAndOffset(limit, offset) - used for paging
    • createTopAndStart(limit, offset) - used for paging Class can be found here.

$.getDatabaseUtils();


$.getXssUtils();


  • xml - XML to JSON and vice-versa: toJson(xmlString) and fromJson(jsonString). Class can be found here.

$.getXmlUtils();


  • get - getter for instance parameters

$.get(key);


  • set - setter for instance parameters

$.set(key, value);


Extensions

  • wiki - Confluence to HTML converter utility. Method toHtml([confluence text]) renders it as HTML. The latest version supports also Markdown, Textile, TracWiki and TWiki. Class can be found here.

$.get(“wiki”);


Samples about how to use the APIs can be found at Dirigible Samples.

Edit