Page 1 of 1

Code assistance

PostPosted:Mon Mar 26, 2012 7:49 am
by vkasgpta
Hi,

I am trying to make a script to auto unlock documents if they have been locked for more then a day. Currently i am facing an issue where users use Word to check out the documents, save them so they can email the document to someone (subscription is not working...) then try to check in the document. In this process word cannot check in the document so they try to use IE to check in but it says for the same user that the node is locked. To fix this i have to login to unlock through repository in admin view...

So i am now thinking to use a script to fix that until i get the subscription working... Any ideas on the code to accomplish this? well i am thinking of this:
Code: Select all
where timeout.time > 1440
timeout.unlock
Of course i have no idea on the actual variable name so i need help with that...

Re: Code assistance

PostPosted:Tue Mar 27, 2012 6:27 pm
by pavila
This kind of job can be implemented using the Crontab feature. You can make an XPath query to get the locked nodes (see samples in administration) and after that, unlock them.

Re: Code assistance

PostPosted:Sun Apr 01, 2012 6:37 am
by vkasgpta
pavila wrote:This kind of job can be implemented using the Crontab feature. You can make an XPath query to get the locked nodes (see samples in administration) and after that, unlock them.
thx pavila, i got the xpath query:
Code: Select all
/jcr:root/okm:root//element(*,okm:document)[@jcr:lockOwner]/@jcr:lockOwner
I checked out the samples but i could not understand them... I used the query translator to kind of get this in sql since im more familiar with that...
The translator cant seem to recognize update though...:
Code: Select all
UPDATE jcr:lockOwner FROM okm:document set jcr:lockOwner NULL WHERE jcr:lockOwner IS NOT NULL AND jcr:path LIKE '/okm:root[%]/%'
But i think this does not address the check in feature...?

Re: Code assistance

PostPosted:Mon Apr 02, 2012 12:20 pm
by pavila
In order to unlock you need to use the OpenKM API or de Jackrabbit low-level API. The XPath is only to retrieve the list of locked nodes.

Re: Code assistance

PostPosted:Thu Apr 05, 2012 9:24 am
by jllort
Something like
OKMDocument.getInstance().lock(null, docPath);