How to programmatically retrieve product version of AEM/CQ5 - aem

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?

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

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();

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

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

Related

Is there a REST API for Jenkins plugins?

I'm trying to write a script that quickly checks if our Jenkins plugins are up to date. I know that this is a built in feature in Jenkins, but for security reasons, our Jenkins instance doesn't have internet access.
I know that I can get a lot of information about a plugin, including version, from:
https://plugins.jenkins.io/<name-of-plugin>
However, I can't get it to return anything other than HTML. I could scrape the HTML for the version number, but if there is a stable API that returns JSON or similar, that would be preferred. I'm pretty sure Jenkins isn't scraping HTML to check for updates, so the API must exist. Does anyone know where it is?
There seem to be two solutions available. I ended up scraping:
https://updates.jenkins.io/download/plugins/<name-of-plugin>
The latest version is always in the second column of the second row, so scraping is trivial. It works well most of the time, but sometimes the connection is refused, which I assume might be due to of the volume of requests sent by the script.
Another option that I found is to download the following JSON file:
https://updates.jenkins.io/current/update-center.actual.json
It is currently 1.7MB and contains information about the latest version of all Jenkins plugins. It also contains meta data like dependencies, which allows your script to validate that all dependencies are satisfied.
Unfortunately I haven't found a way to download JSON for individual plugins, so you either have to scrape HTML for individual plugins or download a massive JSON for all plugins.
Update: I found the API:
https://plugins.jenkins.io/api/plugin/<name-of-plugin>
And I also found the source code and the documentation:
https://github.com/jenkins-infra/plugin-site-api

Accessing AEM 6.2 error logs over HTTP

In previous versions of AEM, certainly in CQ 5.6 and AEM 6.0, it was possible to tail the error logs over HTTP, without connecting to the server over SSH.
For example, I could get the last 1000 lines from the error log of my AEM author instance by calling:
http://localhost:4502/bin/crxde/logs?tail=1000
This seems to no longer be possible in AEM 6.2, this path does not resolve to anything.
Is there another way I could still tail the log over HTTP?
A colleague answered this question for me on a chat so I'm putting it here to make it easier to find in the future.
There's now a neat utility in the OSGi console that allows one to view the logs as well as configure the various loggers. You can find it at http://localhost:4502/system/console/slinglog
The Appender tab provides links to the various log files that can be used to load logs over HTTP.
Here's an example request it makes:
http://localhost:4502/system/console/slinglog/tailer.txt?tail=1000&name=%2Flogs%2Ferror.log
As you can see, both the log file name and the tail parameter can be specified. You can also use grep with both simple phrases and regular expressions.
This is a built-in feature of Apache Sling.
In addition FYI, you can also find the status-slinglogs where you can perform log file downloads in a zip and logger actions in a txt to your local at /system/console/status-slinglogs
http://localhost:4502/system/console/status-slinglogs
and the direct urls for the downloading these zip files are as below
http://localhost:4502/system/console/status-slinglogs.zip
http://localhost:4502/system/console/status-slinglogs/configuration-status-20170126-183246.zip (where as 20170126-183246 is and time stamp)
You should not be looking at log files via CRXDE lite.
log files in 6.2 are project specific - better to open them from a text editor.
see attached screenshot.
Hope this helps!
Regards,
Prince
You can curl the log with e.g.:
curl -u admin:admin 'http://localhost:4502/system/console/slinglog/tailer.txt?tail=4000&name=%2Flogs%2Ferror.log'
where 4000 is the number of lines you want to get.
I recently wrote a tool named "Log Tailer Plus" to solve exactly this problem. It's entirely free/open source - Take a look at a post describing usage here : https://blogs.perficientdigital.com/2019/05/14/introducing-aem-logtailerplus/
TLDR; You can grab an AEM package from here ( https://github.com/prftryan/LogTailerPlus ) install it to your machine, and access via http://localhost:4502/log-tailer-plus (if local) or http://server:port/log-tailer-plus
This tool will allow you to follow any number of logs at once by leveraging the out of the box logging endpoint(/system/console/tailer ) as well as dynamically checking active OSGI Logging Logger configurations. Currently, highlighting is supported, but only for relatively standard logging patterns (it's done via regex).
This is a new release, works on AEM 6.2+. Enjoy

How to get prereleased packages list using Nuget.Core?

I'm trying to use Nuget.Core to find Microsoft.Bcl.Immutable package (it is currently in prerelease state). DataServicePackageRepository.SupportsPrereleasePackages always returns false and I can't find any way to change it.
Id there a way to work with prereleased packages, located at nuget.org using Nuget.Core APIs?
The problem was using v1 nuget API, located at http://packages.nuget.org/v1/FeedService.svc/.
Second version API http://packages.nuget.org/api/v2/ supports exposing prereleased packages in search results.

Mylyn connector for sourceforge feature/bug tracking system

I haven't found any clear information about this around.
Is it possible to integrate the sourceforge tracking system for bugs/features with Mylyn?
I've found this page that seems a bit old (indeed the link for downloading the general connector does not work).
Anyone have a clue about this? It is possible to realise such a kind of connection?
Yes with the move of SourceForge to use Allura the configuration on the page you highlighted is outdated.
I posted details on getting the Web Template Connector to work for Allura at http://officefloor.wordpress.com/2012/12/10/allura-sourceforge-mylyn-connector/
The generic connector is now in the Mylyn incubator. Use this download site:
http://download.eclipse.org/mylyn/incubator/3.7 (for Eclipse 3.6, 3.7, 3.8)
Since I wasn't able to get it running – maybe it's because of Eclipse Luna or something else – I slightly modified Daniel's method which partially uses the REST interface:
Basic Configuration
Add the following parameters and appropriate values to the table unter Additional Settings section in the Properties for Task Repository dialog:
project – your so-called UNIX name of the project
tickets – the ticketing application, e.g. bugs or features
bearer_token – you need to set-up a bearer token as described in the Allura documentation
under Advanced Configuration, use:
Task URL: ${serverUrl}/p/${project}/${tickets}/ (the same as in Daniel's method)
New Task URL: ${serverUrl}/p/${project}/${tickets}/new (the same as in Daniel's method)
Query Request URL: ${serverUrl}/rest/p/${project}/${tickets}?access_token=${bearer_token}
Query Pattern: \{"summary":\s*"({Description}.+?)",\s*"ticket_num":\s*({Id}.+?)\}
Milestone query
To query tasks by milestones, use the following parameters in your Edit Query configuration:
add a parameter milestone with e.g. M1 to the parameter table
use the following Query URL: ${serverUrl}/rest/p/${project}/${tickets}/search?q=_milestone%3A${milestone}&access_token=${bearer_token}

vb6 xcopy deployment

Can any one tell me how to convert an legacy application which is vb6 ( COM dll's ocx and exes) to use Regfree COM .
I tried opening the dlls in visual studio and created manifest file, but some of the dlls it is giving error.
Is there any tools out there which will help me to do this process?
I tried a tool from codeproject which is called regsvr42, which is not creating the manifest fully.
I used tools like PE explorer where I get all the typelib information , but converting them into manifest files is too difficult.
We have started migrating that to .NET, for some months we have to deploy it, it will easier if it is xcopy based deployment.
To create manifest files you can try to use Make My Manifest from http://mmm4vb6.atom5.com/.
EDIT The MMM website is down. I see here that the author was having trouble with their hosting and has provided another location to get Make My Manifest - download it here.
If you can control creation of objects you can use DirectCOM from http://www.thecommon.net/10.html
Keep in mind that if one of used DLLs or OCXs is creating other COM objects dynamically with CreateObject calls, that reference will not be stored in vbp project file and you won't get full manifest file. Probably you will have to catch object creations while the application is running. Depends.exe application can profile running application and report all used dlls. I don't know if there is tool that can find additional COM related information.
There is an excellent walkthrough of what to do in this article on MSDN: Registration-Free Activation of COM Components: A Walkthrough.
Make My Manifest can accomodate late binding as well as early binding. You simply have to add the references to the late-bound dependencies manually, by file location or by ProgId.
You might look at http://mmm4vb6.atom5.com/mmm-demo-1248.html for additional help in using the utility.
MakeMyManifest is well spoken of as an automatic tool for creating manifests for VB6 projects, haven't tried it myself.
DirectCOM also has fans, again I haven't tried it.
EDIT The MMM website is down. I see here that the author was having trouble with their hosting and has provided another location to get Make My Manifest - download it here.
There is a semi-automatic technique. You can create the manifests with Visual Studio 2008 (you can use a free version like Visual Basic Express Edition). Then make a couple of edits by hand to make the manifests suitable for use from VB6. See this section of this MSDN article for step-by-step instructions - ignore the rest of the article which is about ClickOnce.