@Test @FixFor("MODE-2654") public void shouldNotCopyLocks()throws Exception { Node parentNode = session.getRootNode().addNode("node"); Node childNode = parentNode.addNode("child"); childNode.addMixin("mix:lockable"); session.save(); JcrWorkspace workspace = session.getWorkspace(); JcrLockManager lockManager = workspace.getLockManager(); lockManager.lock("/node/child", false, false, Long.MAX_VALUE, null); assertTrue(session.getNode("/node/child").isLocked()); workspace.copy("/node", "/newPath"); assertFalse(session.getNode("/newPath").isLocked()); assertFalse(session.getNode("/newPath/child").isLocked()); lockManager.lock("/newPath/child", false, false, Long.MAX_VALUE, null); assertTrue(session.getNode("/newPath/child").isLocked()); } }
throw new LockException(JcrI18n.nodeNotLockable.text(node.location())); if (node.isLocked()) { throw new LockException(JcrI18n.alreadyLocked.text(node.location()));
throw new LockException(JcrI18n.nodeNotLockable.text(node.location())); if (node.isLocked()) { throw new LockException(JcrI18n.alreadyLocked.text(node.location()));
if (node.isNodeType(JcrMixLexicon.LOCKABLE) && node.isLocked()) {
if (node.isNodeType(JcrMixLexicon.LOCKABLE) && node.isLocked()) {
if (node.isLocked() && !node.holdsLock()) { throw new LockException(JcrI18n.lockTokenNotHeld.text(node.getPath()));
@Test @FixFor( "MODE-2641" ) public void shouldNotProvideTimeoutForSessionScopedLocks() throws Exception { // Create a new lockable node Node node = session.getRootNode().addNode("test"); node.addMixin("mix:lockable"); session.save(); String path = node.getPath(); // Lock the node with a session scoped lock int timeout = 2; JcrLockManager lockManager = session.getWorkspace().getLockManager(); Lock lock = lockManager.lock(node.getPath(), false, true, timeout, null); assertTrue(node.isLocked()); assertEquals("Session scoped locks should not have timeout information", Long.MAX_VALUE, lock.getSecondsRemaining()); JcrSession otherSession = repository.login(); try { lockManager = otherSession.getWorkspace().getLockManager(); lock = lockManager.getLock(path); assertTrue(otherSession.getNode(path).isLocked()); assertEquals("Session scoped locks should not have timeout information", Long.MAX_VALUE, lock.getSecondsRemaining()); } finally { otherSession.logout(); } }
if (node.isLocked() && !node.holdsLock()) { throw new LockException(JcrI18n.lockTokenNotHeld.text(node.getPath()));
@FixFor( "MODE-2623" ) @Test public void shouldAllowLockUnlockWithinTransaction() throws Exception { final String path = "/test"; Node parent = session.getRootNode().addNode("test"); parent.addMixin("mix:lockable"); session.save(); startTransaction(); LockManager lockMgr = session.getWorkspace().getLockManager(); lockMgr.lock(path, true, true, Long.MAX_VALUE, session.getUserID()); lockMgr.unlock(path); commitTransaction(); assertFalse(session.getNode(path).isLocked()); }
if (node.isLocked() && !node.holdsLock()) { throw new LockException(JcrI18n.lockTokenNotHeld.text(node.getPath()));
if (node.isLocked() && !node.holdsLock()) { throw new LockException(JcrI18n.lockTokenNotHeld.text(node.getPath()));
if (nodeToCheckLock.isLocked() && !nodeToCheckLock.holdsLock()) { throw new LockException(JcrI18n.lockTokenNotHeld.text(nodeToCheckLock.getPath()));
if (nodeToCheckLock.isLocked() && !nodeToCheckLock.holdsLock()) { throw new LockException(JcrI18n.lockTokenNotHeld.text(nodeToCheckLock.getPath()));