diff --git a/source/java/org/alfresco/repo/lock/LockServiceImpl.java b/source/java/org/alfresco/repo/lock/LockServiceImpl.java index 144ccf0156..4db0a0ef9b 100644 --- a/source/java/org/alfresco/repo/lock/LockServiceImpl.java +++ b/source/java/org/alfresco/repo/lock/LockServiceImpl.java @@ -317,6 +317,25 @@ public class LockServiceImpl implements LockService, public void lock(NodeRef nodeRef, LockType lockType, int timeToExpire, Lifetime lifetime) { lock(nodeRef, lockType, timeToExpire, lifetime, null); + } + + /** + * @see org.alfresco.service.cmr.lock.LockService#lock(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.lock.LockType, int, Lifetime, boolean) + */ + @Override + @Extend(traitAPI=LockServiceTrait.class,extensionAPI=LockServiceExtension.class) + public void lock(NodeRef nodeRef, LockType lockType, int timeToExpire, Lifetime lifetime, boolean lockChildren) + { + lock(nodeRef, lockType, timeToExpire, lifetime); + + if (lockChildren) + { + Collection childAssocRefs = this.nodeService.getChildAssocs(nodeRef); + for (ChildAssociationRef childAssocRef : childAssocRefs) + { + lock(childAssocRef.getChildRef(), lockType, timeToExpire, lifetime, lockChildren); + } + } } /** diff --git a/source/java/org/alfresco/repo/virtual/bundle/VirtualLockServiceExtension.java b/source/java/org/alfresco/repo/virtual/bundle/VirtualLockServiceExtension.java index 337e9a020b..98caf51f68 100644 --- a/source/java/org/alfresco/repo/virtual/bundle/VirtualLockServiceExtension.java +++ b/source/java/org/alfresco/repo/virtual/bundle/VirtualLockServiceExtension.java @@ -101,6 +101,17 @@ public class VirtualLockServiceExtension extends SpringBeanExtension nodeRefs, LockType lockType, int timeToExpire) throws UnableToAquireLockException diff --git a/source/java/org/alfresco/service/cmr/lock/LockService.java b/source/java/org/alfresco/service/cmr/lock/LockService.java index 60a7179fc1..bdb2ba6cbb 100644 --- a/source/java/org/alfresco/service/cmr/lock/LockService.java +++ b/source/java/org/alfresco/service/cmr/lock/LockService.java @@ -143,13 +143,13 @@ public interface LockService /** * Places a lock on a node and optionally on all its children. *

- * The lock prevents any other user or process from comitting updates + * The lock prevents any other user or process from committing updates * to the node until the lock is released. *

* The lock will be owned by the current user. *

* If any one of the child locks can not be taken then an exception will - * be raised and all locks canceled. + * be raised and all locks cancelled. *

* If the time to expire is 0 then the lock will never expire. Otherwise the * timeToExpire indicates the number of seconds before the lock expires. When @@ -171,6 +171,35 @@ public interface LockService @Auditable(parameters = {"nodeRef", "lockType", "timeToExpire", "lockChildren"}) public void lock(NodeRef nodeRef, LockType lockType, int timeToExpire, boolean lockChildren) throws UnableToAquireLockException; + + /** + * Places a lock on a node and optionally on all its children. + *

+ * The lock prevents any other user or process from committing updates + * to the node until the lock is released. + *

+ * The lock will be owned by the current user. + *

+ * If the time to expire is 0 then the lock will never expire. Otherwise the + * timeToExpire indicates the number of seconds before the lock expires. When + * a lock expires the lock is considered to have been released. + *

+ * If the node is already locked and the user is the lock owner then the lock will + * be renewed with the passed timeToExpire. + * + * @param nodeRef a reference to a node + * @param lockType the lock type + * @param timeToExpire the number of seconds before the locks expires. + * @param lifetime allows persistent or ephemeral locks to be specified. + * @param lockChildren if true indicates that all the children (and + * grandchildren, etc) of the node will also be locked, + * false otherwise + * @throws UnableToAquireLockException + * thrown if the lock could not be obtained + */ + @Auditable(parameters = {"nodeRef", "lockType", "timeToExpire", "lifetime", "lockChildren"}) + public void lock(NodeRef nodeRef, LockType lockType, int timeToExpire, Lifetime lifetime, boolean lockChildren) + throws UnableToAquireLockException; /** * Places a lock on all the nodes referenced in the passed list.