• Code assistance

  • OpenKM has many interesting features, but requires some configuration process to show its full potential.
OpenKM has many interesting features, but requires some configuration process to show its full potential.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #14961  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...
 #14982  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.
 #15047  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...?
 #15058  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.
 #15085  by jllort
 
Something like
OKMDocument.getInstance().lock(null, docPath);

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.