How to Use Artifactory Query Language (AQL) to Obtain Data from an Archive

How to Use Artifactory Query Language (AQL) to Obtain Data from an Archive

AuthorFullName__c
Ino Choi
articleNumber
000004994
ft:sourceType
Salesforce
FirstPublishedDate
2021-06-29T17:49:05Z
lastModifiedDate
2024-03-10T07:46:48Z
VersionNumber
7

Artifactory features default-enabled capabilities, known as primary Domains, which can assist you in searching for data in Artifactory. One of these domains, called Archive, allows you to browse the contents of archived artifacts (and can be altered by editing the archive MIME-type in the mimetypes.xml file, which is located in the $ARTIFACTORY_HOME/etc/).

Here's an example: Let’s say you'd like to get a file from inside of Archive. Instead of downloading Archive in its entirety, you'd simply search its contents for the file you want to see if it's there by doing the following:

curl -XPOST -u <ADMIN> <ARTIFACTORY_URL>/artifactory/api/search/aql -H "Content-type: text/plain" -d
'archive.entries.find (
    {
        "archive.item.repo":{"$eq":"<repo name>"},
        "archive.item.name":{"$eq":"<archive name>"}
    }
)'
If you find what you're looking for, download only that file by using the Archive Entry Download REST API.

However, when the primary domain is archive, a non-admin user will not be able to perform this AQL search. Using the example above, if a non-admin user attempts to perform an archive.entries.find the output will yield no results:
{
"results" : [  ],
"range" : {
  "start_pos" : 0,
  "end_pos" : 0,
  "total" : 0
}

In this case, the non-admin user will have to use the items primary domain and add the include tag to obtain similar information:
curl -XPOST -u <USER> <ARTIFACTORY_URL>/artifactory/api/search/aql -H "Content-type: text/plain" -d 'items.find ({"name":{"$eq":"<archive name>"}}).include("archive.entry")'