.. _changeevent: Change Event ============ This feed can be used to retrieve all index and document set changes that have occurred in ECM. It provides a means to track any changes that may need to be replicated in an external repository. Any modifications to an index entry will generate a new change event in this feed that contains the id of index entry folder object. Any changes to a document set (including documents) will result in an event being added that points to the document set folder object. Only one change event will exist in the CMIS repository for each object. If an object is modified multiple times, the most recent change event will replace any that already exist. Change history recording can be enabled by checking Save Change History in ECM Configuration under the Documents section. Change events can be generated for all historical records by clicking the Populate Change History button in ECM Configuration screen. .. image:: /_static/img/change-events-workbench.PNG .. _get-index-entry-changes: Get index entry changes """"""""""""""""""""""" Request properties ^^^^^^^^^^^^^^^^^^ :Change log token: A change log token will usually consist of two components, the change id and a unix timestamp: ``e.g. changeLogToken=17168070x1413439157`` The change id is a unique value assigned to each change (17168070). The unix timestamp indicates the minimum date of changes that should be returned. Note that a custom timestamp can be passed in without an id value: ``e.g. changeLogToken=1413439157`` :Filter: The filter parameter provides a means for the caller to restrict the result set to index entries. Optionally index number/s can be applied to set a more specific filter. Valid values: ``&filter=indexentry[,index number]`` Sample request ^^^^^^^^^^^^^^^ All indexes available to the repository. .. code-block:: text GET https://test.com/testO.Web.Start/test/Api/CMIS/T1/changes/?changeLogToken=1475611121&filter=indexentry HTTP/1.1 Host: test.com Filter for index 11 and 40 entries only. .. code-block:: text GET https://test.com/testO.Web.Start/test/Api/CMIS/T1/changes/?changeLogToken=1475611121&filter=indexentry,11,40 HTTP/1.1 Host: test.com Sample response ^^^^^^^^^^^^^^^ .. code-block:: xml HTTP/1.1 200 OK Cache-Control: private Content-Type: application/atom+xml;type=feed Server: Microsoft-IIS/7.5 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET X-UA-Compatible: IE=edge Strict-Transport-Security: max-age=10886400 Date: Wed, 05 Oct 2016 06:23:44 GMT Content-Length: 9642 Change Token 1475611121 c1a3a1d2-f699-4d46-8280-86a3a1e2f047 2016-10-05T16:23:44+10:00 false 6 8002e136eca148fd80713a4dfab9fc85 indexentry-10788-x-x-x-x-x-19 was changed. 2016-10-05T16:23:44+10:00 2016-10-05T16:23:44+10:00 2016-10-05T16:23:44.3512315+10:00 C 2016-10-05T09:40:49.563+10:00 indexentry-10788-x-x-x-x-x-19 166042x1475624449 created 2016-10-05T09:40:49.563+10:00 indexentry-10788-x-x-x-x-x-19 .. _get-document-set-changes: Get document set changes """"""""""""""""""""""""" Request properties ^^^^^^^^^^^^^^^^^^ :Change log token: A change log token will usually consist of two components, the change id and a unix timestamp: ``e.g. changeLogToken=17168070x1413439157`` The change id is a unique value assigned to each change (17168070). The unix timestamp indicates the minimum date of changes that should be returned. Note that a custom timestamp can be passed in without an id value: ``e.g. changeLogToken=1413439157`` :Filter: The filter parameter provides a means for the caller to restrict the result set to document sets. Valid value: ``&filter=folder[,index number]`` Sample request ^^^^^^^^^^^^^^ Filter to retrieve all document sets available to the repository that have changed. .. code-block:: text GET https://test.com/testO.Web.Start/test/Api/CMIS/T1/changes/?changeLogToken=1475611121&filter=folder HTTP/1.1 Host: test.com Filter to only retrieve document sets available to the repository that have changed if they are linked to index 11. .. code-block:: text GET https://test.com/testO.Web.Start/test/Api/CMIS/T1/changes/?changeLogToken=1475611121&filter=folder,11 HTTP/1.1 Host: test.com Sample response ^^^^^^^^^^^^^^^^ .. code-block:: xml HTTP/1.1 200 OK Cache-Control: private Content-Type: application/atom+xml;type=feed Server: Microsoft-IIS/7.5 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET X-UA-Compatible: IE=edge Strict-Transport-Security: max-age=10886400 Date: Wed, 05 Oct 2016 06:37:34 GMT Content-Length: 141969 Change Token 1474611121 78af80d9-3842-4986-a8ac-47dea8a39696 2016-10-05T16:37:34+10:00 DotCMIS Sample """""""""""""" Request properties ^^^^^^^^^^^^^^^^^^ :Change log token: A change log token will usually consist of two components, the change id and a unix timestamp: ``e.g. changeLogToken=17168070x1413439157`` The change id is a unique value assigned to each change (17168070). The unix timestamp indicates the minimum date of changes that should be returned. Note that a custom timestamp can be passed in without an id value: ``e.g. changeLogToken=1413439157`` :Filter: The filter parameter provides a means for the caller to restrict a result set to either index entries or document sets. Valid values are as follows: ``&filter=folder`` ``&filter=indexentry`` .. code-block:: C# public void Process(string changeToken = "") { while(true) { do { //Note: you would normally have a lookup table (or an alternative reference) to check whether the target objects have already been created var changes = Source.GetChangeEvents(changeToken); foreach (var changeEvent in changes.ChangeEventList) { changeToken = changeEvent.Properties.FirstOrDefault(x => x.Key.Equals("cmis:changeToken", StringComparison.OrdinalIgnoreCase)).Value.FirstOrDefault().ToString(); //Handle index entry changes if (Helpers.GetObjectTypeFromId(changeEvent.ObjectId).Equals(Constants.ObjectIdPrefixes.IndexEntry)) { ProcessIndexEntry(changeEvent.ObjectId); continue; } //Handle docset (folder) changes if (Helpers.GetObjectTypeFromId(changeEvent.ObjectId).Equals(Constants.ObjectIdPrefixes.Docset)) { ProcessDocumentSet(changeEvent.ObjectId, indexEntryId.Id); continue; } Logger.CreateMessage(new Message("Unexpected change id.", changeEvent.ObjectId, MessageTypes.Error)); } //Check if there are any more changes if (!changes.ChangeEventList.Any() || changes.HasMoreItems == null || !changes.HasMoreItems.Value) break; WriteMessage(string.Format("Retrieving next set of changes: {0}", changeToken)); } while (true); Logger.CreateMessage(new Message("No new changes...", MessageTypes.Information)); Thread.Sleep(5000); } } .. _changeeventpaging: Change Event Paging """"""""""""""""""" Change event paging is based on getting the next set of records after a requested point in time. The changeLogToken parameter provided with the request sets the earliest time to retrieve change events returning results in ascending order. If more change events are available, the change token from the last change event returned is used as the change log token parameter for the next change event request. For information on using paging for other CMIS objects see the :ref:`Paging` section. Sample request ^^^^^^^^^^^^^^ In this sample below we are requesting all document set changes made after 20/01/2023. This date converted to epoch time generates a change token of '1674136800'. .. code-block:: text https://test.com/TEST/Api/CMIS/REPOSITORY/changes/?changeLogToken=1674136800&filter=folder&includeProperties=false From the response returned, the last change event record has returned a change token of '115804229x1674732806'. This is the value that will be used to get the next set of changes. .. code-block:: text https://test.com/TEST/Api/CMIS/REPOSITORY/changes/?changeLogToken=115804229x1674732806&filter=folder&includeProperties=false Sample response ^^^^^^^^^^^^^^^ .. code-block:: xml Change Token 1674181573 8117e6f6-1649-4ed8-a80c-bfb24b2dbae2 2023-01-31T13:20:33Z