Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

After retrieving a transaction resource using the  RESTful HTTP API - Transactions, clients can send additional REST API calls within the scope of that transaction. After committing the transaction, the pending changes will be persisted in a single atomic operation. Validation, event-driven workflows, and other asynchronous operations are not triggered until the transaction is committed, which may provide a performance increase for some types of iterative tasks. Transactions can also be rolled back, as if they never occurred.

Example

Code Block
firstline1
titleCreating a new transaction resource
firstline 1
linenumberstrue
curl -v -X POST "http://localhost:8080/rest/fcr:tx" 

Create a transaction. In the response, the Location header will contain a path to the created transaction

Code Block
titleCreate transaction response
collapsetrue
Status: 201 Created
 
Headers:
Location: http://localhost:8080/rest/tx:83e34464-144e-43d9-af13-b3464a1fb9b5
Expires: Sat, 16 Nov 2013 00:32:57 GMT

The expires header indicates when the transaction will be automatically rolled back due to inactivity.

...

API requests can be prefixed with the transaction identifier:

Code Block
firstline2
titleModifying resources in the transaction
firstline 2
linenumberstrue
curl -X POST "http://localhost:8080/rest/tx:83e34464-144e-43d9-af13-b3464a1fb9b5/path/to/object/to/create"
curl -X DELETE "http://localhost:8080/rest/tx:83e34464-144e-43d9-af13-b3464a1fb9b5/path/to/resource/to/delete"

You can send most API requests scoped by the transaction. API requests that are not prefixed by a path to the node do not occur within the scope of a transaction and cannot be used (e.g. fcr:nodetypes, fcr:namespaces, etc)

Code Block
firstline4
titleCommitting a transaction
firstline 4
linenumberstrue
curl -X POST "http://localhost:8080/rest/tx:83e34464-144e-43d9-af13-b3464a1fb9b5/fcr:tx/fcr:commit"

Until the transaction is committed, no other client will see the changes made within the scope of the transaction. After committing, the changes will be applied to the workspace and all clients will be able to see the change.

Fedora 4's transactions do NOT support checkpointing. After committing a transaction, it is closed, and any further operations on that transaction will be rejected.

Code Block
firstline5
titleRolling back a transaction
firstline 5
linenumberstrue
curl -X POST "http://localhost:8080/rest/tx:83e34464-144e-43d9-af13-b3464a1fb9b5/fcr:tx/fcr:rollback"

The changes made within the scope of the transaction will be erased, and the transaction closed and removed.