Reputation: 68
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:
represent a typical install?
Upvotes: 2
Views: 2365
Reputation: 353
For AEM 6.5
com.adobe.granite.license.ProductInfoProvider;
com.adobe.granite.license.ProductInfo;
@OSGiService
private ProductInfoProvider productInfoProvider;
ProductInfo productInfo = productInfoProvider.getProductInfo();
productInfo.getVerion().toString(); //6.5.13.0
productInfo.getShortVersion(); //6.5
Thanks
Upvotes: 0
Reputation:
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();
Upvotes: 1
Reputation: 3402
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
Upvotes: 0
Reputation: 6100
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
.
Upvotes: 5