Skip to content

Constants

New feature

Since 6.10.15

Purpose

A DSL that exposes commons constants from Platform 6.

Methods

Binding name: p6.const


mime

Provides access to common MIME types.

Syntax

string p6.const.mime.[type]

Available types:

  • JSONapplication/json
  • XMLapplication/xml
  • CSVtext/csv
  • PDFapplication/pdf
  • XLSXapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  • XLSapplication/vnd.ms-excel
  • ZIPapplication/zip
  • HTMLtext/html
  • TEXTtext/plain
  • OCTETapplication/octet-stream
Example
rest("/apis/sample")
    .post("/data")
    .consumes(p6.const.mime.JSON)
    .produces(p6.const.mime.JSON)
    .to("p6cmb://scripts?platform6.request.action=execute&id=simpleScript")
    .routeId("RestCall")

service request

Provides access to common service request constants.

Syntax

string p6.const.service.request.[type]

Available types:

  • USERplatform6.request.user
  • ACTIONplatform6.request.action
  • COMMON_ACTIONplatform6.request.common.action
Example
final def cm = [headers: [
     (p6.const.service.request.ACTION) : 'status'
 ]]
p6.service.request('platform6.scripts', cm, {
    cmr, e ->
        println cmr
        if( null != e) throw e
})

service response

Provides access to common service response constants.

Syntax

string p6.const.service.response.[type]

Available types:

  • STATUSplatform6.response.status
  • VALUEplatform6.response.value
  • EXCEPTIONplatform6.response.exception
  • EXCEPTION_MSGplatform6.response.exception.message
  • UNCAUGHT_EXCEPTIONplatform6.response.uncaught.exception
Example
if (p6.pipeline.get(p6.const.service.response.STATUS) == 'ERROR') {
    p6.log.error 'Service error: ' + p6.pipeline.get(p6.const.service.response.EXCEPTION_MSG)
} else {
    p6.log.info 'Service OK: ' + p6.pipeline.get(p6.const.service.response.VALUE)
}