Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] To know if a Resource is being modified by others
icon5.gif  [CDO] To know if a Resource is being modified by others [message #1059179] Fri, 17 May 2013 07:07 Go to next message
Marc Gil is currently offline Marc Gil
Messages: 81
Registered: July 2009
Member
Hi,

Is it possible to know if a Resource is being edited or modified by other users? Not read/write locked but being edited in a normal way, for instance via CDO Editor or others.

Thanks,
Marc
Re: [CDO] To know if a Resource is being modified by others [message #1059183 is a reply to message #1059179] Fri, 17 May 2013 07:35 Go to previous messageGo to next message
Marc Gil is currently offline Marc Gil
Messages: 81
Registered: July 2009
Member
I can access to the list of remote sessions, but I think I can't inspect the list of views or transactions opened by these sessions...

resourceNode.cdoView().getSession().getRemoteSessionManager().getRemoteSessions()

Cheers,
Marc
Re: [CDO] To know if a Resource is being modified by others [message #1059278 is a reply to message #1059179] Fri, 17 May 2013 07:21 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5525
Registered: July 2009
Senior Member
Am 17.05.2013 09:07, schrieb Marc Gil:
> Hi,
>
> Is it possible to know if a Resource is being edited or modified by other users? Not read/write locked but being
> edited in a normal way, for instance via CDO Editor or others.
No, the server and, hence, other clients are only notified about commits and lock changes, not all getter or setter
calls that happen in a local transaction.

You can either implement your own Net4j SignalProtocol (see examples) or use
CDORemoteSessionManager.sendMessage(CDORemoteSessionMessage, CDORemoteSession...). The CDORemoteSessionManager is
accessible via CDOSession.getRemoteSessionManager().

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [CDO] To know if a Resource is being modified by others [message #1059279 is a reply to message #1059183] Fri, 17 May 2013 07:41 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5525
Registered: July 2009
Senior Member
Am 17.05.2013 09:35, schrieb Marc Gil:
> I can access to the list of remote sessions, but I think I can't inspect the list of views or transactions opened by
> these sessions...
No, that's not possible. Neither could you determine complex information such as remote object dirty state.

You need to use sendMessage() to implement your own protocol. I.e., when something happens locally that other remote
sessions might be interested in you need to:

1) detect it (normally with an IListener) and

2) send it to the remote sessions (where the message can be handled appropriately),

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [CDO] To know if a Resource is being modified by others [message #1059356 is a reply to message #1059279] Fri, 17 May 2013 15:49 Go to previous messageGo to next message
Marc Gil is currently offline Marc Gil
Messages: 81
Registered: July 2009
Member
Thanks Eike,

Finally I solved it using IListeners, and when a commit happens I do what I need.

The scenario is the following:
- User A has the resourceNode X opened, for instance, with the CDO Editor.
- User B tries to rename or delete the resourceNode X.

I wanted that User B receives an alert indicating there are users that has this resource opened, in order to prevent some errors. One solution is that A has opened the resourceNode in lock mode, so B could not rename it. Another solution is that B renames the resource, and then A receives a message alerting that the editor is going to be closed. Of course, all the non saved changes will be lost... I have implemented both of them.

Cheers,
Marc
Re: [CDO] To know if a Resource is being modified by others [message #1059365 is a reply to message #1059356] Fri, 17 May 2013 16:34 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5525
Registered: July 2009
Senior Member
Am 17.05.2013 17:49, schrieb Marc Gil:
> Thanks Eike,
>
> Finally I solved it using IListeners, and when a commit happens I do what I need.
>
> The scenario is the following:
> - User A has the resourceNode X opened, for instance, with the CDO Editor.
> - User B tries to rename or delete the resourceNode X.
>
> I wanted that User B receives an alert indicating there are users that has this resource opened, in order to prevent
> some errors. One solution is that A has opened the resourceNode in lock mode, so B could not rename it.
+1

> Another solution is that B renames the resource, and then A receives a message alerting that the editor is going to be
> closed. Of course, all the non saved changes will be lost... I have implemented both of them.
Why doesn't the receiving editor just handle the rename such that it can stay open?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [CDO] To know if a Resource is being modified by others [message #1059366 is a reply to message #1059365] Fri, 17 May 2013 16:41 Go to previous message
Marc Gil is currently offline Marc Gil
Messages: 81
Registered: July 2009
Member
Let me to say that my editor is not as "easy" as the default cdo editor was Razz And at this moment, I have no time to manage this solution, but I have annotated it and when I can include your solution I will implement it Smile

Thanks Eike!
Marc
Previous Topic:Creating an OCLExpression expensive?
Next Topic:Change EMF properties and refresh Property View
Goto Forum:
  


Current Time: Tue Sep 23 10:39:04 GMT 2014

Powered by FUDForum. Page generated in 0.01958 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software