ist-dresden / composum-nodes

Set of Apache Sling / AEM development tools: JCR browser, user and package management and more
https://www.composum.com/home/nodes.html
MIT License
55 stars 21 forks source link

How to list all packages with versions and their states? #135

Closed pun-ky closed 6 years ago

pun-ky commented 6 years ago

I am building an automation which requires to have knowledge about all packages states on instance.

on AEM there was: /crx/packmgr/list.jsp

{
"pid": "ICF Olson:aem-groovy-console:11.0.0",
"path": "/etc/packages/ICF Olson/aem-groovy-console-11.0.0.zip",
"name": "aem-groovy-console",
"downloadName": "aem-groovy-console-11.0.0.zip",
"group": "ICF Olson",
"groupTitle": "ICF Olson",
"version": "11.0.0",
"description": "The AEM Groovy Console provides an interface for running Groovy scripts in the AEM container. Scripts can be\n        created to manipulate content in the JCR, call OSGi services, or execute arbitrary code using the AEM, Sling,\n        or JCR APIs.",
"thumbnail": "/crx/packmgr/thumbnail.jsp?_charset_=utf-8&path=%2fetc%2fpackages%2fICF%20Olson%2faem-groovy-console-11.0.0.zip&ck=1529385259960",
"buildCount": 1,
"lastModified": 1494956785099,
"lastModifiedBy": "admin",
"created": 1494956785099,
"createdBy": "admin",
"lastUnpacked": 1527677245028,
"lastUnpackedBy": "admin",
"lastWrapped": 1494956785099,
"lastWrappedBy": "admin",
"lastUnwrapped": 1527677244492,
"size": 6934524,
"hasSnapshot": true,
"needsRewrap": false,
"requiresRoot": true,
"requiresRestart": false,
"acHandling": "merge",
"dependencies": [],
"resolved": true,
"filter": [
{
"root": "/apps/groovyconsole/components",
"rules": []
},
{
"root": "/apps/groovyconsole/config",
"rules": []
},
{
"root": "/apps/groovyconsole/install",
"rules": []
},
{
"root": "/apps/groovyconsole/templates",
"rules": []
},
{
"root": "/etc/clientlibs/groovyconsole",
"rules": []
},
{
"root": "/etc/groovyconsole",
"rules": [
{
"modifier": "exclude",
"pattern": "/etc/groovyconsole/scripts(/.*)?"
},
{
"modifier": "exclude",
"pattern": "/etc/groovyconsole/jcr:content/audit(/.*)?"
}
]
},
{
"root": "/home/users/system/groovy-console-system-user",
"rules": []
},
{
"root": "/rep:policy",
"rules": []
}
],
"screenshots": []
},
// ...

generally I don't need to know all of that details, but at least:

package group, package name, package version and state (installed, only uploaded).

Maybe there is some endpoint on Composum already serving this kind of data?

Greetings, Krystian

pun-ky commented 6 years ago

ok got it

curl -u admin:admin -X POST http://localhost:8080/bin/cpm/package.service.html?cmd=ls

pun-ky commented 6 years ago

however to be considered adding

class PackageUtil {

    public static void toJson(JsonWriter writer, JcrPackageDefinition definition)
            throws IOException {
        // ...
        if (lastUnpacked != null) {
            writer.name(JcrPackageDefinition.PN_LAST_UNPACKED).value(dateFormat.format(lastUnpacked.getTime()));
        }
        // ...
    }
}