本文整理了Java中javax.jcr.lock.Lock.refresh()
方法的一些代码示例,展示了Lock.refresh()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lock.refresh()
方法的具体详情如下:
包路径:javax.jcr.lock.Lock
类名称:Lock
方法名:refresh
[英]If this lock's time-to-live is governed by a timer, this method resets that timer so that the lock does not timeout and expire. If this lock's time-to-live is not governed by a timer, then this method has no effect.
[中]如果此锁的生存时间由计时器控制,则此方法将重置该计时器,以便该锁不会超时和过期。如果此锁的生存时间不受计时器控制,则此方法无效。
代码示例来源:origin: apache/jackrabbit
/**
* Test {@link javax.jcr.lock.Lock#refresh()} on a released lock.
*/
public void testRefresh() throws RepositoryException {
// refresh must succeed
lock.refresh();
}
代码示例来源:origin: apache/jackrabbit
/** {@inheritDoc} */
public void refresh() throws RepositoryException, RemoteException {
lock.refresh();
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
@Override
public void refresh() throws LockException, RepositoryException {
synchronized (session) {
lock.refresh();
setTimeout(lock, getSecondsRemaining());
}
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-ocm
public void refresh() {
try
{
lock.refresh();
}
catch (javax.jcr.RepositoryException e)
{
throw new RepositoryException(e);
}
}
代码示例来源:origin: org.apache/jackrabbit-ocm
public void refresh() {
try
{
lock.refresh();
}
catch (javax.jcr.RepositoryException e)
{
throw new RepositoryException(e);
}
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
private static void refreshLock(final Session session, final String nodePath) {
try {
final LockManager lockManager = session.getWorkspace().getLockManager();
final Lock lock = lockManager.getLock(nodePath);
lock.refresh();
log.debug("Lock successfully refreshed");
} catch (RepositoryException e) {
log.error("Failed to refresh lock", e);
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Test {@link javax.jcr.lock.Lock#refresh()} on a released lock.
*
* @throws Exception
*/
public void testRefreshNotLive() throws Exception {
// release the lock
lockMgr.unlock(lockedNode.getPath());
// refresh
try {
lock.refresh();
fail("Refresh on a lock that is not alive must fail");
} catch (LockException e) {
// success
}
}
代码示例来源:origin: apache/jackrabbit
/**
* {@inheritDoc}
*/
public void refreshLock(SessionInfo sessionInfo, NodeId nodeId)
throws LockException, RepositoryException {
getNode(nodeId, getSessionInfoImpl(sessionInfo)).getLock().refresh();
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi2jcr
/**
* {@inheritDoc}
*/
public void refreshLock(SessionInfo sessionInfo, NodeId nodeId)
throws LockException, RepositoryException {
getNode(nodeId, getSessionInfoImpl(sessionInfo)).getLock().refresh();
}
代码示例来源:origin: info.magnolia/magnolia-core
private void restore(Node node, Lock lock) throws RepositoryException {
String nodeType = node.getPrimaryNodeType().getName();
log.debug("Restoring previous version of node at {} of type {}", node.getPath(), nodeType);
// Get last version of parent or single node.
Version version = getPreviousVersion(node);
// Check the version.
if (version == null) {
throw new RepositoryException("No previous version found for node at " + node.getPath());
}
// Restore parent previous version
versionManager.restore(node, version, true);
if (includingChildren) {
lock.refresh();
restoreAllChildren(node, nodeType);
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Test refresh
*/
public void testRefresh() throws Exception {
// create new node
Node n = testRootNode.addNode(nodeName1, testNodeType);
ensureMixinType(n, mixLockable);
testRootNode.getSession().save();
// lock node and get lock token
Lock lock = n.lock(false, true);
// assert: lock must be alive
assertTrue("lock must be alive", lock.isLive());
// assert: refresh must succeed
lock.refresh();
// unlock node
n.unlock();
// assert: lock must not be alive
assertFalse("lock must not be alive", lock.isLive());
}
代码示例来源:origin: apache/jackrabbit
public void execute(Session session, Node test) throws RepositoryException {
// add versionable nodes
for (int i = 0; i < NUM_OPERATIONS / CONCURRENCY; i++) {
Node n = test.addNode("test" + i);
n.addMixin(mixLockable);
session.save();
Lock l = n.lock(false, true);
l.refresh();
n.unlock();
}
}
}, CONCURRENCY);
代码示例来源:origin: info.magnolia/magnolia-core
protected void preDeleteNode(Node node, Context context, Lock lock) throws RepositoryException {
// Due to deprecated #preDeleteNode(Node,Context) method, lock object can be null.
if (lock != null) {
lock.refresh();
}
VersionConfig versionConfig = Components.getComponent(VersionConfig.class);
if (versionConfig.isActive()) {
version(node, context);
}
markAsDeleted(node);
purgeContent(node);
storeDeletionInfo(node, context);
// save changes before progressing on sub node - means we can't roll back, but session doesn't grow out of limits
node.getSession().save();
Rule rule = new Rule(StringUtils.split(getItemTypes() + "," + NodeTypes.MetaData.NAME + "," + NodeTypes.Resource.NAME, ", "));
rule.reverse();
for (Iterator<Node> iter = new FilteringNodeIterator(node.getNodes(), new RuleBasedNodePredicate(rule)); iter.hasNext(); ) {
preDeleteNode(iter.next(), context, lock);
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Test refresh
*/
public void testRefreshNotLive() throws Exception {
// create new node
Node n = testRootNode.addNode(nodeName1, testNodeType);
ensureMixinType(n, mixLockable);
testRootNode.getSession().save();
// lock node and get lock token
Lock lock = n.lock(false, true);
// assert: lock must be alive
assertTrue("lock must be alive", lock.isLive());
// unlock node
n.unlock();
// assert: lock must not be alive
assertFalse("lock must not be alive", lock.isLive());
// refresh
try {
lock.refresh();
fail("Refresh on a lock that is not alive must fail");
} catch (LockException e) {
// success
}
}
代码示例来源:origin: apache/jackrabbit
public void testLock2() throws RepositoryException, NotExecutableException {
Node n = createLockableNode(testRootNode);
modifyPrivileges(n.getPath(), PrivilegeRegistry.REP_WRITE, false);
modifyPrivileges(n.getPath(), Privilege.JCR_LOCK_MANAGEMENT, true);
Node n2 = getTestNode().getNode(nodeName1);
// all lock operations must succeed
Lock l = n2.lock(true, true);
l.refresh();
n2.unlock();
}
代码示例来源:origin: apache/jackrabbit
public void execute(Session session, Node test)
throws RepositoryException {
int i = 0;
try {
Node n = test.addNode("test");
n.addMixin(mixLockable);
session.save();
for (i = 0; i < NUM_OPERATIONS / CONCURRENCY; i++) {
Lock lock = n.lock(false, true);
final UserTransaction utx = new UserTransactionImpl(test.getSession());
utx.begin();
lock.refresh();
utx.commit();
n.unlock();
}
} catch (Exception e) {
final String threadName = Thread.currentThread().getName();
final Throwable deepCause = getLevel2Cause(e);
if (deepCause != null && deepCause instanceof StaleItemStateException) {
// ignore
} else {
throw new RepositoryException(threadName + ", i=" + i + ":" + e.getClass().getName(), e);
}
}
}
}, CONCURRENCY);
代码示例来源: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 testLock3() throws RepositoryException, NotExecutableException {
Node n = createLockableNode(testRootNode);
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);
Node n2 = trn.getNode(n.getName());
n2.lock(true, true);
Lock l = n2.getLock();
// withdraw lock-mgmt -> must not be able to refresh the lock or
// unlock the node
modifyPrivileges(trn.getPath(), Privilege.JCR_LOCK_MANAGEMENT, false);
try {
l.refresh();
fail("TestUser doesn't have permission to refresh the lock.");
} catch (AccessDeniedException e) {
// success
}
try {
n2.unlock();
fail("TestUser doesn't have permission to unlock the node.");
} catch (AccessDeniedException e) {
// success
}
// make sure the lock can be removed upon session.logout.
modifyPrivileges(trn.getPath(), Privilege.JCR_LOCK_MANAGEMENT, true);
}
代码示例来源: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);
}
}
代码示例来源:origin: apache/jackrabbit
/**
* @see DavResource#refreshLock(LockInfo, String)
*/
public ActiveLock refreshLock(LockInfo lockInfo, String lockToken) throws DavException {
if (!exists()) {
throw new DavException(DavServletResponse.SC_NOT_FOUND);
}
ActiveLock lock = getLock(lockInfo.getType(), lockInfo.getScope());
if (lock == null) {
throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "No lock with the given type/scope present on resource " + getResourcePath());
}
if (lock instanceof JcrActiveLock) {
try {
// refresh JCR lock and return the original lock object.
node.getLock().refresh();
} catch (RepositoryException e) {
throw new JcrDavException(e);
}
} else {
lock = lockManager.refreshLock(lockInfo, lockToken, this);
}
/* since lock has infinite lock (simple) or undefined timeout (jcr)
return the lock as retrieved from getLock. */
return lock;
}
内容来源于网络,如有侵权,请联系作者删除!