[opencms-dev] CmsLockException when updating content

Christian Steinert christian_steinert at web.de
Sat Nov 21 09:38:59 CET 2009


Vaclav Balak wrote:
> I tried to unlock file itself, but it always was the same: Error
> unlocking resource "/sites/..." by current user "Admin" - Resource
> "/sites/..." is not locked by current user "Admin". When I use
> browser, it tells me 'No exclusive locks found! ', so where can be
> problem?
>   
Dear Vaclav

You can only unlock a file, when the current user is the one that has 
locked it before.
If another user has locked the file, you first need to steal the lock.
 
There is still one situation when you cannot unlock a resource: if the 
resource is in the process of being published. At that time the resource 
is blocked by opencms itself and cannot be unlocked by normal means. 
This seems to be a conscious design decision of the opencms developers - 
if there is a publish lock, then there is nothing you can do.

Roman wrote that they had lock errors that were unexpected but so far, 
all the locking and unlocking behavior that I have seen in opencms made 
complete sense to me

-----
So before you try to unlock a resource, just try the following:

// check, if the resource is locked at all and if the resource has no 
publish lock
// ...

try{
  //take over lock from another user
  cmsObject.changeLock( resourcePath );
}catch(CmsException e) {
  //resource was not locked by another user
}

// unlock the resource
// ...

Kind regards
Christian





More information about the opencms-dev mailing list