[CDO]Identify the author of a CDOCommit [message #1840397] |
Wed, 14 April 2021 07:43 |
Xavier GISTAU Messages: 6 Registered: February 2019 |
Junior Member |
|
|
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.
Best regards,
Xavier
|
|
|
Re: [CDO]Identify the author of a CDOCommit [message #1840423 is a reply to message #1840397] |
Thu, 15 April 2021 04:49 |
|
Hi Xavier,
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.setConnector(connector);
configuration.setRepositoryName("repo1");
if (serverIsAuthenticating)
{
configuration.setCredentialsProvider(new PasswordCredentialsProvider("Eike", "12345"));
}
else
{
configuration.setUserID("Eike");
}
CDOSession session = configuration.openNet4jSession();
You'll see in the commit history that the commits (i.e., the CDOCommitInfos) carry the proper userID.
Cheers
Eike
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
Re: [CDO]Identify the author of a CDOCommit [message #1840474 is a reply to message #1840434] |
Fri, 16 April 2021 04:07 |
|
Xavier GISTAU wrote
none of them was replicated into my local model
You still haven't explained what you mean by "my local model" and I have no clue. Are you aware that the CDOTransaction that you are returning from your "connection method" provides you with a local model? You can enter and access it through different ways:
ResourceSet rset = tx.getResourceSet();
Or:
Resource res = tx.getResource("/my-folder/my-model");
Or:
EObject obj = tx.getObject(cdoid);
Xavier GISTAU wrote
Net4jUtil.prepareContainer(IPluginContainer.INSTANCE);
You don't need any of the XyzUtil.prepareContainer() calls if you're running inside Eclipse, i.e., with the extension registry enabled.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03422 seconds