Skip to content

CURL it out – Adobe CQ5 Curl Commands and Usage

February 13, 2013

Run JCR query builder API:

Find “all” page references for a given image/asset in a jcr path. The below command will return in JSON format:
curl -s -u ${username}:${password} -X GET http://localhost:4502/bin/querybuilder.json?path=/content/my-site&1_property=fileReference&1_property.value=/content/dam/my-site/image.jpg&p.limit=-1
*Note: -1 in the p.limit will return all page references else prints only 10.

You can also specify the required number of page references; something like below which will return only 20 page references:
curl -s -u ${username}:${password} -X GET http://localhost:4502/bin/querybuilder.json?path=/content/my-site&1_property=fileReference&1_property.value=/content/dam/my-site/image.jpg&p.limit=20

To find all pending Jobs
curl -s -u admin:admin “http://localhost:4502/bin/querybuilder.json?&path=/var/eventing/jobs&type=slingevent:Job&p.limit=-1&fulltext=/com/day/cq/replication/job&fulltext.relPath=@slingevent:topic&property.and=true&property=slingevent:finished&property.operation=not&orderby=slingevent:created&orderby.sort=asc”

To find all Blocking Jobs
curl -s -u admin:admin “http://localhost:4502/bin/querybuilder.json?path=/var/eventing/jobs/anon&type=slingevent:Job&rangeproperty.property=event.job.retrycount&rangeproperty.lowerBound=1”

CQ Package Manager Commands:
Uninstall a bundle (use http://localhost:4502/system/console/bundles to access the Apache Felix web console)
curl -u admin:admin -daction=uninstall http://localhost:4505/system/console/bundles/”name-of-bundle”
Upload a package AND install
curl -u admin:admin -F file=@”name of zip file” -F name=”name of package” -F force=true -F install=true http://localhost:4502/crx/packmgr/service.jsp
Upload a package DO NOT install
curl -u admin:admin -F file=@”name of zip file” -F name=”name of package” -F force=true -F install=false http://localhost:4502/crx/packmgr/service.jsp
Rebuild an existing package in CQ
curl -u admin:admin -X POST http://localhost:4502:/crx/packmgr/service/.json/etc/packages/name_of_package.zip?cmd=build

Download a package:
curl -u admin:admin http://localhost:4502/etc/packages/export/name_of_package.zip > name of local package file
Upload a package
curl -u admin:admin -F package=@”name_of_package.zip” http://localhost:4502/crx/packmgr/service/.json/?cmd=upload
Install a package
curl -u admin:admin -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/export/name of package?cmd=install

List contents of a package
$ curl -u admin:admin -X POST http://localhost:4502/crx/packmgr/service/console.html/etc/packages/day/cq561/product/cq-content-5.6.1.20130606.zip?cmd=contents

 
CQ Bundle Manager Commands:
Install a bundle
curl -u admin:admin -F action=install -F bundlestartlevel=20 -F bundlefile=@”name of jar.jar” http://localhost:4502/system/console/bundles
Build a bundle
curl -u admin:admin -F bundleHome=/apps/ projects-A/bundles/name of bundle -F descriptor=/apps/projects-A/bundles/com.centrica.cq.wcm.core-bundle/name_of_bundle.bnd http://localhost:4502/libs/crxde/build
Stop a bundle
curl -u admin:admin http://localhost:4502/system/console/bundles/org.apache.sling.scripting.jsp -Faction=stop
Start a bundle
curl -u admin:admin http://localhost:4502/system/console/bundles/org.apache.sling.scripting.jsp -Faction=start
JCR Node Management:
Delete a node (hierarchy) – (this will delete any directory / node / site)
curl -X DELETE http://localhost:4502/path/to/node/jcr:content/nodeName -u admin:admin

Create or add a JCR node:
curl -u admin:admin -F”_charset_=utf-8″ -F”:nameHint=node” -F”jcr:primaryType=nt:unstructured” -F”sling:resourceType=project-A/components/abc-definition” -F”nodeReferenceName=ref-name1″ -F”jcr:createdBy=bala” -F”jcr:lastModifiedBy=bala” http://localhost:4502/content/geometrixx/en_GB/products/jcr:content/abc/

Create or add a JCR node along with some properties:
curl -u admin:admin -F”_charset_=utf-8″ -F”:nameHint=var” -F”jcr:primaryType=nt:unstructured” -F”key=key1″ -F”value=key1-value” http://localhost:4502/content/geometrixx/en_GB/products/jcr:content/abc/variables/

CQ Replication Commands:
Tree Activation
curl -u admin:admin -F cmd=activate -F ignoredeactivated=true -F onlymodified=true -F path=/content/geometrixx http://localhost:4502/etc/replication/treeactivation.html

User & Group Administration
Get User Info:
curl -u admin:admin http://localhost:4502/libs/granite/security/balakondepudi.json

Create User:
curl -u admin:admin -FcreateUser= -FauthorizableId=testuser -Frep:password=abc123 http://localhost:4502/libs/granite/security/post/authorizables

Create Group:
curl -u admin:admin -FcreateGroup=group1 -FauthorizableId=testGroup1 http://localhost:4502/libs/granite/security/post/authorizables

Create user with Profile:
curl -u admin:admin -FcreateUser=testuser -FauthorizableId=testuser -Frep:password=abc123 -Fprofile/gender=male http://localhost:4502/libs/granite/security/post/authorizables

Set a Profile Property on an Existing User:
curl -u admin:admin -Fprofile/age=29 http://localhost:4502/home/users/t/testuser1.rw.html

Create a User as a Member of a Group:
curl -u admin:admin -FcreateUser=testuser -FauthorizableId=testuser -Frep:password=abc123 -Fmembership=contributor http://localhost:4502/libs/granite/security/post/authorizables

Add a User to a Group:
curl -u admin:admin -FaddMembers=testuser1 http://localhost:4502/home/groups/t/testGroup.rw.html

Remove a User from a Group:
curl -u admin:admin -FremoveMembers=testuser1 http://localhost:4502/home/groups/t/testGroup.rw.html

Set a User’s Group Memberships:
curl -u admin:admin -Fmembership=contributor -Fmembership=testgroup http://localhost:4502/home/users/t/testuser.rw.html

Delete user and Group:
curl -u admin:admin -FdeleteAuthorizable= http://localhost:4502/home/users/t/testuser
curl -u admin:admin -FdeleteAuthorizable= http://localhost:4502/home/groups/t/testGroup

Change an user password:
curl -u testuser:OLD_PWD -F rep:password=”NEW_PWD” http://localhost:4502/home/users/t/testuser.rw.html
curl rep:password=”test” –user admin:admin http://localhost:4502/home/users/a/alister@geometrixx.com

Backup Commands:
Online Backup:
curl -u admin:admin -X POST http://localhost:4502/system/console/jmx/com.adobe.granite:type=Repository/op/startBackup/java.lang.String?target=<PATH-TO-BACKUP>/12-feb-2013.zip

Online backup with delay in milli seconds:
curl -u admin:admin -X POST http://localhost:4502/system/console/jmx/com.adobe.granite:type=Repository/a/BackupDelay?value=<TIME-IN-MILISECOND&gt;
curl -u admin:admin –data “delay=TIME-IN-MILISECONDS&force=false&target=01-dec-2012.zip” http://localhost:4502/libs/granite/backup/content/admin/backups/

How to stop a running online backup:
curl -u admin:admin http://localhost:4502/libs/granite/backup/content/admin/backups.cancel.html

Link to track online progress:
http://localhost:4502/libs/granite/backup/content/admin.html

Datastore GC:
For Datastore Garbage Collection:
curl -u admin:admin -X POST http://localhost:4502/system/console/jmx/com.adobe.granite:type=Repository/op/runDataStoreGarbageCollection/java.lang.Boolean

Tar Optimization:
curl -u admin:admin -X POST http://localhost:4502/system/console/jmx/com.adobe.granite:type=Repository/op/startTarOptimization/

Flush Dispatcher Cache:
curl -H “CQ-Action: Flush” -H “CQ-Handle: /content/geometrixx/en/products” -H “CQ-Path:/content/geometrixx/en/products” -H “Content-Length: 0” -H “Content-Type: application/octet-stream” http://dispatcher-server-hostname:port/dispatcher/invalidate.cache

Advertisements

From → Uncategorized

6 Comments
  1. esaiventhan permalink

    From where do you get this Bala?

  2. SSS permalink

    is there a way to list all pacakages under a specified group??

  3. Ravi cool permalink

    Can I get a list of users and the groups they are assigned to, using curl? (or any other method?)

Trackbacks & Pingbacks

  1. AEM / CQ5 Curl Commands | Sergei Müller | Web Developer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: