Search code examples
jcrslingjackrabbit

Apache Sling: Accessing Versions through REST API


I am trying to retrieve the version history of a versionable node in Sling.

I have created a versionable node, checked out, uploaded a new version and checked it in.

curl -u admin:admin -T test.txt http://localhost:8080/apps/versions2
curl -u admin:admin http://localhost:8080/apps/versions2/test.txt -X POST -F"jcr:mixinTypes=mix:versionable"
curl -u admin:admin http://localhost:8080/apps/versions2/test.txt -X POST -F":operation=checkout"
curl -u admin:admin -T test.txt http://localhost:8080/apps/versions2/test.txt
curl -u admin:admin http://localhost:8080/apps/versions2/test.txt -X POST -F":operation=checkin"

However, when I try to pull the version history as suggested by this enhancement request it does not work.

curl -u admin:admin http://localhost:8080/apps/versions2/test.txt.V.tidy.json
{
"jcr:primaryType": "nt:file",
"jcr:mixinTypes": ["mix:versionable"],
"jcr:createdBy": "admin",
"jcr:versionHistory": "31d1e0e8-22b0-476d-b591-b7441073f0fc",
"jcr:predecessors": [],
"jcr:created": "Mon Nov 20 2017 13:31:47 GMT+0100",
"jcr:baseVersion": "00b9682c-9402-4c5f-a759-8f1837e55e35",
"jcr:isCheckedOut": "false",
"jcr:uuid": "0e1784aa-51c2-4901-b56d-89f8dcea9744"
}

My plan B was to read the nodes from /jcr:system/jcr:versionStorage but I have no idea how to access it through the WebDAV API.


Solution

  • configuration policy for version info servlet is set to REQUIRE, which means this servlet will not be active until a config is explicitly set.

    So you can go to system config (http://localhost:8080/system/console/configMgr), search for Apache Sling Version Info Servlet, click on and save the default config, than you would be able to get versions for that node as expected.