Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added a couple missing response codes.

...

Excerpt

Status
colourBlue
titlePOST
Create a new transaction

Info

After retrieving a transaction URI from the "Location" header in the response to the following HTTP request, the client can execute any POST/PUT/PATCH/DELETE/GET REST API method within the transaction scope by including the transaction URI in the "Atomic-ID" request header.


Warning

Transactions are automatically closed and rolled back after 3 minutes of inactivity. Transactions can be refreshed by POSTing to the transaction URI

Example:

Code Block
curl -i -X POST "http://localhost:8080/rest/fcr:tx" 

Response:

Code Block
Status: 201 Created
 
Headers:
Location: http://localhost:8080/rest/fcr:tx/ce4bb2bf-8ced-4c7d-b281-f2132e3064bb
Link: <http://localhost:8080/rest/fcr:tx/ce4bb2bf-8ced-4c7d-b281-f2132e3064bb/commit>; rel="http://fedora.info/definitions/v4/transaction#commitEndpoint"
Atomic-Expires: Thu, 07 May 2020 17:34:37 GMT

Usage:

When a transaction has been created, it will return a Location header.  Use this location (transaction URI) as the value of the "Atomic-ID" request header for performing REST API operations within the transaction.  When you are done with the transaction, either commit the transaction to the repository by making a PUT request to the transaction URI,  or discard the changes and rollback the transaction by making a DELETE request to the transaction URI.

For further examples of the usage of Transactions, see: Transactions

Status:

Status
subtletrue
colourGreen
title201
  Created: if the transaction is created successfully


Status
titleGET
 Get the current status of the repository in a transaction

To get the status of a transaction, perform a GET request on the transaction URI that was previously returned as the value of the "Location" header from the transaction creation request. The "Atomic-Expires" header indicates the time at which the transaction will auto-rollback.

Example:

Code Block
curl -i -X GET "http://localhost:8080/rest/fcr:tx/ce4bb2bf-8ced-4c7d-b281-f2132e3064bb"

Response:

Code Block
Status: 204 No Content

 Headers:
Atomic-Expires: Thu, 7 May 2020 17:46:17 GMT


Status:

Status
subtletrue
colourGreen
title204
No Content: If the request was successful

Status
subtletrue
colourRed
title404
Not Found: Transaction not found

Status
subtletrue
colourRed
title410
Gone: Transaction expired



Status
colourBlue
titlePOST
Keep an existing transaction alive

By performing a POST request on an existing transaction URI, the transaction's expiration time is extended by the value of the session timeout duration (default: 3 minutes)

Example:

Code Block
curl -i -X POST "http://localhost:8080/rest/fcr:tx/ce4bb2bf-8ced-4c7d-b281-f2132e3064bb"

Response:

Code Block
Status: 204 No Content
 
Headers:
Atomic-Expires: Thu, 7 May 2020 18:00:38 GMT


Status:

Status
subtletrue
colourGreen
title204
  No Content: if the transaction is renewed successfully

Status
subtletrue
colourRed
title404
  Not Found: if the transaction doesn't exist

Status
subtletrue
colourRed
title410
  Gone: Transaction expired



Status
colourBlue
titlePUT
Commit an open transaction


Any operations you made within the scope of the transaction will be applied together, meaning if any of them fail, the whole transaction will fail.

Example:

Code Block
curl -X PUT "http://localhost:8080/rest/fcr:tx/ce4bb2bf-8ced-4c7d-b281-f2132e3064bb"

Response:

Code Block
Status: 204 No Content

Status:

Status
subtletrue
colourGreen
title204
 No Content: if the transaction is committed successfully

Status
subtletrue
colourRed
title404
Not Found: if the transaction doesn't exist

Status
subtletrue
colourRed
title409
Conflict: Transaction did not commit successfully

Status
subtletrue
colourRed
title410
Gone: Transaction expired



Status
colourBlue
titleDELETE
 
Rollback and close an open transaction

Example:

Code Block
curl -i -X DELETE "http://localhost:8080/rest/fcr:tx/ce4bb2bf-8ced-4c7d-b281-f2132e3064bb"

Response:

Code Block
Status: 204 No Content

Status:

Status
subtletrue
colourGreen
title204
 No Content: if the transaction is discarded successfully

Status
subtletrue
colourRed
title410
Gone: if the transaction has already been committed or rolled back

Status
subtletrue
colourRed
title404
Not Found: if the transaction does not exist

...