Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] How to get the userId of the user who locks a given CDO object(How to get the userId or at least the session that have a lock (lockType = WRITE) on a CDO element)
icon5.gif  [CDO] How to get the userId of the user who locks a given CDO object [message #757242] Thu, 17 November 2011 10:23 Go to next message
Jerome Godard is currently offline Jerome GodardFriend
Messages: 6
Registered: November 2010
Junior Member
Hi,

I use a CDO repository with UserManager enabled (CDO 4.0.1). I would like to decorate my project explorer with the id of the user that locks (lockType = WRITE) a CDO element so that a user can know the people that work on an other element.

For the moment I have the following method provided by CDOLockImpl:

  public boolean isLockedByOthers()
  {
    return object.cdoView().isObjectLocked(object, type, true);
  }


this method delegates to a CDOSessionProtocol instance
sessionProtocol.isObjectLocked(this, object, lockType, byOthers);


Is there a better way to retreive this user ID or at least retreive the session that has a lock on this element.

Thanks for your help,

Jérôme

[Updated on: Thu, 17 November 2011 10:40]

Report message to a moderator

Re: [CDO] How to get the userId of the user who locks a given CDO object [message #757267 is a reply to message #757242] Thu, 17 November 2011 12:22 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Did you try this:

cdoObject.cdoView().getSession().getUserID()
Re: [CDO] How to get the userId of the user who locks a given CDO object [message #757269 is a reply to message #757267] Thu, 17 November 2011 12:30 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
That should not work as it would just return the session user Neutral


Erdal Karaca wrote on Thu, 17 November 2011 07:22
Did you try this:

cdoObject.cdoView().getSession().getUserID()

Re: [CDO] How to get the userId of the user who locks a given CDO object [message #757962 is a reply to message #757242] Fri, 18 November 2011 05:20 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Jérôme,

We've enhanced the locking support significantly in CDO 4.1. The CDOObject interface now has the method cdoLockState()
which return the CDOLockState of an object:

public interface CDOLockState
{
public Object getLockedObject();
public boolean isLocked(LockType lockType, CDOLockOwner lockOwner, boolean others);
public Set<CDOLockOwner> getReadLockOwners();
public CDOLockOwner getWriteLockOwner();
public CDOLockOwner getWriteOptionOwner();
}

public interface CDOLockOwner
{
public int getSessionID();
public int getViewID();
public String getDurableLockingID();
public boolean isDurableView();
}

With session.getRemoteSessionManager().getRemoteSessions() you get an array of CDORemoteSessions:

public interface CDORemoteSession extends Comparable<CDORemoteSession>
{
public CDORemoteSessionManager getManager();
public int getSessionID();
public String getUserID();
public boolean isSubscribed();
public boolean sendMessage(CDORemoteSessionMessage message);
}

Does that help?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Am 17.11.2011 11:23, schrieb J:
> Hi,
>
> I use a CDO repository with UserManager enabled. I would like to decorate my project explorer with the id of the user
> that locks (lockType = WRITE) a CDO element so that a user can know the people that work on an other element.
>
> For the moment I have the following method provided by CDOLockImpl:
>
>
> public boolean isLockedByOthers()
> {
> return object.cdoView().isObjectLocked(object, type, true);
> }
>
>
> this method delegates to a CDOSessionProtocol instance
> sessionProtocol.isObjectLocked(this, object, lockType, byOthers);
>
>
> Is there a better way to retreive this user ID or at least retreive the session that has a lock on this element.
>
> Thanks for your help,
>
> Jérôme


Re: [CDO] How to get the userId of the user who locks a given CDO object [message #758297 is a reply to message #757962] Tue, 22 November 2011 15:47 Go to previous message
Jerome Godard is currently offline Jerome GodardFriend
Messages: 6
Registered: November 2010
Junior Member
Thanks for your answers.

I saw that the API regarding LockState has been enhanced in CDO 4.1. The problem is that the platform I am working on, is only CDO 4.0 compliant and that it can not be easily migrated to CDO 4.1. Anyway I will find a workaround waiting for the CDO 4.1 integration in my platform.
Previous Topic:Dynamic EMF and XSD
Next Topic:Binding Data with a textbox
Goto Forum:
  


Current Time: Wed Apr 24 16:23:18 GMT 2024

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

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

Back to the top