A node-level locking service, used by the CheckOutCheckIn service. Does not create a working copy. If you need a node-level locking system, then the LockService can provide this. Functionality provided by the service includes:
- Checking for a lock on a node
- Obtaining lock information
- Locking and unlocking a node
- Suspend and enable locks
Example checking if a node is locked:
/**
* Return whether a Node is currently locked
* @param node The Node wrapper to test against
* @param lockService The LockService to use
* @return whether a Node is currently locked
*/
public static Boolean isNodeLocked(Node node,LockService lockService) {
Boolean locked = Boolean.FALSE;
if (node.hasAspect(ContentModel.ASPECT_LOCKABLE)) {
LockStatus lockStatus = serviceRegistry.getLockService().getLockStatus(node.getNodeRef());
if (lockStatus == LockStatus.LOCKED || lockStatus == LockStatus.LOCK_OWNER) {
locked = Boolean.TRUE;
}
}
return locked;
}