use of javax.jcr.lock.LockManager in project jackrabbit by apache.
the class NodeImpl method unlock.
/**
* {@inheritDoc}
*/
public void unlock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
// check state of this instance
sanityCheck();
LockManager lockMgr = getSession().getWorkspace().getLockManager();
lockMgr.unlock(getPath());
}
use of javax.jcr.lock.LockManager in project jackrabbit by apache.
the class AbstractLockManagementTest method testLockBreaking.
public void testLockBreaking() throws RepositoryException, NotExecutableException {
String locktoken = null;
LockManager sulm = superuser.getWorkspace().getLockManager();
String lockedpath = null;
try {
Node trn = getTestNode();
modifyPrivileges(trn.getPath(), Privilege.JCR_READ, true);
modifyPrivileges(trn.getPath(), PrivilegeRegistry.REP_WRITE, true);
modifyPrivileges(trn.getPath(), Privilege.JCR_LOCK_MANAGEMENT, true);
Session lockingSession = trn.getSession();
assertFalse("super user and test user should have different user ids: " + lockingSession.getUserID() + " vs " + superuser.getUserID(), lockingSession.getUserID().equals(superuser.getUserID()));
trn.addNode("locktest", "nt:unstructured");
trn.addMixin("mix:lockable");
lockingSession.save();
// let the "other" user lock the node
LockManager oulm = lockingSession.getWorkspace().getLockManager();
Lock l = oulm.lock(trn.getPath(), true, false, Long.MAX_VALUE, null);
lockedpath = trn.getPath();
locktoken = l.getLockToken();
lockingSession.logout();
// transfer the lock token to the super user and try the unlock
Node lockednode = superuser.getNode(lockedpath);
assertTrue(lockednode.isLocked());
Lock sl = sulm.getLock(lockedpath);
assertNotNull(sl.getLockToken());
sulm.addLockToken(sl.getLockToken());
sulm.unlock(lockedpath);
locktoken = null;
} finally {
if (locktoken != null && lockedpath != null) {
sulm.addLockToken(locktoken);
sulm.unlock(lockedpath);
}
}
}
use of javax.jcr.lock.LockManager in project jackrabbit by apache.
the class LockManagerTest method testLockTransfer2.
public void testLockTransfer2() throws Exception {
assertLockable(testNode);
boolean sessionScoped = false;
Lock l = lockMgr.lock(testPath, true, sessionScoped, Long.MAX_VALUE, null);
String ltoken = l.getLockToken();
Session other = getHelper().getReadWriteSession();
LockManager otherLockMgr = getLockManager(other);
try {
lockMgr.removeLockToken(ltoken);
otherLockMgr.addLockToken(ltoken);
lockMgr.addLockToken(ltoken);
if (!openScopedLockMultiple) {
fail("Adding token to another session must fail (see config property " + RepositoryStub.PROP_OPEN_SCOPED_LOCK_MULTIPLE + ".");
}
} catch (LockException e) {
if (openScopedLockMultiple) {
fail("Adding token to another session must not fail (see config property " + RepositoryStub.PROP_OPEN_SCOPED_LOCK_MULTIPLE + ".");
}
} finally {
otherLockMgr.removeLockToken(ltoken);
lockMgr.addLockToken(ltoken);
other.logout();
}
}
use of javax.jcr.lock.LockManager in project jackrabbit by apache.
the class NodeImpl method getLock.
/**
* {@inheritDoc}
*/
public Lock getLock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, RepositoryException {
// check state of this instance
sanityCheck();
LockManager lockMgr = getSession().getWorkspace().getLockManager();
return lockMgr.getLock(getPath());
}
use of javax.jcr.lock.LockManager in project jackrabbit by apache.
the class ServerWorkspace method getLockManager.
/** {@inheritDoc} */
public RemoteLockManager getLockManager() throws RepositoryException, RemoteException {
try {
if (remoteLockManager == null) {
LockManager lockManager = workspace.getLockManager();
remoteLockManager = getFactory().getRemoteLockManager(lockManager);
}
return remoteLockManager;
} catch (RepositoryException ex) {
throw getRepositoryException(ex);
}
}
Aggregations