10.2 Delete Concurrency Handling
ETag processing
SData uses the same ETag based concurrency handling mechanism for update and delete operations. When this mechanism is active the consumer MAY include an If-Match HTTP header in its delete request. For example:
DELETE /sdata/myApp/myContract/-/salesOrders('43661') If-Match: STFtZgHEkPz7TyH98YEmWA==
When processing a DELETE request, the provider MUST check if an If-Match header is present. If so, the provider MUST compare the value of the If-Match header with its current ETag value for the resource.
If the consumer does not include the If-Match header in its DELETE request, the provider MUST NOT perform the test and MUST proceed with the delete operation.
If the consumer and provider ETag values are identical, the provider knows that the resource has not been modified since the consumer read it. So it MUST accept the request and proceed with the delete operation. If the operation succeeds, the provider will send a 200 response.
200 OK
Whereas, if the ETag values differ, the provider knows that the resource has been modified since the consumer read it. It MUST respond with a 412 Precondition Failed status code, and include the current version of the entry in its response with the current ETag value:
412 Precondition Failed Content-Type: application/atom+xml; type=entry ETag: 3nqPeQqoGoxQB5xf3NIijw==
<entry xmlns:sdata="http://schemas.sage.com/sdata/2008/1" xmlns:http="http://schemas.sage.com/sdata/http/2008/1" xmlns="http://www.w3.org/2005/Atom"> <id>http://www.example.com/sdata/myApp/myContract/-/salesOrders('43661')</id> <title>Sales Order 43661</title> <!-- entry elements skipped for clarity ... --> ** <http:etag>3nqPeQqoGoxQB5xf3NIijw==</http:etag> **</entry>
If the consumer is an interactive application, it MAY display the resource again and ask the user to confirm the delete operation.
Metadata property
In the schema, the sme:supportsETag property indicates whether the ETag concurrency handling mechanism is supported or not on a resource kind. See Resource Kind Definition section for details. If the sme:supportsETag property is set to false, the ETag mechanism is inactive and delete operations are processed without any concurrency checks.
SData providers MUST support this concurrency handling protocol on all resource kinds that have the sme:supportsETag flag set to true.