管理员通常需要自动执行或简化任何系统中的常见任务。 例如,在AEM中,管理用户、安装包和管理OSGi捆绑包是通常必须完成的任务。
由于构建AEM所基于的Sling框架具有RESTful特性,因此大多数任务可以通过URL调用来完成。 cURL可用于执行此类URL调用,可以是AEM管理员的有用工具。
cURL是用于执行URL操作的开源命令行工具。 它支持各种Internet协议,包括HTTP、HTTPS、FTP、FTPS、SCP、SFTP、TFTP、LDAP、DAP、DICT、TELNET、FILE、IMAP、POP3、SMTP和RTSP。
cURL是一个成熟且广泛使用的工具,最初于1997年发布,用于使用URL语法获取或发送数据。 名称cURL最初的意思是“查看URL”。
由于构建AEM所基于的Sling框架具有RESTful性质,因此大多数任务可以简化为URL调用,而该URL调用可以使用cURL执行。 内容操作任务 例如激活页面,以及启动工作流和 运行任务 例如包管理以及使用cURL管理用户等。 此外,您还可以 创建您自己的cURL 命令用于AEM中的大多数任务。
通过cURL执行的任何AEM命令都必须像任何用户一样获得AEM授权。 使用cURL执行AEM命令时,会尊重所有ACL和访问权限。
cURL是macOS和一些Linux调试程序的标准部分。 但是,它适用于大多数操作系统。 有关最新下载信息,请访问 https://curl.haxx.se/download.html.
cURL的源存储库也可以在GitHub上找到。
cURL命令可以为AEM中的大多数操作构建,例如触发工作流、检查OSGi配置、触发JMX命令、创建复制代理等等。
要找到特定操作所需的确切命令,您需要在执行AEM命令时使用浏览器中的开发人员工具来捕获对服务器的POST调用。
以下步骤描述了如何使用Chrome浏览器中创建新页面作为示例来完成此操作。
准备要在AEM中调用的操作。 在本例中,我们继续到 创建页面 向导,但尚未单击 创建.
启动开发人员工具并选择 网络 选项卡。 单击 保留日志 选项。
单击 创建 在 创建页面 向导以实际创建工作流。
右键单击生成的POST操作并选择 复制 -> 复制为cURL.
将cURL命令复制到文本编辑器并从命令中删除所有标头,这些标头以 -H
(下图以蓝色突出显示)并添加适当的身份验证参数,例如 -u <user>:<password>
.
通过命令行执行cURL命令并查看响应。
以下是常见管理和操作任务的AEM cURL命令列表。
以下示例假定AEM运行于 localhost
在端口 4502
并使用用户 admin
包含密码 admin
. 其他命令占位符设置在尖括号中。
curl -u <user>:<password> http://<host>:<port>/crx/packmgr/service.jsp?cmd=ls
curl -u <user>:<password> -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/mycontent.zip?cmd=create -d packageName=<name> -d groupName=<name>
curl -u <user>:<password> -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/mycontent.zip?cmd=preview
curl -u <user>:<password> -X POST http://localhost:4502/crx/packmgr/service/console.html/etc/packages/mycontent.zip?cmd=contents
curl -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/mycontent.zip?cmd=build
curl -u <user>:<password> -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/mycontent.zip?cmd=rewrap
curl -u <user>:<password> -X POST -Fname=<New Name> http://localhost:4502/etc/packages/<Group Name>/<Package Name>.zip/jcr:content/vlt:definition
curl -u <user>:<password> -F cmd=upload -F force=true -F package=@test.zip http://localhost:4502/crx/packmgr/service/.json
curl -u <user>:<password> -F cmd=install http://localhost:4502/crx/packmgr/service/.json/etc/packages/my_packages/test.zip
curl -u <user>:<password> -F cmd=uninstall http://localhost:4502/crx/packmgr/service/.json/etc/packages/my_packages/test.zip
curl -u <user>:<password> -F cmd=delete http://localhost:4502/crx/packmgr/service/.json/etc/packages/my_packages/test.zip
curl -u <user>:<password> http://localhost:4502/etc/packages/my_packages/test.zip
curl -u <user>:<password> -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/my_packages/test.zip?cmd=replicate
curl -u <user>:<password> -FcreateUser= -FauthorizableId=hashim -Frep:password=hashim http://localhost:4502/libs/granite/security/post/authorizables
curl -u <user>:<password> -FcreateGroup=group1 -FauthorizableId=testGroup1 http://localhost:4502/libs/granite/security/post/authorizables
curl -u <user>:<password> -Fprofile/age=25 http://localhost:4502/home/users/h/hashim.rw.html
curl -u <user>:<password> -FcreateUser=testuser -FauthorizableId=hashimkhan -Frep:password=hashimkhan -Fprofile/gender=male http://localhost:4502/libs/granite/security/post/authorizables
curl -u <user>:<password> -FcreateUser=testuser -FauthorizableId=testuser -Frep:password=abc123 -Fmembership=contributor http://localhost:4502/libs/granite/security/post/authorizables
curl -u <user>:<password> -FaddMembers=testuser1 http://localhost:4502/home/groups/t/testGroup.rw.html
curl -u <user>:<password> -FremoveMembers=testuser1 http://localhost:4502/home/groups/t/testGroup.rw.html
curl -u <user>:<password> -Fmembership=contributor -Fmembership=testgroup http://localhost:4502/home/users/t/testuser.rw.html
curl -u <user>:<password> -FdeleteAuthorizable= http://localhost:4502/home/users/t/testuser
curl -u <user>:<password> -FdeleteAuthorizable= http://localhost:4502/home/groups/t/testGroup
请参阅 备份和恢复 以了解详细信息。
curl -u <user>:<password> -Faction=start http://localhost:4502/system/console/bundles/<bundle-name>
curl -u <user>:<password> -Faction=stop http://localhost:4502/system/console/bundles/<bundle-name>
curl -H "CQ-Action: Activate" -H "CQ-Handle: /content/test-site/" -H "CQ-Path: /content/test-site/" -H "Content-Length: 0" -H "Content-Type: application/octet-stream" http://localhost:4502/dispatcher/invalidate.cache
curl -H "CQ-Action: Deactivate" -H "CQ-Handle: /content/test-site/" -H "CQ-Path: /content/test-site/" -H "Content-Length: 0" -H "Content-Type: application/octet-stream" http://localhost:4502/dispatcher/invalidate.cache
curl -u <user>:<password> "http://localhost:4502/etc/replication/agents.author/publish/jcr:content.queue.json?agent=publish"
http://localhost:4502/etc/replication/agents.author/publish/jcr:content.queue.json?agent=publish
curl -X DELETE http://localhost:4502/etc/replication/agents.author/replication99 -u <user>:<password>
curl -u <user>:<password> -F "jcr:primaryType=cq:Page" -F "jcr:content/jcr:title=new-replication" -F "jcr:content/sling:resourceType=/libs/cq/replication/components/agent" -F "jcr:content/template=/libs/cq/replication/templates/agent" -F "jcr:content/transportUri=http://localhost:4503/bin/receive?sling:authRequestLogin=1" -F "jcr:content/transportUser=admin" -F "jcr:content/transportPassword={DES}8aadb625ced91ac483390ebc10640cdf"http://localhost:4502/etc/replication/agents.author/replication99
curl -u <user>:<password> -F "cmd=pause" -F "name=publish" http://localhost:4502/etc/replication/agents.author/publish/jcr:content.queue.json
curl -u <user>:<password> -F "cmd=clear" -F "name=publish" http://localhost:4502/etc/replication/agents.author/publish/jcr:content.queue.json
请参阅 社区评分和徽章 以了解详细信息。
请参阅 评分和徽章要点 以了解详细信息。
请参阅 MSRP - MongoDB存储资源提供程序 以了解详细信息。
请参阅 在AEM中启用CRXDE Lite 以了解详细信息。
请参阅 数据存储垃圾收集 以了解详细信息。
请参阅 选择使用Adobe Analytics和Adobe Target 以了解详细信息。
请参阅 单点登录 以了解详细信息。
以下是用于内容操作的AEM cURL命令列表。
以下示例假定AEM运行于 localhost
在端口 4502
并使用用户 admin
包含密码 admin
. 其他命令占位符设置在尖括号中。
curl -u <user>:<password> -X POST -F path="/content/path/to/page" -F cmd="activate" http://localhost:4502/bin/replicate.json
curl -u <user>:<password> -X POST -F path="/content/path/to/page" -F cmd="deactivate" http://localhost:4502/bin/replicate.json
curl -u <user>:<password> -F cmd=activate -F ignoredeactivated=true -F onlymodified=true -F path=/content/geometrixx http://localhost:4502/etc/replication/treeactivation.html
curl -u <user>:<password> -X POST -F cmd="lockPage" -F path="/content/path/to/page" -F "_charset_"="utf-8" http://localhost:4502/bin/wcmcommand
curl -u <user>:<password> -X POST -F cmd="unlockPage" -F path="/content/path/to/page" -F "_charset_"="utf-8" http://localhost:4502/bin/wcmcommand
curl -u <user>:<password> -F cmd=copyPage -F destParentPath=/path/to/destination/parent -F srcPath=/path/to/source/location http://localhost:4502/bin/wcmcommand
请参阅 以编程方式与工作流交互 以了解详细信息。
curl -u <user>:<password> -F jcr:primaryType=sling:Folder http://localhost:4502/etc/test
curl -u <user>:<password> -F :operation=delete http://localhost:4502/etc/test/test.properties
curl -u <user>:<password> -F":operation=move" -F":applyTo=/sourceurl" -F":dest=/target/parenturl/" https://localhost:4502/content
curl -u <user>:<password> -F":operation=copy" -F":applyTo=/sourceurl" -F":dest=/target/parenturl/" https://localhost:4502/content
curl -u <user>:<password> -F"*=@test.properties" http://localhost:4502/etc/test
curl -u <user>:<password> -F"test2.properties=@test.properties" http://localhost:4502/etc/test
curl -u <user>:<password> -F "*=@test.properties;type=text/plain" http://localhost:4502/etc/test
请参阅 资源HTTP API 以了解详细信息。