Alfresco node locking in a web script
What I am trying to do is create a set of alfresco web scripts that will allow me to interact with the files in my webproject. I manage to make all the operations of a normal filesystem (list, edit, delete, rename, etc) but i have a huge problem with the lock mechanism. Once someone edits a file in his own sandbox the file must be locked.
Now in the开发者_如何学Go listing of the files, i have access to a method called isLocked() that tells me if a node is locked or not and I can see the owner of the lock as well. These locks were added from the Alfresco default web interface.
And to my question, how can I lock/unlock a node from the a web script ?
Unfortunately there's no Javascript bridge to the LockService
, meaning you need to develop a Java-backed Web Script. You will be then able to do something like:
LockStatus lockStatus = lockService.getLockStatus(node);
if (LockStatus.LOCKED.equals(lockStatus) ||
LockStatus.LOCK_OWNER.equals(lockStatus)) {
lockService.unlock(node);
}
I guess you can do two things:
1) use the Check-in/out Javascript API Wiki location. If a document is checked-out it will get locked and put in Read-Only mode. And the user can check it in, when he's done.
2) use a Java Backed Webscript with pure Java, you have more control on it. You can lock, unlock etc.
精彩评论