Introduction

When writing your notification messages you may already have been using GreenLight's expression language without knowing it. By picking a template from the "Expr. Templates" pulldown a code-snippet gets pasted into your message. Later, when the notification is send, this snippet is parsed and replaced with the resulting value.

While the pulldown provides you with a comfortable way of customizing your message, it's not a complete list of all functions available. On the following pages you will find a set of useful functions.

Functions

Syntax

Functions are defined as follows (note: every expression has to start with ${ and end with } ):

PREFIX:FUNCTION_NAME([ARGUMENTS, ..])

Prefixes

Currently the following prefixes are available:

Prefix

Description

gl

GreenLight specific functions

str

String manipulation utils

arr

Array manipulation utils

GreenLight specific functions

Function

Descritpion

Example

Object def(Object obj, Object defaultValue)

Returns the defaultValue if obj is null

${gl:def(result, "no result found"))}

int maxInt()

Returns the maximum value an int can have

${gl:maxInt()}

String concat(String val1, String val2)

Concatenates the two arguments and returns the resulting string

${gl:concat('some', 'value')}

String commonName(String name)

Returns the common server name

${gl:commonName('cn=myServer/o=acme')}

String abbreviatedName(String name)

Returns the abbreviated server name

${gl:abbreviatedName('cn=myServer/o=acme')}

String manipulation functions

Function

Descritpion

Example

boolean isEmpty(String str)

Checks if a String is empty ("") or null

${str:isEmpty(value)}

boolean isBlank(String str)

Checks if a String is whitespace, empty ("") or null

${str:isBlank(value)}

String trim(String str)

Removes control characters from both ends of this String

${str:trim(' text ')}

int indexOf(String str, String searchStr)

Finds the first index within a String

${str:indexOf('abcdefg', 'd')}

int lastIndexOf(String str, String searchStr)

Finds the last index within a String

${str:indexOf('abcdefgd', 'd')}

String substring(String str, int start, int end)

Gets a substring from the specified String

${str:substring('aabbaa', 2, 4)}

String substringBefore(String str, String separator)

Gets the substring before the first occurrence of a separator

${str:substringBefore('myServer/acme', '/')}

String substringAfter(String str, String separator)

Gets the substring before the first occurrence of a separator

${str:substringAfter('name@server', '@')}

String[] split(String str, String separator, int max)

Splits the provided text into an array

${str:split("ab:cd:ef", ":", -1}

String replace(String text, String searchString, String replacement)

Replaces all occurrences of a String within another String

${str:replace('some_string', '_', ' ')}

String abbreviate(String str, int maxWidth)

Abbreviates a String using ellipses

${str:abbreviate('some long text', 5)}

String lowerCase(String str)

Converts a String to lower case

${str:lowerCase('SeRvEr/AcME')}

String upperCase(String str)

Converts a String to upper case

${str:upperCase('server/acme')}

Array manipulation functions

Function

Descritpion

Example

Object[] subarray(Object[] array, int startIndex, int endIndex)

Produces a new array containing the elements between the start and end indices

${arr:subarray(str:split('ab:cd:ef', ':'), 0, 1}

int getLength(Object array)

Returns the length of an array

${arr:getLength(str:split('ab:cd:ef', ':'))}

Object[] remove(Object[] array, int index)

Removes the element at the specified position from the specified array

${arr:remove(str:split('ab:cd:ef', ':'), 0)}

Examples

Combining functions

The following will output the number of Administrator groups for a server:

There are ${arr:getLength(str:split(result.statistics['Server.Administrators'], ',', -1))} Administrator 
groups on server ${gl:commonName(config.nodeDefinition.name)}