I also trying to locking a resource. each time after I lock a resource, I close the webdavSource immediately, when I create a new webdavSource to unlock the resource, I fail. could you give me more details of your ways to solve the problem. My colde is shown as following:
public boolean lockFile(String lockURL,String lockFilename,String username,String password){
try{
HttpURL hrl = new HttpURL(lockURL);
hrl.setUserinfo(username,password);
WebdavResource wdr = new WebdavResource(hrl);
if(!wdr.isCollection()){
throw new Exception("Path is currently a file!");
}
String currentPath = wdr.getPath();
//make sure the path end with "/"
int len = currentPath.lastIndexOf("/")+1;
if(len!=currentPath.length()){
wdr.setPath(currentPath + "/");
}
wdr.setPath(currentPath + lockFilename);
System.out.println(wdr.getPath());
if(wdr.isLocked()){
return false;
}
boolean returnVal = wdr.lockMethod();
wdr.close();
return returnVal;
}
catch(Exception e){
System.out.println(e);
}
return false;
}public boolean unlockFile(String unlockURL, String unlockFilename, String username, String password){
try{
HttpURL hrl = new HttpURL(unlockURL);
hrl.setUserinfo(username,password);
WebdavResource wdr = new WebdavResource(hrl);
if(!wdr.isCollection()){
throw new Exception("Path is currently a file!");
}
String currentPath = wdr.getPath();
//make sure the path end with "/"
int len = currentPath.lastIndexOf("/")+1;
if(len!=currentPath.length()){
wdr.setPath(currentPath + "/");
}
wdr.setPath(currentPath + unlockFilename);
System.out.println(wdr.getPath()); if(!wdr.isLocked()){
return false;
} System.out.println("is it locked? "+wdr.isLocked());
LockDiscoveryProperty lockDiscovery = wdr.getLockDiscovery();
Lock[] locks = lockDiscovery.getActiveLocks();
boolean returnVal = wdr.unlockMethod();
wdr.close();
return returnVal;
}
catch(Exception e){
System.out.println(e);
}
return false;
}any help would be appreciated.
From: "Andreas Probst" <[EMAIL PROTECTED]>
Reply-To: "Slide Users Mailing List" <[EMAIL PROTECTED]>
To: "Slide Users Mailing List" <[EMAIL PROTECTED]>
Subject: RE: Locking a resource and act on it in a different (WebDAV)session
Date: Sun, 11 Apr 2004 07:10:02 +0200
This is called stealing a thread, not stealing a lock.
On 10 Apr 2004 at 18:50, Uma Gajendragadkar wrote:
> Where can I download "rc1" from? > > Thanks > Uma > > -----Original Message----- > From: Rolf Kulemann [mailto:[EMAIL PROTECTED] > Sent: Saturday, April 10, 2004 6:46 PM > To: Slide Users Mailing List > Subject: Re: Locking a resource and act on it in a different > (WebDAV)session > > On Fri, 2004-04-09 at 23:12, Andreas Probst wrote: > > Hi Rolf, > > > > to act on a locked resource it is necessary to give the lock > > token in the request. If I remember correctly, the spec > > recommends a client to send the lock token only if this client > > issued the lock. This way no client can steal the lock of > > another client of the same user. If you want to act on the > > resource with another client, read the lock token and send it > > with the request. So it should be possible the steal the lock of > > the other session. > > Thanks, but my problem was solved with rc1. There is now a new method on > the WebdavResource called discoverOwnLocks() which makes live much > easier. > > Thanks for ur reply. > > -- > Regards, > > Rolf Kulemann > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] >
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
