CRUD operations are done with HTTP requests. I'll use curl in my examples, and operate on a node at http://localhost:8080/content/mynode
, since that's what is being used in the tutorial you have read.
Create: To create content you do a HTTP POST request. In the tutorial the following example is used:
curl -u admin:admin -F"sling:resourceType=foo/bar" -F"title=some title" http://localhost:8080/content/mynode
This creates new content at http://localhost:8080/content/mynode
, with a single property title
=some title
Read: Simply to a GET request to the content node:
curl http://localhost:8080/content/mynode
... or even simpler, use your web browser and navigate to http://localhost:8080/content/mynode
Update: You can also update with a POST request, e.g.:
curl -u admin:admin -F"sling:resourceType=foo/bar" -F"title=some other title" http://localhost:8080/content/mynode
This sets the title of the already existing content node to some other title
. You can also add new properties:
curl -u admin:admin -F"sling:resourceType=foo/bar" -F"myProperty=my value" http://localhost:8080/content/mynode
... which adds the property myProperty
, with the value my value
.
Delete: You delete a content node by sending an HTTP DELETE request:
curl -u admin:admin -X DELETE http://localhost:8080/content/mynode
For the full range of operations you can do, see Apache Sling: Manipulating Content - The SlingPostServlet