Page 1 of 1

Purge Trash Script - LockException

PostPosted:Fri Aug 30, 2013 8:07 am
by Catscratch
Hi there,

I'm trying to use the Purge Trash script you provided here:
http://wiki.openkm.com/index.php/Script ... sers_trash

But when executing I got a LockException in Line 18:
OKMDocument.getInstance().purge(token, doc.getPath());

Exception:
Code: Select all
target exception : at Line: 18 :   
	.purge ( token , doc .getPath ( ) ) 
  Target exception: com.openkm.core.LockException: 1505bfd9-99e0-4dc2-81dd-5a788aec2d7c : 5355df4f-8d7d-40a8-8482-8e1a3d3fc2a0
Hm. What is the problem here and how to solve it?

Thanks a lot,
regards.

EDIT: The exception occurs on the first user trash that is not empty.

Re: Purge Trash Script - LockException

PostPosted:Sat Aug 31, 2013 10:45 am
by jllort
Seems there's a document locked ( can be on edition ) and that's the reason why you're not allowed to delete it.

here you got two uuid, I do not know which is the document uuid should take a look on okm_document_node table to get the document name filtering by uuid you got on error.

Which openkm version are you using ?

Re: Purge Trash Script - LockException

PostPosted:Sat Aug 31, 2013 6:37 pm
by Catscratch
You're right. The first UUID is the document UUID and I had a look. It is checked out for editing.


I manually cancelt editing.

Now the question is how to solve this problem automatically in the future? Is there a way to extend the purge script to check for a document lock and automatically unlock it?

PS: My OKM version is listed in my signature.

Re: Purge Trash Script - LockException

PostPosted:Wed Sep 04, 2013 6:14 pm
by jllort
The easiest way is in your code control de LockException ( try catch ) and unlock.

Re: Purge Trash Script - LockException

PostPosted:Wed Sep 04, 2013 6:21 pm
by Catscratch
Hm, maybe this is a good feature request for your next release. Because it seems like a bug that locked documents stay locked, even in the trash. A document should automatically be unlocked when deleting it (to trash).

Re: Purge Trash Script - LockException

PostPosted:Thu Sep 05, 2013 7:33 am
by pavila
Well, see it as a feature :P Anyway, contributions are welcome.