本文整理了Java中javax.jcr.lock.Lock.getLockToken()
方法的一些代码示例,展示了Lock.getLockToken()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lock.getLockToken()
方法的具体详情如下:
包路径:javax.jcr.lock.Lock
类名称:Lock
方法名:getLockToken
[英]May return the lock token for this lock. If this lock is open-scoped and the current session either holds the lock token for this lock, or the repository chooses to expose the lock token to the current session, then this method will return that lock token. Otherwise this method will return null
.
[中]可以返回此锁的锁令牌。如果此锁是开放范围的,并且当前会话持有此锁的锁令牌,或者存储库选择向当前会话公开锁令牌,则此方法将返回该锁令牌。否则,此方法将返回null
。
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
@Override
public String getLockToken() {
synchronized (session) {
return lock.getLockToken();
}
}
代码示例来源:origin: net.adamcin.oakpal/oakpal-core
@Override
public String getLockToken() {
return delegate.getLockToken();
}
代码示例来源:origin: apache/jackrabbit
/** {@inheritDoc} */
public String getLockToken() throws RemoteException {
return lock.getLockToken();
}
代码示例来源:origin: org.apache/jackrabbit-ocm
public String getLockToken() {
return lock.getLockToken();
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-ocm
public String getLockToken() {
return lock.getLockToken();
}
代码示例来源:origin: apache/jackrabbit
/**
*
*/
public void testGetLockToken() {
assertNotNull("A open scoped lock must expose the token to the lock holder.", lock.getLockToken());
}
}
代码示例来源:origin: apache/jackrabbit
/**
* {@link javax.jcr.lock.Lock#getLockToken()} must
* always return <code>null</code> for session scoped locks.
*/
public void testGetLockToken() {
assertNull("A session scoped lock may never expose the token.", lock.getLockToken());
}
代码示例来源:origin: pentaho/pentaho-platform
/**
* Stores a lock token associated with the session's user.
*/
protected void addLockToken( final Session session, final PentahoJcrConstants pentahoJcrConstants, final Lock lock )
throws RepositoryException {
Node lockTokensNode = getOrCreateLockTokensNode( session, pentahoJcrConstants, lock );
Node newLockTokenNode =
lockTokensNode.addNode( lock.getNode().getIdentifier(), pentahoJcrConstants.getPHO_NT_LOCKTOKENSTORAGE() );
newLockTokenNode.setProperty( pentahoJcrConstants.getPHO_LOCKEDNODEREF(), lock.getNode() );
newLockTokenNode.setProperty( pentahoJcrConstants.getPHO_LOCKTOKEN(), lock.getLockToken() );
session.save();
}
代码示例来源:origin: apache/jackrabbit
public void testAddLockToken() throws RepositoryException,
NotExecutableException {
assertLockable(testNode);
boolean sessionScoped = false;
Lock l = lockMgr.lock(testPath, true, sessionScoped, Long.MAX_VALUE, null);
String ltoken = l.getLockToken();
// adding lock token should have no effect.
lockMgr.addLockToken(ltoken);
}
代码示例来源:origin: apache/jackrabbit
public void testTokenTransfer() throws Exception {
String lockToken = lock.getLockToken();
try {
superuser.removeLockToken(lockToken);
String nlt = lock.getLockToken();
assertTrue("freshly obtained lock token must either be null or the same as the one returned earlier",
nlt == null || nlt.equals(lockToken));
} finally {
// move lock token back in order to have lock removed properly
superuser.addLockToken(lockToken);
}
}
代码示例来源:origin: apache/jackrabbit
public static String getDavLocktoken(Lock lock) throws RepositoryException {
String jcrLockToken = lock.getLockToken();
if (jcrLockToken == null) {
return SESSPREFIX + Text.escape(lock.getNode().getIdentifier());
} else {
return OPENPREFIX + Text.escape(jcrLockToken);
}
}
代码示例来源:origin: brix-cms/brix-cms
private boolean isNodeEditable(BrixNode node) {
if (node.isNodeType("mix:versionable") && !node.isCheckedOut()) {
return false;
}
if (node.isLocked() && node.getLock().getLockToken() == null) {
return false;
}
return true;
}
代码示例来源:origin: apache/jackrabbit
public void testLockHolderAfterTokenTransfer() throws Exception {
String lockToken = lock.getLockToken();
Node n2 = (Node) otherSession.getItem(lockedNode.getPath());
try {
superuser.removeLockToken(lockToken);
otherSession.addLockToken(lockToken);
assertTrue("After lockToken transfer, the new lockHolder must get a non-null token", n2.getLock().getLockToken() != null);
assertTrue("After lockToken transfer, the new lockHolder must get the same token.", n2.getLock().getLockToken().equals(lockToken));
} finally {
// move lock token back in order to have lock removed properly
otherSession.removeLockToken(lockToken);
superuser.addLockToken(lockToken);
}
}
代码示例来源:origin: apache/jackrabbit
public void testGetLockTokens() throws RepositoryException,
NotExecutableException {
assertLockable(testNode);
boolean sessionScoped = false;
Lock l = lockMgr.lock(testPath, true, sessionScoped, Long.MAX_VALUE, null);
String ltoken = l.getLockToken();
assertTrue("Creating open scoped lock must add token to the lock manager.",
containsLockToken(lockMgr, ltoken));
assertTrue("Creating open scoped lock must add token to the lock manager.",
containsLockToken(superuser.getLockTokens(), ltoken));
}
代码示例来源:origin: apache/jackrabbit
/**
* Creates a new lock info for the given JCR lock object.
*
* @param lock the lock.
* @param idFactory the id factory.
* @throws RepositoryException if an error occurs while the node from the
* given lock or while creating the node id.
*/
private LockInfoImpl(Lock lock, IdFactoryImpl idFactory) throws RepositoryException {
super(lock.getLockToken(), lock.getLockOwner(), lock.isDeep(),
lock.isSessionScoped(), lock.getSecondsRemaining(), lock.isLockOwningSession(),
idFactory.createNodeId(lock.getNode()));
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi2jcr
/**
* Creates a new lock info for the given JCR lock object.
*
* @param lock the lock.
* @param idFactory the id factory.
* @throws RepositoryException if an error occurs while the node from the
* given lock or while creating the node id.
*/
private LockInfoImpl(Lock lock, IdFactoryImpl idFactory) throws RepositoryException {
super(lock.getLockToken(), lock.getLockOwner(), lock.isDeep(),
lock.isSessionScoped(), lock.getSecondsRemaining(), lock.isLockOwningSession(),
idFactory.createNodeId(lock.getNode()));
}
代码示例来源:origin: apache/jackrabbit
public void testGetLockTokensAfterUnlock() throws RepositoryException,
NotExecutableException {
assertLockable(testNode);
boolean sessionScoped = false;
Lock l = lockMgr.lock(testPath, true, sessionScoped, Long.MAX_VALUE, null);
String ltoken = l.getLockToken();
lockMgr.unlock(testPath);
assertFalse("Removing an open scoped lock must remove the token from the lock manager.",
containsLockToken(lockMgr, ltoken));
assertFalse("Removing an open scoped lock must remove the token from the lock manager.",
containsLockToken(superuser.getLockTokens(), ltoken));
}
代码示例来源:origin: apache/jackrabbit
public void testRefreshAfterTokenTransfer() throws Exception {
String lockToken = lock.getLockToken();
try {
superuser.removeLockToken(lockToken);
lock.refresh();
fail("After transfering lock token the original lock object cannot be refresh by session, that does hold lock any more.");
} catch (LockException e) {
// oK
} finally {
// move lock token back in order to have lock removed properly
superuser.addLockToken(lockToken);
}
}
代码示例来源:origin: apache/jackrabbit
public void testUnlockAfterTokenTransfer() throws Exception {
String lockToken = lock.getLockToken();
try {
superuser.removeLockToken(lockToken);
lockedNode.unlock();
fail("After transfering lock token the original lock object cannot be unlocked by session, that does hold lock any more.");
} catch (LockException e) {
// oK
} finally {
// move lock token back in order to have lock removed properly
superuser.addLockToken(lockToken);
}
}
代码示例来源:origin: apache/jackrabbit
public void testRefreshAfterTokenTransfer2() throws Exception {
String lockToken = lock.getLockToken();
Node n2 = (Node) otherSession.getItem(lockedNode.getPath());
try {
superuser.removeLockToken(lockToken);
otherSession.addLockToken(lockToken);
n2.getLock().refresh();
} finally {
// move lock token back in order to have lock removed properly
otherSession.removeLockToken(lockToken);
superuser.addLockToken(lockToken);
}
}
内容来源于网络,如有侵权,请联系作者删除!