|[CDO]Identify the author of a CDOCommit [message #1840397]
||Wed, 14 April 2021 07:43
| Xavier GISTAU
Registered: February 2019
Hello everyone, I hope you are all doing great !|
Some months ago, I started to work with CDO, and asked for some insights about interacting with CDO programmatically. I have since then been able to achieve a lot using CDO, and I am glad for the help I was given and thankful to the CDO team for their work.
I am now facing new issues, as my work with CDO gets bigger and bigger!
Working with a CDO repo and an EMF client, I have been able to implement functionalities in order to add EMF model elements to my CDO repo programmatically.
My goal is now to have two clients using the same repo, and when one client pushes modifications to the CDO base these modifications are replicated into the other client. I currently have the various mechanisms that I need but my question is the following : is it possible to identify which client has committed a CDOCommit ?
At this time, I have a single session for each of my client, each client has a transaction monitoring the latest state of the repo, and it catches a CDOViewAdaptersNotifiedEvent from which I get the changes and replicate them in the local model.
The problem is because I am reacting on changes to the latest state of the repo, this can happen :
- Client 1 creates an element A into its local model, and push it to the repo
- Client 1 monitoring transaction notices a change in the repo
- Client 1 replicates the change that happens in the repo, into the Client 1
- Client 1 now has two elements A
To avoid that, I thought maybe checking which SessionID produced the change would help me, since a client could just ignore commit that its session created. Is it the way to go or am I completely off track here ? Is it possible to get this kind of information based on a CDOViewAdaptersNotifiedEvent ?
As always, thanks for your time and your help, if you need any further details, I will be happy to tell you.
|Re: [CDO]Identify the author of a CDOCommit [message #1840423 is a reply to message #1840397]
||Thu, 15 April 2021 04:49
|| Eike Stepper
Registered: July 2009
What do you mean by "Client 1 replicates the change that happens in the repo, into the Client 1"? Have you written own code to patch your client 1 local model objects? If so, why? As you must have noticed, CDO is already doing that for you, and it's clear that you end up with duplicate elements if you "replicate" them again.
Regarding the availability of the user name, you can set up your client session like so:
ITCPConnector connector = TCPUtil.getConnector(IPluginContainer.INSTANCE, "localhost:2036");
CDONet4jSessionConfiguration configuration = CDONet4jUtil.createNet4jSessionConfiguration();
configuration.setCredentialsProvider(new PasswordCredentialsProvider("Eike", "12345"));
CDOSession session = configuration.openNet4jSession();
You'll see in the commit history that the commits (i.e., the CDOCommitInfos) carry the proper userID.
Powered by FUDForum
. Page generated in 0.01602 seconds