You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-user@jakarta.apache.org by Po...@FT.com on 2003/09/15 11:45:32 UTC
How do we steal locks in Slide?
If I call UnlockMethod(path, locktoken), provided my session has the same
user login as when the lock was created, I can unlock the resource. What do
I need to do if I want to "steal" a lock and unlock it regardless of
user-lock-affinity?
Thanks!
Portia
**********************************************************************************
This email may contain confidential material. If you were not an
intended recipient, please notify the sender and delete all copies.
We may monitor email to and from our network.
Re: How do we steal locks in Slide?
Posted by Andreas Probst <an...@gmx.net>.
Hi Portia
Do you use WebDAV API or Slide API?
What I did from a year ago until half a year ago. I don't know
whether this still works with current slide: I just get the lock
token and call unlock. (with WebDAV-API)
WebdavResource wr = <init>;
if (wr.isLocked())
{
// idea from WebdavResource
HttpURL httpURL = wr.getHttpURL();
HttpClient client = wr.getSessionInstance(httpURL);
LockDiscoveryProperty lockDiscovery =
wr.getLockDiscovery();
Lock locks[] = lockDiscovery.getActiveLocks();
String lock = locks[0].getLockToken();
String owner = locks[0].getOwner();
if (lock == null)
{
logger.info(path+" not locked. ");
//shouldn't be true here, as we asked isLocked()
}
//here you can steal the lock
else if (owner.endsWith("/"+userName))
{
logger.info("locktoken: "+lock);
// unlock for the given path.
org.apache.webdav.lib.methods.UnlockMethod method
= new
org.apache.webdav.lib.methods.UnlockMethod(path);
generateIfHeader here, see WebdavResource
method.setLockToken(lock);
int statusCode = client.executeMethod(method);
if (statusCode >= 200 && statusCode < 300)
{
result = true;
}
else
{
result = false;
}
method.releaseConnection();
Andreas
On 15 Sep 2003 at 9:45, Portia.Tung@FT.com wrote:
>
> If I call UnlockMethod(path, locktoken), provided my session has the same
> user login as when the lock was created, I can unlock the resource. What do
> I need to do if I want to "steal" a lock and unlock it regardless of
> user-lock-affinity?
>
> Thanks!
> Portia
>
>
>
>
> **********************************************************************************
> This email may contain confidential material. If you were not an
> intended recipient, please notify the sender and delete all copies.
> We may monitor email to and from our network.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: slide-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org
Re: How do we steal locks in Slide?
Posted by Andreas Probst <an...@gmx.net>.
Hi Portia
Do you use WebDAV API or Slide API?
What I did from a year ago until half a year ago. I don't know
whether this still works with current slide: I just get the lock
token and call unlock. (with WebDAV-API)
WebdavResource wr = <init>;
if (wr.isLocked())
{
// idea from WebdavResource
HttpURL httpURL = wr.getHttpURL();
HttpClient client = wr.getSessionInstance(httpURL);
LockDiscoveryProperty lockDiscovery =
wr.getLockDiscovery();
Lock locks[] = lockDiscovery.getActiveLocks();
String lock = locks[0].getLockToken();
String owner = locks[0].getOwner();
if (lock == null)
{
logger.info(path+" not locked. ");
//shouldn't be true here, as we asked isLocked()
}
//here you can steal the lock
else if (owner.endsWith("/"+userName))
{
logger.info("locktoken: "+lock);
// unlock for the given path.
org.apache.webdav.lib.methods.UnlockMethod method
= new
org.apache.webdav.lib.methods.UnlockMethod(path);
generateIfHeader here, see WebdavResource
method.setLockToken(lock);
int statusCode = client.executeMethod(method);
if (statusCode >= 200 && statusCode < 300)
{
result = true;
}
else
{
result = false;
}
method.releaseConnection();
Andreas
On 15 Sep 2003 at 9:45, Portia.Tung@FT.com wrote:
>
> If I call UnlockMethod(path, locktoken), provided my session has the same
> user login as when the lock was created, I can unlock the resource. What do
> I need to do if I want to "steal" a lock and unlock it regardless of
> user-lock-affinity?
>
> Thanks!
> Portia
>
>
>
>
> **********************************************************************************
> This email may contain confidential material. If you were not an
> intended recipient, please notify the sender and delete all copies.
> We may monitor email to and from our network.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: slide-user-help@jakarta.apache.org
>