DATM-59-04 Configure AEM with CONGA
Overview
- Configure AEM OSGi configuration
- Deploy additional AEM packages
- Generate configuration content packages
Git project
Introduction
The GIT project contains CONGA configuration definitions and two CONGA example environments:
definition/src/main/dev-environments/development.yaml
environment/src/main/environments/prod.yaml
The first one is used for testing in the local AEM instance. You will only touch this for this exercise.
The second one is an example for a PROD environment - it is not used in the exercise, but you can have a look what different configuration is generated for the different environment files.
Please not that typically the configuration definition is part of the application Maven module structure and released together with it. For the sake of simplicity no AEM application is included in this training repository, instead the application packages from the wcm.io Sample Application are used, which are available on Maven Central. The wcm.io Sample Application itself also contains a CONGA configuration definition, but this is not used in this exercise.
Exercise
A) Deploy the sample application and predefined configuration
Exercise:
- Execute
mvn clean install
on the root of the training repository - Deploy the application and configuration to your local AEM instance via the script
definition/packages-upload.sh
- This Script uses the CONGA AEM Maven Plugin to deploy the generated AEM packages to your local AEM instance running at port 4502
Validation:
- Open the sample application at http://localhost:4502/editor.html/content/wcm-io-samples/en.html
- Have a look at the generated configuration at
definition/target/configuration/development
environment/target/configuration/prod
B) Deploy Groovy Console on Author
Exercise:
- There is a nice Open Source tool for AEM, the “AEM Groovy Console”: https://github.com/CID15/aem-groovy-console
- The AEM ZIP package for deploying it is also available on Maven Central: https://repo1.maven.org/maven2/org/cid15/aem/groovy/console/aem-groovy-console-all/17.0.0/
- Please extend the role
wcm-io-samples-cms
to include a deployment of this Groovy Console Package - Make the deployment of this file conditional using a configuration parameter, similar as it is already done for the sample content in the same role
- Deploy the Groovy Console only for the author node of the local environment
development.yaml
- Redeploy the application and configuration to your local AEM instance
Validation:
- Open http://localhost:4502/apps/groovyconsole.html - the Groovy Console should be displayed
C) Restrict Access to Groovy Console to Administrators
Preparation - create two new users:
- Create a new non-admin user “author” with password “author” at http://localhost:4502/security/users.html
- Assign this user to group “Authors” (content-authors)
Exercise:
- If you look in http://localhost:4502/system/console/configMgr you will find a configuration “Groovy Console Configuration Service” which has a configuration parameter labeled with “Allowed Groups” - we want to set this to
administrators
to restrict the access to the Groovy console - Enhance the role
wcm-io-samples-cms
to generate an additional OSGi configuration for this service that reconfigures this property to the desired value - Redeploy the application and configuration to your local AEM instance
Validation:
- Log into AEM using the author user
- Open the Groovy Console http://localhost:4502/apps/groovyconsole.html
- Try to execute this script:
def templates = [] as TreeSet
getPage("/content/wcm-io-samples/en").recurse { page ->
def template = page?.template?.path
if (template) {
templates.add(template)
}
}
templates.each {
println it
}
- Log into AEM using the admin user
- Open the Groovy Console http://localhost:4502/apps/groovyconsole.html
- Try to execute the sample from above
D) Add additional logfile for JCR Query Debugging
Exercise:
- We want to debug JCR queries by setting DEBUG log level for these two log categories:
org.apache.jackrabbit.oak.query
org.apache.jackrabbit.oak.plugins.index
- In the role
wcm-io-samples-cms
you will find examples for defining additional loggers for the factory PIDorg.apache.sling.commons.log.LogManager.factory
- Create a new entry with the mentioned log categories, DEBUG log level, and a log file named
logs/query.log
- Redeploy the application and configuration to your local AEM instance
Validation:
- Ensure a
query.log
exists in the local AEM directorycrx-quickstart/logs
- Execute any query in AEM or CRXDE Lite an ensure new log entries are written in this log (please note that several AEM background services also execute queries form time to time, so you will see a log of other messages as well)
E) Make the languages displayed in AEM translator configurable
Exercise:
- AEM comes with a translator tool for managing i18n dictionaries: http://localhost:4502/libs/cq/i18n/translator.html
- By default it displays all languages. But as described here it is also possible to configure the list of languages displayed in the translator
- This is possible by creating a node at
/etc/languages
, node typent:unstructured
, and set a propertylanguages
to list of language codes e.g. de,fr,es
- Generate an AEM package via CONGA automatically that creates this node and multivalued string property
- Add a new configuration parameter to the role
wcm-io-samples-cms
which contains a list of language codes. Set it to the default value “de”, “en” in the role. - Generate a new AEM package from the role
wcm-io-samples-cms
based on a Handlebars JSON template. This JSON file defines the content of the langages node. Use Handlebars logic to fill in the language codes defined in the configuration parameter. Use theaem-contentpackage
post processor to transform the generated JSON to an AEM package. - You can have a look at the file
wcm-io-samples-aem-cms-author-systemusers
generated by the same role as example - it uses the same mechanisms but is more complex. - Configure the list of languages for all nodes to “de”, “en”, “fr”, “it” in the environment
development.yaml
- Redeploy the application and configuration to your local AEM instance
Validation:
- Open http://localhost:4502/libs/cq/i18n/translator.html - you should see for columns with translations labelled DE, EN, FR, IT
F) Add ACLs for translator language configuration
Exercise:
- Currently, the updated list of languages in the Translator http://localhost:4502/libs/cq/i18n/translator.html is only visible for admin users - to fix this we need to add proper ACLs to the node to make it visible for other users as well
- In the JSON file describing the content of the node add a policy node like this (it applies
read
privilege to the build-in groupcontent-authors
):
"rep:policy": {
"jcr:primaryType": "rep:ACL",
"allow": {
"jcr:primaryType": "rep:GrantACE",
"rep:principalName": "content-authors",
"rep:privileges": [
"jcr:read"
]
}
}
- Within the role file you have also set the “Access Control Handling” to “merge” mode for this content package to get the ACL applied - look up the property name in the documentation: https://devops.wcm.io/conga/plugins/aem/extensions.html
- Redeploy the application and configuration to your local AEM instance
Validation:
- Log into AEM using the author user (created in step D)
- Open http://localhost:4502/libs/cq/i18n/translator.html - you should see for columns with translations labelled DE, EN, FR, IT