Page tree

Bleeding Edge

This documentation covers bleeding-edge updates to the 6.x version of Fedora. Looking for another version? See all documentation.

Skip to end of metadata
Go to start of metadata

Overview

Fedora supports the ability to wrap multiple REST API calls into a single transaction that can be committed or rolled back as an atomic operation.

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. The updates related to a given transaction are only visible within that transaction scope. Event-driven workflows are not triggered until the transaction is committed. Transactions can also be rolled back on-demand or based on a configurable timeout duration, leaving the repository in the state as if the transaction had never occurred.

Example

Create a transaction:

Creating a new transaction resource
curl -i -X POST "http://localhost:8080/rest/fcr:tx" 

In the response, the Location header will contain a path to the transaction URI:

Create transaction response
Status: 201 Created
 
Headers:
Expires: Wed, 20 May 2020 23:26:46 GMT
Location: http://localhost:8080/rest/fcr:tx/fd4f48c4-7c47-46ee-8907-af6411ae4215

The expires header indicates when the transaction will be automatically rolled back

Transactions are automatically closed and rolled back after 3 minutes. Transactions can be refreshed by POSTing to the transaction URI returned in the "Location" header of the initial creation request.
See Application Configuration for setting a different session duration.

The following API methods on repository resources can be called within the scope of a transaction: PUT, POST, PATCH, GET, and DELETE .

In order to make a request within the transaction, include the Transaction URI in the "Atomic-ID" request header:

Modifying resources in the transaction
curl -H"Atomic-ID: http://localhost:8080/rest/fcr:tx/fd4f48c4-7c47-46ee-8907-af6411ae4215" -X POST "http://localhost:8080/rest/path/to/object/to/create"
curl -H"Atomic-ID: http://localhost:8080/rest/fcr:tx/fd4f48c4-7c47-46ee-8907-af6411ae4215" -X DELETE "http://localhost:8080/rest/path/to/resource/to/delete"

To get the status of a transaction, perform a GET request on the Transaction URI:

Getting status of a transaction
curl -i GET http://localhost:8080/rest/fcr:tx/fd4f48c4-7c47-46ee-8907-af6411ae4215"

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 repository, associated events will be emitted, and all clients will be able to see the change(s).

To commit a transaction, perform a PUT request on the Transaction URI:

Committing a transaction
curl -X PUT "http://localhost:8080/rest/fcr:tx/fd4f48c4-7c47-46ee-8907-af6411ae4215"

To rollback a transaction, perform a DELETE request on the Transaction URI:

Rolling back a transaction
curl -X DELETE "http://localhost:8080/rest/fcr:tx/fd4f48c4-7c47-46ee-8907-af6411ae4215"

Note: Rolling back a transaction will result in the changes made within the scope of the transaction to be erased, and the transaction closed and removed.

After committing or rolling back a transaction, it is closed, and any further operations on that transaction will be rejected.