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 Brian Olore <bo...@us.ibm.com> on 2002/04/24 21:22:38 UTC

lockMethod() & unlockMethod() w/diff instances fails

I have read several posts on this topic, but am still unable to find a
clear solution.  The problem is that locking and unlocking a resource using
the same WebdavResource instance works great, but locking in one instance
and unlocking in another fails.  This is very troubling for those of us
that are trying to write 2 apps, one that locks, and another that unlocks.
I have yet to find a solution for this situation.

lockMethod() and unlockMethod() seem to be tied to the current session,
which is what i think is causing this problem.  The most frustrating part
is that isLocked() always returns the correct value.  So basically I *know*
there is a lock on the resource, I just can't unlock it via unlockMethod()
(it always returns false unless same instance or WebdavResource). In my
mind, it would make more sense to have the lockMethod() and unlockMethod()
tied to the data that isLocked() is using. Short of writing my own methods
that calls isLocked() and deals with the locks appropriately, is there
anything else I can do ?

I appreciate any solutions or work-arounds.
TIA
Brian
bolore@us.ibm.com



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: lockMethod() & unlockMethod() w/diff instances fails

Posted by Sung-Gu <jericho at apache.org>.
Hi Brian Olore,

----- Original Message ----- 
From: "Brian Olore" <bo...@us.ibm.com>
To: <sl...@jakarta.apache.org>
Sent: Thursday, April 25, 2002 4:22 AM
Subject: lockMethod() & unlockMethod() w/diff instances fails


> I have read several posts on this topic, but am still unable to find a
> clear solution.  The problem is that locking and unlocking a resource using
> the same WebdavResource instance works great, but locking in one instance
> and unlocking in another fails.  This is very troubling for those of us
> that are trying to write 2 apps, one that locks, and another that unlocks.
> I have yet to find a solution for this situation.

Do you mean that 2 apps are multi-threads or multi-instances(not multi-threaded)?

> lockMethod() and unlockMethod() seem to be tied to the current session,

It's correct to be tied to the current session.
More exactly, it's corrected to be tied to the same authority (including userinfo and server info)
If anybody unlocks a resource on the web, that would be a real problem.

> which is what i think is causing this problem.  The most frustrating part
> is that isLocked() always returns the correct value.  So basically I *know*
> there is a lock on the resource, I just can't unlock it via unlockMethod()
> (it always returns false unless same instance or WebdavResource). In my
> mind, it would make more sense to have the lockMethod() and unlockMethod()
> tied to the data that isLocked() is using. Short of writing my own methods
> that calls isLocked() and deals with the locks appropriately, is there
> anything else I can do ?

You can find a solution hacked by Tim Anderson from the recent mailing-list.
 http://www.mail-archive.com/slide-user@jakarta.apache.org/msg02056.html

> I appreciate any solutions or work-arounds.

For multi-threads, we should integrate with the shared stated from commons-httpclient 2.0 aplha.
As I know, the http client 2.0 alpha is somewhat buggy and hasn't tested yet enough.
I don't know its release plan either.

And there is an older way to fix this problem that was implemented and removed before.
I've commented it before.   It has a possibilty for even multi-instances, though it doesn't look nice.
http://www.mail-archive.com/slide-user@jakarta.apache.org/msg01987.html
Similarly, for example, implementing any sessions inherited from WebdavState including lock
information would be nice.   I haven't looked into any incorrect usages of that kinda way architecture yet.
So it might be a temporary solution.

And there would be an nice way to solve this problem,  that is saving lock infomation to the file.
However, we should consider the security issue about that.
Because the lock information is tied to the authority information like username and password.
So, it's not really considerd to be wise without other security mechanism like encryption? --a

I hope it will be help to you.

Sung-Gu

> TIA
> Brian
> bolore@us.ibm.com
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 

Re: lockMethod() & unlockMethod() w/diff instances fails

Posted by Elodie Tasia <e....@ever-team.com>.
I had the same problem last week. The only solution is to use the LockMethod
and UnlockMethod classes directly.

You get the locktoken in this way  (you need it to unlock) :

HttpClient client = new HttpClient();
HttpURL hu = this.davRes.getHttpURL();
client = davRes.getSessionInstance(hu);     // davRes is a instance of
WebdavResource
client.setDebug(10);
client.startSession(this.host, this.port, new Credentials(this.user,
this.passwd));
lm = new LockMethod(this.path, hu.getUserName()+"@"+hu.getHost(),
LockMethod.SCOPE_EXCLUSIVE, timeout);
lm.setDebug(10);
lm.setDepth(0);
client.executeMethod(lm);
code = lm.getStatusCode();
String lockToken = lm.getLockToken();


And you can unlock your resource in that way :

HttpClient client = new HttpClient();
client.setState(new WebdavState());    // don't forget that ! or it won't
work !
client.setDebug(10);
client.startSession(host, port, new Credentials(user, passwd));
um = new UnlockMethod(path);
um.setDebug(10);
um.setLockToken(lockToken);
client.executeMethod(um);

Good Luck !

----- Original Message -----
From: "Brian Olore" <bo...@us.ibm.com>
To: <sl...@jakarta.apache.org>
Sent: Wednesday, April 24, 2002 9:22 PM
Subject: lockMethod() & unlockMethod() w/diff instances fails


> I have read several posts on this topic, but am still unable to find a
> clear solution.  The problem is that locking and unlocking a resource
using
> the same WebdavResource instance works great, but locking in one instance
> and unlocking in another fails.  This is very troubling for those of us
> that are trying to write 2 apps, one that locks, and another that unlocks.
> I have yet to find a solution for this situation.
>
> lockMethod() and unlockMethod() seem to be tied to the current session,
> which is what i think is causing this problem.  The most frustrating part
> is that isLocked() always returns the correct value.  So basically I
*know*
> there is a lock on the resource, I just can't unlock it via unlockMethod()
> (it always returns false unless same instance or WebdavResource). In my
> mind, it would make more sense to have the lockMethod() and unlockMethod()
> tied to the data that isLocked() is using. Short of writing my own methods
> that calls isLocked() and deals with the locks appropriately, is there
> anything else I can do ?
>
> I appreciate any solutions or work-arounds.
> TIA
> Brian
> bolore@us.ibm.com
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>