Platforms and Technology

4 Useful Features of Composum Browser

Composum Banner

Composum Browser is an Open Source JCR Node browser for Apache Sling which bills itself as “the Swiss knife for the repository”. Composum Browser is included in Apache Sling since Sling 9 and is available in all versions of Apache Sling CMS.

While Composum Browser certainly supports navigating the JCR repository structure in Apache Sling, it can do much more. Here are four useful features in Composum Browser:

Edit Files

Editing files in the repository using Composum is pretty straight-forward. First select the node for the file, select the Text / Code View and then select the Edit Text button which will open the editor.

Edit a File in Composum

Run Groovy Scripts

Groovy scripts are tremendously helpful to run ad-hoc scripts for extracting report data, performing bulk updates on the fly or debugging issues.

To execute a Groovy script, create a file with the .groovy extension and then execute the script in the Composum editor. One important thing to note is that you want to make sure your return is not session-bound, because it closes the resource resolver before printing the result. 

Using Composum Groovy Executor

Default Variables

The Composum Groovy script executor binds the following variables for your use:

Platforms & Technology - A Business Leaders Guide to Key Trends in Cloud
A Business Leaders Guide to Key Trends in Cloud

Cloud’s dynamic nature can make it hard to keep up with the wide-ranging capabilities that make it a key enabler to improve business processes and support a larger digital transformation.

Get the Guide

OSGi Services

Since Groovy is executing in the context of an OSGi container, you may want to retrieve an OSGi service, unfortunately, it’s not quite as easy as the AEM Groovy Console, but it can be done:

import org.osgi.framework.*;
import org.apache.sling.api.resource.*;

BundleContext bundleContext = FrameworkUtil.getBundle(ResourceResolverFactory.class).getBundleContext();
def serviceReference = bundleContext.getServiceReference(ResourceResolverFactory.class);
def service = bundleContext.getService(serviceReference);
println service;
bundleContext.ungetService(serviceReference); 

Installing Groovy

Naturally, to use the Groovy script execution feature in Composum Browser, you need Groovy installed. At the time this post was written, Groovy is not installed in the Apache Sling Starter 11 or Sling CMS 0.16.2. The easiest way to install Groovy is to install Groovy All 2.4.19. In future versions of Sling CMS and Sling Starter the expectation is Groovy 3 will be pre-installed.

View System Nodes

In more recent versions of Composum (at least 1.12+) you can see the system nodes in the JCR, including:

  • JCR Namespaces
  • JCR Node Types
  • Supported Privileges
  • Privilege Storage
  • Version Storage

To see the system properties change the Filter for tree option to unfiltered and then expand /jcr:system.

View System Configuration in Composum

Download Query File

Composum supports executing queries in the search bar. In addition, you can download the results of the query by selecting the Export Query Result dropdown on the right-hand side of the search bar. The export option supports JSON (full tree), CSV (summary), and TSV (summary). 

Exporting Query Composum

Composum Node Browser is a powerful tool for managing Apache Sling based repositories. Check it out via the Apache Sling Starter or Sling CMS  or download Composum directly from GitHub.

About the Author

Dan is a certified Adobe Digital Marketing Technologist, Architect, and Advisor, having led multiple successful digital marketing programs on the Adobe Experience Cloud. He's passionate about solving complex problems and building innovative digital marketing solutions. Dan is a PMC Member of the Apache Sling project, frequent Adobe Beta participant and committer to ACS AEM Commons, allowing a unique insight into the cutting edge of the Adobe Experience Cloud platform.

More from this Author

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to the Weekly Blog Digest:

Sign Up