3.4.1. Loading and saving script in JCR

There are two ways to save a script in JCR. The first way is to save it at server startup time by using configuration.xml and the second way is to upload the script via HTTP.

Loading script at startup time

This way can be used for loading prepared scripts. To use this way, you need to configure org.exoplatform.services.jcr.ext.script.groovy.GroovyScript2RestLoaderPlugin. See the simple configuration example below.

        <property name="autoload" value="true" />
        <property name="path" value="file:/home/andrew/JcrGroovyTest.groovy" />

If the specified node does not exist, it will be created. The list of scripts is set by properties-params. Name of each properties-param will be used as node name for stored script. The autoload property deploys this script at startup time, and the path property sets the source of script to be loaded. In this example, the single script is loaded from the local file: /home/andrew/JcrGroovyTest.groovy.

Loading script via HTTP

This is sample of HTTP requests. In this example, the script is loaded from the test.groovy file.

andrew@ossl:~> curl -u root:exo \
-H 'Content-type:script/groovy' \
--data-binary @test.groovy \

This example imitates sending data with the HTML form ('multipart/form-data'). The autoload parameter is optional. If the autoload parameter is set to "true" (autoload=true), the script will be instantiated and deployed immediately.

andrew@ossl:~> curl -u root:exo \
-F "file=@test.groovy;name=test" \
-F "autoload=true" \
Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus