4.4 Synchronization Feed
The SData synchronization protocol uses Atom feeds to transfer changes to resources between endpoints.
The SData synchronization feeds are SData feeds that carry additional synchronization information. Here is a typical example:
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:sdata="http://schemas.sage.com/sdata/2008/1"> <title>Account synchronization feed DD052E5C-BFAD-4ffa-8D54-D696E4959497</title> <id>http://www.example.com/sdata/myApp1/myContract/-/accounts/$syncSource('DD052E5C-BFAD-4ffa-8D54-D696E4959497')</id> <updated>2008-03-31T13:46:45Z</updated> <link rel="self" type="application/atom+xml; type=feed" title="Refresh" href="http://www.example.com/sdata/myApp1/myContract/-/accounts/$syncSource('DD052E5C-BFAD-4ffa-8D54-D696E4959497')" /> <link rel="first" type="application/atom+xml; type=feed" title="First Page" href="http://www.example.com/sdata/myApp1/myContract/-/accounts/$syncSource('DD052E5C-BFAD-4ffa-8D54-D696E4959497')" /> <link rel="next" type="application/atom+xml; type=feed" title="NextPage" href="http://www.example.com/sdata/myApp1/myContract/-/accounts/$syncSource('DD052E5C-BFAD-4ffa-8D54-D696E4959497') ?startIndex=11&count=10" /> <syncMode xmlns="http://schemas.sage.com/sdata/sync/2008/1">catchUp</syncMode> <!-- Digest --> <digest xmlns="http://schemas.sage.com/sdata/sync/2008/1"> <origin>http://www.example.com/sdata/myApp1/myContract/-/accounts</origin> <digestEntry> <endpoint>http://www.example.com/sdata/myApp1/myContract/-/accounts</endpoint> <tick>6</tick> <stamp>2008-10-30T17:23:08Z</stamp> <conflictPriority>2</conflictPriority> </digestEntry> <digestEntry> <endpoint>http://www.example.com/sdata/myApp2/myContract/-/accounts</endpoint> <tick>10</tick> <stamp>2008-10-30T12:16:51Z</stamp> <conflictPriority>1</conflictPriority> </digestEntry> <digestEntry> <endpoint>http://www.example.com/sdata/sageApp3/test/-/accounts</endpoint> <tick>10</tick> <stamp>2008-10-30T16:47:03Z</stamp> <conflictPriority>3</conflictPriority> </digestEntry> </digest> <!-- Entry --> <entry> <id/> <title/> <updated>2008-10-30T14:55:43.281Z</updated> <content/> <!-- Per-Resource Synchronization State --> <syncState xmlns="http://schemas.sage.com/sdata/sync/2008/1"> <endpoint>http://www.example.com/sdata/myApp1/myContract/-/accounts</endpoint> <tick>5</tick> <stamp>2008-10-30T14:55:43.281Z</stamp> </syncState> <!-- XML payload --> <payload xmlns="http://schemas.sage.com/sdata/2008/1"> <account sdata:uuid="74926A0D-D2C0-4daa-9986-47C833691569" xmlns="http://schemas.sage.com/myContract"> <name>Natural Goods Ltd.</name> <!-- more account data --> </account> </payload> </entry> <!-- Entry --> <entry> <id>http://www.example.com/sdata/myApp1/myContract/-/accounts('23552')</id> <title>Account Chemical Bros</title> <updated>2008-05-25T13:27:19.207Z</updated> <content>Account Chemical Bros</content> <!-- Per-Resource Synchronization State --> <syncState xmlns="http://schemas.sage.com/sdata/sync/2008/1"> <endpoint>http://www.example.com/sdata/sageApp3/test/-/accounts</endpoint> <tick>8</tick> <stamp>2008-10-30T13:27:19.207Z</stamp> </syncState> <!-- XML payload --> <payload xmlns="http://schemas.sage.com/sdata/2008/1"> <account sdata:uuid="C4411795-9943-4cf4-8705-51A74C9F0ACC" xmlns="http://schemas.sage.com/myContract"> <name>Chemical Brothers Inc.</name> <!-- more account data --> </account> </payload> </entry> <!-- ... more entries ... --> </feed>
This feed is an Atom feed that carries the following SData XML extensions:
SData Namespace | SData Extension | Element or Attribute | Applies To | Description |
---|---|---|---|---|
sync/2008/1 | syncMode | Element | feed | Indicates whether the feed corresponds to a catch up or immediate synchronization operation. Valid values are: * catchUp * immediate |
sync/2008/1 | digest | Element | feed | Source digest. The target will use this digest to detect conflicts (see section on Conflict Handling with Digest). The target will also use this digest to update its own digest at the end of the feed (end of last page). |
sdata/2008/1 | uuid | Attribute | payload child | UUID of the resource. |
sdata/2008/1 | isDeleted | Attribute | payload child | Boolean attribute to flag resources that have been deleted on the source side. Default value is false. So this attribute is only necessary on deleted entries (with value true). |
sync/2008/1 | syncState | entry | The synchronization state of the entry. In the example above, the first entry was created in sageApp1 at tick 5, the second one was updated by sageApp3 at tick 8. |
The payload included into every entry MUST be a full payload. Partial payloads are not allowed in synchronization feeds as this may lead to inconsistent merge operations.
Endpoints that are both source and target in sync operations SHOULD store all the payload elements defined by the contract so that they propagate full payloads to other nodes.
All lists included in sync payloads MUST contain all the entries recorded by the endpoint. If the endpoint stores the complete list and does not track delete operations on list elements, it MUST flag the list that it sends with sdata:deleteMissing=”true”. If the endpoints does not store the complete list, is MUST NOT set the sdata:deleteMissing flag but it MUST still send all the elements that it stores.
The synchronization protocol uses the standard paging links (<link rel=”next”>) if the synchronization feed is broken in pages.
Inside the synchronization feed, the entries must be sorted so that their <syncState> tick always increases for a given<syncSate> endpoint. On the other hand, the order in which the <syncState> endpoints are returned does not matter
A provider exposing a resource kind for synchronization MUST provide as response to operations on the $syncSource and $syncTarget operations a feed structured in the following manner:
syncMode specification: MUST for $syncTarget requestdigest: MUST for $syncSource and $syncTargetrequests and responses entry (sequence): MUST for $syncTarget requestWith regard to the sequence of entries in the feed, the entries for a given endpoint MUST be ordered by ascending tick.
The provider MUST support sequential paging mechanism for retrieval of the results.