Uploaded image for project: 'Service Packs and Hot Fixes'
  1. Service Packs and Hot Fixes
  2. MNT-20139

CmisConnector returns wrong values for changeLogToken and hasMoreItems


    • Type: Service Pack Request
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: 5.2
    • Fix Version/s: 5.2.5, 6.0.1
    • Component/s: CMIS
    • Labels:
    • Bug Priority:
      Category 2
    • ACT Numbers:


    • RCA Cause:
      Lack of code review
    • RCA Quality:
      Missing test(s)
    • RCA Description:
      Incorrect changeLogToken and hasMoreItems values were returned in cases when providing maxItems or having entries with empty values


      See also this pull request: https://github.com/Alfresco/alfresco-repository/pull/228

       Short description of the issue

      There are 3 bugs that together compromise the reliability of the Cmis Changelog. We use this Changelog (through Apache Chemistry) to retreive all new documents into our application. There are three main errors: incorrect changeLogToken is returned (always), hasMoreChanges check is wrong resulting in false response when there are actually more changes and the changeLogToken is not returned at all when there are no more changes.

      We had to use a workaround, especially for the hasMoreChanges bug, to look at the value in the repository when we get a false response. However, this has resulted in missed documents on our end, which has caused big problems in production. We are now at a point where we can not trust Alfresco to return us all documents.


      Detailed description of the bugs

      Issue 1: changeLogToken from cmis http call to CMISChangeLog returns the wrong value
      When a query is done with Apache Chemistry or manually calling the url it generates, the returned changeLog is always incorrect.

      To start with a call when there are more items available from the given changeLogToken.

      Use a local docker which has seen quite a few documents being added and moved around, so that there are changes in the changelog

      1. Call http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser?cmisselector=contentChanges&changeLogToken=0&includeProperties=false&includePolicyIds=false&includeACL=false&maxItems=1000&succinct=true
      2. In my case this returns Json:
            objects: [array of 1000 objects], 
            hasMoreItems: true, 
            changelogToken: "1000" 

        #This changelogToken is always exactly the old changeLogToken + maxItems

      1. Now call a lower level API to get these same 1000 documents: http://localhost:8080/alfresco/service/api/audit/query/CMISChangeLog?verbose=true&limit=1000&forward=true&fromId=0
      2. The result here is: {count: 1000, entries:[array of 1000 documents]}
      3. We can inspect the last document and see what its ID is, which is its changelogToken. In my case, this is 11550
      4. Expected: I would have expected the changelogToken variable in step 3 to be 11550.

      Issue 2: returned changeLogToken is null when there are no more changes from the changeLog
      This is what happends there are no more items available from the given changeLogToken af the call

      1. same as before, set up an Alfresco
      2. same call, but change the changeLogToken variable to the latest from your repository and subtract a few more from it. So for me the latest from the respository is 6317, so I would supply 6000 as my changeLogToken: http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser?cmisselector=contentChanges&changeLogToken=6000&includeProperties=false&includePolicyIds=false&includeACL=false&maxItems=1000&succinct=true
      3. This now returns the following json:
            objects: [array of 14], 
            hasMoreItems: false, 
            changeLogToken: null
      1. Expected: the value of the latest entry as changeLogToken, not null.

      Issue 3: Changelog returns hasMoreItems = false, even though there are more changes.

      This is somewhat harder to reproduce, because I don't know how to set up the Alfresco changelog data for it. I do know why it happends. This happends when an entry in the changelog, requested through the /service/api/audit/query/CMISChangeLog call has a 'values' field that is an empty object. Example:

          id: 700, 
          application: "CMISChangeLog", 
          user: "admin", 
          time: "2018-10-19T08:21:14.186Z", 
          values: {} 

      If you have an entry like the above, doing the following steps results in a problem:

      1. Made a call to Alfresco with startToken 0 and request 1000 changes: http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser?cmisselector=contentChanges&changeLogToken=0&includeProperties=false&includePolicyIds=false&includeACL=false&maxItems=100&succinct=true
      2. Result:
            objects: [array of 100], 
            hasMoreItems: false, 
            changeLogToken: null 
      1. However, if I do the lower level call: http://localhost:8080/alfresco/service/api/audit/query/CMISChangeLog?verbose=true&limit=100&forward=true&fromId=0 I do get 100 entries.
      2. Expected: I would epect the higher level call to know that there are more items, even though some were filtered out.
        The problem here is that the CmisConnector uses the resulting documents array to determine if there are more items, even though this array is subject to filtering. This array may even be bigger then the requested value (code path supports it, I do not know if it can happen in practise).


          Issue Links




                • Assignee:
                  closedbugs Closed Bugs (Inactive)
                  vzorge Vincent Zorge (Inactive)
                • Votes:
                  0 Vote for this issue
                  7 Start watching this issue


                  • Created:

                    Structure Helper Panel