2
votes

AEM 5.6.1.

I have a package. I'd like to be able to 'sniff' the version of AEM a user/administraor is using when attempting to install the package.

The version is available in the front-end via Tools -> Web Console -> Main -> Product Information

I appreciate I could parse the above page and extract but surely there's a more elegant way to do it?

I've looked through Adobe docs on Packages: (I would post links but SO complaining I've not got enough reputation) And had a good hunt around SO.

The closest I've come is through this doc: https://helpx.adobe.com/experience-manager/using/programmatically-accessing-cq-content-using.html and assuming that the details found in CRX @ /etc/packages/day:

  • cq5
  • cq560
  • cq561

represent a typical install?

4

4 Answers

5
votes

Current versions of AEM provide this info is via the ProductInfoService described at [1], which can return a number of ProductInfo objects.

This is already available in 5.6.1, also via the OSGi console at /system/console/status-productinfo .

[1] https://docs.adobe.com/docs/fr/aem/6-0/develop/ref/javadoc/com/adobe/granite/license/package-summary.html

1
votes

To pro-grammatically retrieve the product version of any running AEM instance can be done by the following code snippet.

@Reference 
private ProductInfoProvider productInfo;

String version = productInfo.getProductInfo().getShortVersion();

First we need to inject the ProductInfoProvider service or define the references of ProductInfoProvider into your service and use following functions calls to get the version information as productInfo.getProductInfo().getShortVersion();

0
votes

The product information is stored on the node "/libs/cq/core/productinfo" , you can read the information from those nodes.

You don't specify if you'll have repository access while the package is being installed. In case you want the data as JSON over HTTP just hit the path with ".json" extension

Source : Checked the network requests made by the aem developer chrome plugin

0
votes

We can read AEM product Version from the node "/libs/cq/core/productinfo" in CRXDE

def productInfo = request.resourceResolver.getResource("/libs/cq/core/productinfo")?.adaptTo(ValueMap) ?: [:]

String version = productInfo["shortVersion"]

Reference: https://forums.adobe.com/thread/2338675