Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save anupammaiti/967d6ded193e966b99fc381c96935d69 to your computer and use it in GitHub Desktop.
Save anupammaiti/967d6ded193e966b99fc381c96935d69 to your computer and use it in GitHub Desktop.
AEM/CQ cURL: Adding include/exclude rules to package filters
# Adding include/exclude rules to CQ/AEM package filters through cURL.
# Through a simple search, you will find numerous lists of CQ/AEM cURL commands.
# However, I haven't seen an example of adding rules to package filters. The
# JSON "rules" key takes an array value. You can leave the array empty if you
# don't need to include any rules. The array is of JSON objects with a
# "modifier" key and value of "include" or "exclude", and a "pattern" key with
# your path or regular expression as the value.
# create package
curl -u admin:admin -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/my_packages/testpackage?cmd=create \
-d packageName=testpackage \
-d groupName=my_packages
# add filters
curl -u admin:admin -X POST http://localhost:4502/crx/packmgr/update.jsp \
-F path=/etc/packages/my_packages/testpackage.zip -F packageName=testpackage \
-F groupName=my_packages \
-F filter="[{\"root\" : \"/content/my-site\", \"rules\": [{\"modifier\" : \"exclude\", \"pattern\" : \"/content/my-site/(.*)/folder-to-exclude(/.*)?\"}]}]" \
-F '_charset_=UTF-8'
# build package
curl -u admin:admin -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/my_packages/testpackage.zip?cmd=build
@anupammaiti
Copy link
Author

The below command actually rewrite the filter every time whenever command is executed, this is a problem when running through loops in shell script. To prevent this just remove "rw".
curl -u admin:admin -F root="/content/dam/onlocation" http://localhost:4502/etc/packages/my_packages/testpackage.zip/jcr:content/vlt:definition/filter/f2.rw.html

So the new command should be
curl -u admin:admin -F root="/content/dam/onlocation" http://localhost:4502/etc/packages/my_packages/testpackage.zip/jcr:content/vlt:definition/filter/f2.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment