[opencms-dev] CmsLockException when updating content
Roman Uhlig Maxity.de
roman.uhlig at maxity.de
Fri Nov 20 14:56:01 CET 2009
We do it like that:
if (cmso.existsResource(resource)) {
cmso.lockResourceTemporary(resource);
cmso.deleteResource(resource, CmsResource.DELETE_PRESERVE_SIBLINGS);
try { cmso.unlockResource(resource); }
catch (Exception ignore) {}
}
It seems that unlocking through API sometimes is not working/is not necessary though you would think it is (not only for deleting). This is why we completely ignore any unlock exceptions, in our tests they were always "fake".
Roman
-----Ursprüngliche Nachricht-----
Von: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] Im Auftrag von Vaclav Balak
Gesendet: Freitag, 20. November 2009 14:40
An: opencms-dev at opencms.org
Betreff: [opencms-dev] CmsLockException when updating content
Hi,
I'm trying to create (or alter) content, like this:
try{
System.out.println("Creating new layout...");
cmsObject.createResource(newResname, resTypeId,
content.getBytes(), properties);
}catch(Exception e){
System.out.println("Rewriting existing layout...");
String parentResname =
cmsObject.getRequestContext().getFileTranslator().translateResource(
CmsResource.getParentFolder(newResname));
cmsObject.unlockResource(parentResname);
cmsObject.replaceResource(newResname, resTypeId,
content.getBytes(), properties);
}
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?
In wiki is just 'Writing content' article, not 'Editing' :-( (
http://opencms-wiki.org/Creating_and_editing_files ).
So, how can I edit (or delete) file?
Thanks in advance,
shMoula
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev
More information about the opencms-dev
mailing list