[CDO] How to get the userId of the user who locks a given CDO object [message #757242] |
Thu, 17 November 2011 10:23 |
Jerome Godard 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 #757962 is a reply to message #757242] |
Fri, 18 November 2011 05:20 |
|
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
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
Powered by
FUDForum. Page generated in 0.03366 seconds