Skip to content

Commit

Permalink
UNOMI-847: Updated the Groovy Action documentation (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fgerthoffert authored Aug 27, 2024
1 parent c0a2bc8 commit 3c4c3f2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions manual/src/main/asciidoc/configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ Note that when a groovy action is deleted by the API, the action type associated

In this short example, we’re going to create a Groovy Action that will be adding “Hello world!” to the logs whenever a new view event is triggered.

The first step consists in creating the groovy script on your filesystem, start by creating the file `hello-world.groovy`:
The first step consists in creating the groovy script on your filesystem, start by creating the file `helloWorldGroovyAction.groovy`:

[source,groovy]
----
Expand All @@ -474,14 +474,16 @@ def execute() {

As the last instruction of the script is `EventService.NO_CHANGE`, data will not be persisted.

Once the action has been created you need to submit it to Unomi (from the same folder as `hello-world.groovy`).
Once the action has been created you need to submit it to Unomi (from the same folder as `helloWorldGroovyAction.groovy`).
[source,bash]
----
curl -X POST 'http://localhost:8181/cxs/groovyActions' \
--user karaf:karaf \
--form 'file=@hello-world.groovy'
--form 'file=@helloWorldGroovyAction.groovy'
----

Important: A bug ( https://issues.apache.org/jira/browse/UNOMI-847[UNOMI-847] ) in Apache Unomi 2.5 and lower requires the filename of a Groovy file being submitted to be the same than the id of the Groovy action (as per the example above).

Finally, register a rule to trigger execution of the groovy action:
[source,bash]
----
Expand Down

0 comments on commit 3c4c3f2

Please sign in to comment.