AEM Groovy Console

The AEM Groovy Console provides an interface for running Groovy scripts in the AEM (Adobe CQ) container. Scripts can be created to manipulate content in the JCR, call OSGi services, or execute arbitrary code using the AEM, Sling, or JCR APIs.

License

License

Categories

Categories

Groovy Languages
GroupId

GroupId

com.citytechinc.aem.groovy.console
ArtifactId

ArtifactId

aem-groovy-console
Last Version

Last Version

8.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

AEM Groovy Console
The AEM Groovy Console provides an interface for running Groovy scripts in the AEM (Adobe CQ) container. Scripts can be created to manipulate content in the JCR, call OSGi services, or execute arbitrary code using the AEM, Sling, or JCR APIs.
Project Organization

Project Organization

CITYTECH, Inc.
Source Code Management

Source Code Management

https://github.com/Citytechinc/cq-groovy-console

Download aem-groovy-console

How to add to project

<!-- https://jarcasting.com/artifacts/com.citytechinc.aem.groovy.console/aem-groovy-console/ -->
<dependency>
    <groupId>com.citytechinc.aem.groovy.console</groupId>
    <artifactId>aem-groovy-console</artifactId>
    <version>8.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.citytechinc.aem.groovy.console/aem-groovy-console/
implementation 'com.citytechinc.aem.groovy.console:aem-groovy-console:8.1.0'
// https://jarcasting.com/artifacts/com.citytechinc.aem.groovy.console/aem-groovy-console/
implementation ("com.citytechinc.aem.groovy.console:aem-groovy-console:8.1.0")
'com.citytechinc.aem.groovy.console:aem-groovy-console:jar:8.1.0'
<dependency org="com.citytechinc.aem.groovy.console" name="aem-groovy-console" rev="8.1.0">
  <artifact name="aem-groovy-console" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.citytechinc.aem.groovy.console', module='aem-groovy-console', version='8.1.0')
)
libraryDependencies += "com.citytechinc.aem.groovy.console" % "aem-groovy-console" % "8.1.0"
[com.citytechinc.aem.groovy.console/aem-groovy-console "8.1.0"]

Dependencies

compile (22)

Group / Artifact Type Version
javax.jcr : jcr jar
javax.servlet : servlet-api jar
javax.servlet : jsp-api jar
org.osgi : org.osgi.core jar
org.apache.felix : org.apache.felix.scr jar
org.apache.sling : org.apache.sling.api jar
org.apache.sling : org.apache.sling.jcr.api jar
org.apache.sling : org.apache.sling.jcr.resource jar
org.apache.sling : org.apache.sling.scripting.jsp.taglib jar
com.day.cq.wcm : cq-wcm-api jar
com.day.cq : cq-commons jar
com.day.commons : day-commons-text jar
com.day.cq : cq-search jar
com.day.cq : cq-mailer jar
com.day.cq : cq-tagging jar
com.day.cq.wcm : cq-wcm-taglib jar [5.7.4,5.8.2]
com.adobe.granite : com.adobe.granite.replication.core jar
org.slf4j : slf4j-api jar
org.apache.commons : commons-lang3 jar
org.apache.commons : commons-email jar
org.apache.jackrabbit : jackrabbit-api jar
org.apache.felix : org.apache.felix.scr.annotations jar 1.9.12

provided (2)

Group / Artifact Type Version
org.codehaus.groovy : groovy-all jar 2.4.3
com.citytechinc.aem.groovy.extension : aem-groovy-extension-bundle jar 1.0.1

test (1)

Group / Artifact Type Version
com.citytechinc.aem.prosper : prosper jar 5.0.0

Project Modules

There are no modules declared in this project.

AEM Groovy Console

This project has moved to https://github.com/CID15/aem-groovy-console and will no longer be maintained in this repository.

Overview

The AEM Groovy Console provides an interface for running Groovy scripts in Adobe Experience Manager. Scripts can be created to manipulate content in the JCR, call OSGi services, or execute arbitrary code using the AEM, Sling, or JCR APIs. After ainstalling the package in AEM (instructions below), see the console page for documentation on the available bindings and methods. Sample scripts are included in the package for reference.

Screenshot

Requirements

Compatibility

Groovy Console Version(s) AEM Version(s)
15.x.x, 14.x.x, 13.x.x 6.3, 6.4, 6.5
12.x.x 6.4
11.x.x 6.3
10.x.x, 9.x.x 6.2
8.x.x 6.1
7.x.x 6.0
6.x.x, 5.x.x 5.6 (CQ)
3.x.x 5.5, 5.4 (CQ)

Installation

  1. Download the console package. For previous versions, tags can be checked out from GitHub and built directly from the source (e.g. mvn install).

  2. Verify the installation.

Additional build profiles may be added in the project's pom.xml to support deployment to non-localhost AEM servers.

To enable access to the Groovy Console from /groovyconsole, update the Groovy Console Configuration Service via the OSGi console configuration page to enable the vanity path.

Building From Source

To build and install the latest development version of the Groovy Console (or if you've made source modifications), run the following Maven command.

mvn install -P local

Excluding the Groovy OSGi Bundle

If your AEM instance has multiple applications using Groovy and the groovy-all bundle is already deployed, you can exclude this bundle from the Groovy Console package build with the exclude-groovy-bundle Maven profile. This should prevent issues with conflicting Groovy versions at runtime.

mvn install -P local,exclude-groovy-bundle

Context Path Support

If you are running AEM with a context path, set the Maven property aem.context.path during installation.

mvn install -P local -Daem.context.path=/context

OSGi Configuration

Navigate to the OSGi console configuration page and select the Groovy Console Configuration Service.

Property Description Default Value
Email Enabled? Check to enable email notification on completion of script execution. false
Email Recipients Email addresses to receive notification. []
Script Execution Allowed Groups List of group names that are authorized to use the console. By default, only the 'admin' user has permission to execute scripts. []
Scheduled Jobs Allowed Groups List of group names that are authorized to schedule jobs. By default, only the 'admin' user has permission to schedule jobs. []
Vanity Path Enabled? Enables /groovyconsole vanity path. false
Audit Disabled? Disables auditing of script execution history. false
Display All Audit Records? If enabled, all audit records (including records for other users) will be displayed in the console history. false
Thread Timeout Time in seconds that scripts are allowed to execute before being interrupted. If 0, no timeout is enforced. 0

Batch Script Execution

Saved scripts can be remotely executed by sending a POST request to the console servlet with either the scriptPath or scriptPaths query parameter.

Single Script

curl -d "scriptPath=/var/groovyconsole/scripts/samples/JcrSearch.groovy" -X POST -u admin:admin http://localhost:4502/bin/groovyconsole/post.json

Multiple Scripts

curl -d "scriptPaths=/var/groovyconsole/scripts/samples/JcrSearch.groovy&scriptPaths=/var/groovyconsole/scripts/samples/FulltextQuery.groovy" -X POST -u admin:admin http://localhost:4502/bin/groovyconsole/post.json

Extensions

The Groovy Console provides extension hooks to further customize script execution. The console provides an API containing extension provider interfaces that can be implemented as OSGi services in any bundle deployed to an AEM instance. See the default extension providers in the com.icfolson.aem.groovy.console.extension.impl package for examples of how a bundle can implement these services to supply additional script bindings, compilation customizers, metaclasses, and star imports.

Service Interface Description
com.icfolson.aem.groovy.console.api.BindingExtensionProvider Customize the bindings that are provided for each script execution.
com.icfolson.aem.groovy.console.api.CompilationCustomizerExtensionProvider Restrict language features (via blacklist or whitelist) or provide AST transformations within the Groovy script compilation.
com.icfolson.aem.groovy.console.api.ScriptMetaClassExtensionProvider Add runtime metaclasses (i.e. new methods) to the underlying script class.
com.icfolson.aem.groovy.console.api.StarImportExtensionProvider Supply additional star imports that are added to the compiler configuration for each script execution.

Notifications

To provide custom notifications for script executions, bundles may implement the com.icfolson.aem.groovy.console.notification.NotificationService interface (see the com.icfolson.aem.groovy.console.notification.impl.EmailNotificationService class for an example). These services will be dynamically bound by the Groovy Console service and all registered notification services will be called for each script execution.

Scheduler

The Scheduler allows for immediate (asynchronous) or Cron-based script execution. Scripts are executed as Sling Jobs and are audited in the same manner as scripts executed in the console.

Scheduled Job Event Handling

Bundles may implement services extending com.icfolson.aem.groovy.console.job.event.AbstractGroovyConsoleScheduledJobEventHandler to provide additional post-processing or notifications for completed Groovy Console jobs. See com.icfolson.aem.groovy.console.job.event.DefaultGroovyConsoleEmailNotificationEventHandler for an example of the required annotations to register a custom event handler.

Sample Scripts

Sample scripts can be found in the src/main/scripts directory.

Versioning

Follows Semantic Versioning guidelines.

com.citytechinc.aem.groovy.console

ICF Next

Versions

Version
8.1.0
8.0.3
8.0.2
8.0.1
8.0.0
7.0.2
7.0.1
7.0.0