0

I have some code that needs to know the latest ChangeToken, so I wrote:

session.Clear();
var token = session.RepositoryInfo.LatestChangeLogToken;

Unfortunately, it does not always return the latest token.
Example:

  1. Start the session
  2. Run the code above, I get 72
  3. Create a folder on the server
  4. Start CMIS Workbench, read the token, it is 73
  5. Run the code above again while still in the same session, I get 72 <-- Problem

Is there a way to somehow "reset" the session, or clear the cache better?
I would prefer to not create a new session every time.

Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373

2 Answers2

2

OpenCMIS has the Session.getLatestChangeLogToken() method for that, which does the same. Clearing the caches or fetching the repository info is not necessary.

Florian Müller
  • 3,215
  • 1
  • 14
  • 11
1

This works:

session.Clear(); // Clear all caches.
session.Binding.GetRepositoryService().GetRepositoryInfos(null);

var token = session.Binding.GetRepositoryService().GetRepositoryInfo(
      this.session.RepositoryInfo.Id, null).LatestChangeLogToken;

The token is always up-to-date.
Not too sure whether the first two lines are needed or not.

Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373